blob: ab7853c27aa2d6820b659a737ba8d61bc5274452 [file] [log] [blame]
ChetanGaonker901727c2016-11-29 14:05:03 -08001#
2# Copyright 2016-present Ciena Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16import unittest
17import os,sys
ChetanGaonker901727c2016-11-29 14:05:03 -080018import keystoneclient.v2_0.client as ksclient
19import keystoneclient.apiclient.exceptions
20import neutronclient.v2_0.client as nclient
21import neutronclient.common.exceptions
22import novaclient.v1_1.client as novaclient
23from multiprocessing import Pool
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080024from neutronclient.v2_0 import client as neutron_client
ChetanGaonker901727c2016-11-29 14:05:03 -080025from nose.tools import assert_equal
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080026from OnosCtrl import OnosCtrl, get_mac
ChetanGaonker901727c2016-11-29 14:05:03 -080027from CordLogger import CordLogger
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080028import time
ChetanGaonker901727c2016-11-29 14:05:03 -080029
ChetanGaonker71fe0302016-12-19 17:45:44 -080030PROTO_NAME_TCP = 'tcp'
31PROTO_NAME_ICMP = 'icmp'
32IPv4 = 'IPv4'
33
34OS_USERNAME = 'admin'
35OS_PASSWORD = 'admin'
36OS_TENANT = 'admin'
37OS_AUTH_URL = 'http://10.119.192.11:5000/v2.0/'
38OS_TOKEN = 'vDgyUPEp'
39OS_SERVICE_ENDPOINT = 'http://10.119.192.11:35357/v2.0/'
40
41#VM SSH CREDENTIALS
42VM_USERNAME = 'ubuntu'
43VM_PASSWORD = 'ubuntu'
44
45TENANT_PREFIX = 'test-'
46VM_PREFIX = 'test-'
47NETWORK_PREFIX = 'test-'
48CIDR_PREFIX = '192.168'
49
ChetanGaonker901727c2016-11-29 14:05:03 -080050class cordvtn_exchange(CordLogger):
51
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080052 app_cordvtn = 'org.opencord.vtn'
53 test_path = os.path.dirname(os.path.realpath(__file__))
54 cordvtn_dir = os.path.join(test_path, '..', 'setup')
55 cordvtn_conf_file = os.path.join(test_path, '..', '../cordvtn/network_cfg.json')
ChetanGaonker901727c2016-11-29 14:05:03 -080056
57 @classmethod
58 def setUpClass(cls):
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080059 ''' Activate the cordvtn app'''
ChetanGaonker901727c2016-11-29 14:05:03 -080060 time.sleep(3)
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080061 cls.onos_ctrl = OnosCtrl(cls.app_cordvtn)
62 status, _ = cls.onos_ctrl.activate()
63 assert_equal(status, False)
64 time.sleep(3)
65 cls.cordvtn_setup()
ChetanGaonker901727c2016-11-29 14:05:03 -080066
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080067 @classmethod
68 def tearDownClass(cls):
ChetanGaonker901727c2016-11-29 14:05:03 -080069 '''Deactivate the cord vtn app'''
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080070 cls.onos_ctrl.deactivate()
71 cls.cord_vtn_cleanup()
ChetanGaonker901727c2016-11-29 14:05:03 -080072
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080073 @classmethod
74 def cordvtn_setup(cls):
75 pass
76
77 @classmethod
78 def cord_vtn_cleanup(cls):
79 ##reset the ONOS port configuration back to default
80 for config in cls.configs.items():
81 OnosCtrl.delete(config)
82
83 @classmethod
84 def onos_load_config(cls, cordvtn_conf_file):
85 status, code = OnosCtrl.config(cordvtn_conf_file)
ChetanGaonker901727c2016-11-29 14:05:03 -080086 if status is False:
87 log.info('JSON request returned status %d' %code)
88 assert_equal(status, True)
89 time.sleep(3)
90
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080091 @classmethod
92 def get_neutron_credentials():
93 n = {}
94 n['username'] = os.environ['OS_USERNAME']
95 n['password'] = os.environ['OS_PASSWORD']
96 n['auth_url'] = os.environ['OS_AUTH_URL']
97 n['tenant_name'] = os.environ['OS_TENANT_NAME']
98 return n
99
100 @classmethod
ChetanGaonker71fe0302016-12-19 17:45:44 -0800101 def create_net(tenant_id, name, shared="", external=""):
102 cmd = "neutron net-create %s %s %s --tenant-id=%s"%(name, shared, external, tenant_id)
103 os.system(cmd)
104 time.sleep(1)
105
106 @classmethod
107 def create_subnet(tenant_id, name, subnet, dhcp=""):
108 cmd = "neutron subnet-create %s %s --name %s %s --tenant-id=%s"%(net, subnet, name, dhcp, tenant_id)
109 os.system(cmd)
110 time.sleep(1)
111
112 @classmethod
113 def del_net( tenant_id, name):
114 cmd = "neutron net-delete %s --tenant-id=%s"%(name, tenant_id)
115 os.system(cmd)
116 time.sleep(1)
117
118 @classmethod
119 def del_subnet( tenant_id, name):
120 cmd = "neutron subnet-create %s %s --name %s %s --tenant-id=%s"%(net,subnet,name, dhcp, tenant_id)
121 os.system(cmd)
122 time.sleep(1)
123
124 @classmethod
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800125 def create_net_and_subnet():
126 network_name = "Subscriber-1"
127
128 creds = get_neutron_credentials()
129 neutron = client.Client(**creds)
130
131 body_example = {
132 "network":
133 {
134 "name": network_name,
135 "admin_state_up":True
136 }
137 }
138 net = neutron.create_network(body=body_example)
139 net_dict = net['network']
140 network_id = net_dict['id']
141 print "Network %s created" %network_id
142
143 create_subnet = {
144 "subnets": [
145 {
146 "cidr":"10.10.0.0/24",
147 "ip_version":4,
148 "network_id":network_id
149 }
150 ]
151 }
152 subnet = neutron.create_subnet(body = create_subnet)
153 print "Created Subnet %s"%subnet
154
155 @classmethod
156 def create_network(i):
157 neutron_credentials = get_neutron_credentials()
158 neutron = neutron_client.Client(**neutron_credentials)
159 json = {'network': {'name': 'network-' + str(i),
160 'admin_state_up': True}}
161 while True:
162 try:
163 neutron.create_network(body=json)
164 print '\nnetwork-' + str(i) + ' created'
165 break
166 except Exception as e:
167 print e
168 continue
169
ChetanGaonker901727c2016-11-29 14:05:03 -0800170 def create_tenant(tenant_name):
171 new_tenant = keystone.tenants.create(tenant_name=tenant_name,
172 description="CORD Tenant \
173 created",
174 enabled=True)
175 tenant_id = new_tenant.id
176 tenant_status = True
177 user_data = []
178 for j in range(2):
179 j += 1
180 user_name = tenant_name + '-user-' + str(j)
181 user_data.append(create_user(user_name, tenant_id))
182
183 print " Tenant and User Created"
184
185 tenant_data = {'tenant_name': tenant_name,
186 'tenant_id': tenant_id,
187 'status': tenant_status}
188 return tenant_data
189
190 def create_user(user_name, tenant_id):
191 new_user = keystone.users.create(name=user_name,
192 password="ubuntu",
193 tenant_id=tenant_id)
194 print(' - Created User %s' % user_name)
195 keystone.roles.add_user_role(new_user, member_role, tenant_id)
196 if assign_admin:
197 admin_user = keystone.users.find(name='admin')
198 admin_role = keystone.roles.find(name='admin')
199 keystone.roles.add_user_role(admin_user, admin_role, tenant_id)
200 user_data = {'name': new_user.name,
201 'id': new_user.id}
202 return user_data
203
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800204 def create_port( router_id, network_id):
205 credentials = get_credentials()
206 neutron = client.Client(**credentials)
207 router = neutron.show_router(router_id)
208
209 value = {'port':{
210 'admin_state_up':True,
211 'device_id': router_id,
212 'name': 'port1',
213 'network_id':network_id,
214 }}
215 response = neutron.create_port(body=value)
216
ChetanGaonker71fe0302016-12-19 17:45:44 -0800217 def router_create(self, name):
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800218 external_network = None
219 for network in self.neutron.list_networks()["networks"]:
220 if network.get("router:external"):
221 external_network = network
222 break
223
224 if not external_network:
225 raise Exception("Alarm! Can not to find external network")
226
227 gw_info = {
228 "network_id": external_network["id"],
229 "enable_snat": True
230 }
231 router_info = {
232 "router": {
233 "name": name,
234 "external_gateway_info": gw_info,
235 "tenant_id": self.tenant_id
236 }
237 }
ChetanGaonker71fe0302016-12-19 17:45:44 -0800238 router = self.neutron.router_create(router_info)['router']
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800239 return router
240
ChetanGaonker901727c2016-11-29 14:05:03 -0800241 def delete_tenant(tenant_name):
242 tenant = keystone.tenants.find(name=tenant_name)
243 for j in range(2):
244 j += 1
245 user_name = tenant_name + '-user-' + str(j)
246 delete_user(user_name, tenant.id)
247 tenant.delete()
248 print(' - Deleted Tenant %s ' % tenant_name)
249 return True
250
251 def delete_user(user_name, tenant_id):
252 user = keystone.users.find(name=user_name)
253 user.delete()
254
255 print(' - Deleted User %s' % user_name)
256 return True
257
ChetanGaonker71fe0302016-12-19 17:45:44 -0800258 def set_environment(tenants_num=0, networks_per_tenant=1, vms_per_network=2):
259 octet = 115
260 vm_inc = 11
261 image = nova_connection.images.get(IMAGE_ID)
262 flavor = nova_connection.flavors.get(FLAVOR_ID)
263
264 admin_user_id = keystone_connection.users.find(name=OS_USERNAME).id
265 member_role_id = keystone_connection.roles.find(name='Member').id
266 for num_tenant in range(1, tenants_num+1):
267 tenant = keystone_connection.tenants.create('%stenant%s' % (TENANT_PREFIX, num_tenant))
268 keystone_connection.roles.add_user_role(admin_user_id, member_role_id, tenant=tenant.id)
269 for num_network in range(networks_per_tenant):
270 network_json = {'name': '%snet%s' % (NETWORK_PREFIX, num_tenant*10+num_network),
271 'admin_state_up': True,
272 'tenant_id': tenant.id}
273 network = neutron_connection.create_network({'network': network_json})
274 subnet_json = {'name': '%ssubnet%s' % (NETWORK_PREFIX, num_tenant*10+num_network),
275 'network_id': network['network']['id'],
276 'tenant_id': tenant.id,
277 'enable_dhcp': True,
278 'cidr': '%s.%s.0/24' % (CIDR_PREFIX, octet), 'ip_version': 4}
279 octet += 1
280 subnet = neutron_connection.create_subnet({'subnet': subnet_json})
281 router_json = {'name': '%srouter%s' % (NETWORK_PREFIX, num_tenant*10+num_network),
282 'tenant_id': tenant.id}
283 router = neutron_connection.router_create({'router': router_json})
284 port = neutron_connection.add_interface_router(router['router']['id'], {'subnet_id': subnet['subnet']['id']})
285 for num_vm in range(vms_per_network):
286 tenant_nova_connection = novacli.Client(OS_USERNAME, OS_PASSWORD, tenant.name, OS_AUTH_URL)
287 m = tenant_nova_connection.servers.create('%svm%s' % (VM_PREFIX, vm_inc), image, flavor, nics=[{'net-id': network['network']['id']}, {'net-id': MGMT_NET}])
288 vm_inc += 1
289
290 @classmethod
291 def get_id(tenant_id, name):
292 cmd = "neutron %s-list --tenant-id=%s"%(objname,sdn_tenant_id)
293 output = os.system(cmd)
294 lis = output.split("\n")
295 for i in lis:
296 tokens = i.split()
Chetan Gaonker29e49842017-01-09 22:55:04 +0000297 if len(tokens)>3 and tokens[3] == name:
ChetanGaonker71fe0302016-12-19 17:45:44 -0800298 return tokens[1]
299 return none
300
301 @classmethod
302 def nova_boot(tenant_id, name, netid=None, portid=None):
303 if netid:
Chetan Gaonker29e49842017-01-09 22:55:04 +0000304 cmd = "nova --os-tenant-id %s boot --flavor 1 --image %s --nic net-id=%s %s"%(tenant_id, vm_image_id,netid,name)
ChetanGaonker71fe0302016-12-19 17:45:44 -0800305 if portid:
306 cmd = "nova --os-tenant-is %s boot --flavor 1 --image %s --nic port-id=%s %s"%(tenant_id,vm_image_id,portid,name)
307 os.system(cmd)
308
309 @classmethod
310 def port_create(sdn_tenant_id,name, net, fixedip, subnetid):
311 cmd = "neutron port-create --name %s --fixed-ip subnet_id=%s,ip_address=%s --tenant-id=%s %s" %(name,subnetid,fixedip,sdn_tenant_id,net)
312 os.system(cmd)
313 time.sleep(1)
314
315 @classmethod
316 def nova_wait_boot(sdn_tenant_id,name, state, retries=10):
317 global errno
318 cmd = "nova --os-tenant-id %s list" %(sdn_tenant_id)
319 for i in range(retries):
320 out = os.system(cmd)
321 lis = out.split("\n")
322 for line in lis:
323 toks = line.split()
324 if len(toks) >= 5 and toks[3] == name and toks[5] == state:
325 return
326 time.sleep(5)
Chetan Gaonker29e49842017-01-09 22:55:04 +0000327 errno=1
ChetanGaonker71fe0302016-12-19 17:45:44 -0800328
329 @classmethod
330 def port_delete(sdn_tenant_id,name):
331 cmd = "neutron port-delete %s" %(name)
332 os.system(cmd)
333 time.sleep(1)
334
335 @classmethod
336 def tenant_delete(name):
337 cmd = "keystone tenant-delete %s"%(name)
338 os.system(cmd)
339 time.sleep(1)
340
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800341 @classmethod
342 def verify_neutron_crud():
343 x = os.system("neutron_test.sh")
344 return x
ChetanGaonker901727c2016-11-29 14:05:03 -0800345
Author Name91eaeba2017-01-05 13:41:45 -0800346 def list_floatingips( **kwargs):
347 creds = get_neutron_credentials()
348 neutron = client.Client(**creds)
349 return neutron.list_floatingips(**kwargs)['floatingips']
350
351 def list_security_groups( **kwargs):
352 creds = get_neutron_credentials()
353 neutron = client.Client(**creds)
354 return neutron.list_security_groups(**kwargs)['security_groups']
355
356 def list_subnets( **kwargs):
357 creds = get_neutron_credentials()
358 neutron = client.Client(**creds)
359 return neutron.list_subnets(**kwargs)['subnets']
360
361 def list_networks( **kwargs):
362 creds = get_neutron_credentials()
363 neutron = client.Client(**creds)
364 return neutron.list_networks(**kwargs)['networks']
365
366 def list_ports( **kwargs):
367 creds = get_neutron_credentials()
368 neutron = client.Client(**creds)
369 return neutron.list_ports(**kwargs)['ports']
370
371 def list_routers( **kwargs):
372 creds = get_neutron_credentials()
373 neutron = client.Client(**creds)
374 return neutron.list_routers(**kwargs)['routers']
375
376 def update_floatingip( fip, port_id=None):
377 creds = get_neutron_credentials()
378 neutron = client.Client(**creds)
379 neutron.update_floatingip(fip, {"floatingip":
380 {"port_id": port_id}})
381
382 def update_subnet( subnet_id, **subnet_params):
383 creds = get_neutron_credentials()
384 neutron = client.Client(**creds)
385 neutron.update_subnet(subnet_id, {'subnet': subnet_params})
386
387 def update_router( router_id, **router_params):
388 creds = get_neutron_credentials()
389 neutron = client.Client(**creds)
390 neutron.update_router(router_id, {'router': router_params})
391
392 def router_gateway_set( router_id, external_gateway):
393 creds = get_neutron_credentials()
394 neutron = client.Client(**creds)
395 neutron.update_router(
396 router_id, {'router': {'external_gateway_info':
397 {'network_id': external_gateway}}})
398
399 def router_gateway_clear( router_id):
400 creds = get_neutron_credentials()
401 neutron = client.Client(**creds)
402 neutron.update_router(
403 router_id, {'router': {'external_gateway_info': None}})
404
405 def router_add_interface( router_id, subnet_id):
406 creds = get_neutron_credentials()
407 neutron = client.Client(**creds)
408 neutron.add_interface_router(router_id, {'subnet_id': subnet_id})
409
410 def router_rem_interface( router_id, subnet_id):
411 creds = get_neutron_credentials()
412 neutron = client.Client(**creds)
413 neutron.remove_interface_router(
414 router_id, {'subnet_id': subnet_id})
415
416 def create_floatingip( **floatingip_params):
417 creds = get_neutron_credentials()
418 neutron = client.Client(**creds)
419 response = neutron.create_floatingip(
420 {'floatingip': floatingip_params})
421 if 'floatingip' in response and 'id' in response['floatingip']:
422 return response['floatingip']['id']
423
ChetanGaonker901727c2016-11-29 14:05:03 -0800424
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800425 def test_cordvtn_config_on_restart(self):
426 pass
ChetanGaonker901727c2016-11-29 14:05:03 -0800427
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800428 def test_cordvtn_arp_proxy(self):
429 pass
430
431 def test_cordvtn_gateway(self):
432 pass
433
434 def test_cordvtn_openstack_access(self):
435 pass
436
437 def test_cordvtn_xos_access(self):
438 pass
439
440 def test_cordvtn_ssh_access(self):
441 pass
442
443 def test_cordvtn_ovsdbport(self):
444 pass
445
446 def test_cordvtn_local_management_ip(self):
447 pass
448
449 def test_cordvtn_compute_nodes(self):
450 pass
451
452 def test_cordvtn_basic_tenant(self):
453 onos_load_config()
454 status = verify_neutron_crud()
ChetanGaonker71fe0302016-12-19 17:45:44 -0800455
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800456 if status != 0:
457 print "Issues with Neutron working state"
458 assert_equal(status, True)
459
ChetanGaonker71fe0302016-12-19 17:45:44 -0800460 tenant_1= create_tenant("CORD_Subscriber_Test_Tenant_1")
461 if ten1 != 0:
462 print "Creation of CORD Subscriber Test Tenant 1"
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800463
ChetanGaonker71fe0302016-12-19 17:45:44 -0800464 tenant_2 = create_tenant("CORD_Subscriber_Test_Tenant_2")
465 if ten2 != 0:
466 print "Creation of CORD Subscriber Test Tenant 2"
467
468 create_net(tenant_1,"a1")
469 create_subnet(tenant_1,"a1","as1","10.0.1.0/24")
470
471 create_net(tenant_2,"a2")
472 create_subnet(tenant_2,"a2","as1","10.0.2.0/24")
473
474 netid_1 = get_id(tenant_1,"net","a1")
475 netid_2 = get_id(tenant_2,"net","a2")
476
477 nova_boot(tenant_1,"vm1",netid=netid)
478 nova_boot(tenant_2,"vm1",netid=netid)
479
480 nova_wait_boot(tenant_1,"vm1", "ACTIVE")
481 nova_wait_boot(tenant_2,"vm1", "ACTIVE")
482
483 router_create(tenant_1,"r1")
484 router_interface_add(tenant_1,"r1","as1")
485 router_create(tenant_2,"r1")
486 router_interface_add(tenant_2,"r1","as1")
487
488 create_net(tenant_1,"x1","","--router:external=True")
489 create_net(tenant_2,"x1","","--router:external=True")
490
491 router_gateway_set(tenant_1,"r1","x1")
492 router_gateway_set(tenant_2,"r1","x1")
493
494 subnetid_1 = get_id(tenant_1,"subnet","as1")
495 subnetid_2 = get_id(tenant_2,"subnet","as1")
496 port_create(tenant_1,"p1","a1","10.0.1.100",subnetid_1)
497 port_create(tenant_2,"p1","a1","10.0.1.100",subnetid_2)
498
499 port_id_1 = get_id(tenant_1,"port","p1")
500 port_id_2 = get_id(tenant_2,"port","p1")
501
502 port_delete(tenant_1,"p1")
503 port_delete(tenant_2,"p1")
504
505 router_gateway_clear(tenant_1,"r1")
506 router_gateway_clear(tenant_2,"r1")
507
508 router_interface_delete(tenant_1,"r1","as1")
509 router_interface_delete(tenant_2,"r1","as1")
510
511 router_delete(tenant_1,"r1")
512 router_delete(tenant_2,"r1")
513
514 nova_delete(tenant_1,"vm1")
515 nova_delete(tenant_2,"vm1")
516
517 delete_subnet(tenant_1,"as1")
518 delete_subnet(tenant_1,"as1")
519
520 delete_net(tenant_1,"x1")
521 delete_net(tenant_2,"x1")
522
523 tenant_delete("CORD_Subscriber_Test_Tenant_1")
524 tenant_delete("CORD_Subscriber_Test_Tenant_2")
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800525 assert_equal(ret1, ret2)
ChetanGaonker901727c2016-11-29 14:05:03 -0800526
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800527 def test_cordvtn_for_create_network(self):
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800528 onos_load_config()
529 status = verify_neutron_crud()
530 if status != 0:
531 print "Issues with Neutron working state"
532
533 ret1 = create_tenant(netA)
534 if ret1 != 0:
535 print "Creation of Tenant netA Failed"
536
537 ret2 = create_tenant(netB)
538 if ret2 != 0:
539 print "Creation of Tenant netB Failed"
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800540 network = {'name': self.network_name, 'admin_state_up': True}
541 self.neutron.create_network({'network':network})
542 log.info("Created network:{0}".format(self.network_name))
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800543 assert_equal(ret1, ret2)
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800544
545 def test_cordvtn_to_create_net_work_with_subnet(self):
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800546 onos_load_config()
547 status = verify_neutron_crud()
548 if status != 0:
549 print "Issues with Neutron working state"
550
551 ret1 = create_tenant(netA)
552 if ret1 != 0:
553 print "Creation of Tenant netA Failed"
554
555 ret2 = create_tenant(netB)
556 if ret2 != 0:
557 print "Creation of Tenant netB Failed"
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800558 network_name = self.network_name
559 network = {'name': network_name, 'admin_state_up': True}
560 network_info = self.neutron.create_network({'network':network})
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800561 network_id = network_info['network']['id']
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800562
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800563 log.info("Created network:{0}".format(network_id))
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800564 self.network_ids.append(network_id)
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800565 subnet_count = 1
566 for cidr in self.subnet_cidrs:
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800567 gateway_ip = str(list(cidr)[1])
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800568 subnet = {"network_id": network_id, "ip_version":4,
569 "cidr":str(cidr), "enable_dhcp":True,
570 "host_routes":[{"destination":"0.0.0.0/0", "nexthop":gateway_ip}]
571 }
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800572 subnet = {"name":"subnet-"+str(subnet_count), "network_id": network_id, "ip_version":4, "cidr":str(cidr), "enable_dhcp":True}
573 print subnet
574 self.neutron.create_subnet({'subnet':subnet})
575 log.info("Created subnet:{0}".format(str(cidr)))
576 if not self.number_of_subnet - 1:
577 break
578 self.number_of_subnet -= 1
579 subnet_count += 1
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800580 assert_equal(ret1, ret2)
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800581
582 def test_cordvtn_subnet_limit(self):
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800583 onos_load_config()
584 status = verify_neutron_crud()
585 if status != 0:
586 print "Issues with Neutron working state"
587
588 ret1 = create_tenant(netA)
589 if ret1 != 0:
590 print "Creation of Tenant netA Failed"
591
592 ret2 = create_tenant(netB)
593 if ret2 != 0:
594 print "Creation of Tenant netB Failed"
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800595 network_name = uuid.uuid4().get_hex()
596 network = {'name': network_name, 'admin_state_up': True}
597 network_info = self.neutron.create_network({'network':network})
598 log.info("Created network:{0}".format(network_name))
599 network_id = network_info['network']['id']
600 self.network_ids.append(network_id)
601 subnet_cidrs = ['11.2.2.0/29', '11.2.2.8/29']
602 for cidr in subnet_cidrs:
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800603 subnet = {"network_id": network_id, "ip_version":4, "cidr": cidr}
604 subnet_info = self.neutron.create_subnet({'subnet':subnet})
605 subnet_id = subnet_info['subnet']['id']
606 log.info("Created subnet:{0}".format(cidr))
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800607 while True:
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800608 port = {"network_id": network_id, "admin_state_up": True}
609 port_info = self.neutron.create_port({'port':port})
610 port_id = port_info['port']['id']
611 self.port_ids.append(port_id)
612 log.info("Created Port:{0}".format(port_info['port']['id']))
613 if not self.quota_limit:
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800614 break
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800615 self.quota_limit -= 1
616 assert_equal(ret1, ret2)
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800617
618 def test_cordvtn_floatingip_limit(self):
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800619 onos_load_config()
620 status = verify_neutron_crud()
621 if status != 0:
622 print "Issues with Neutron working state"
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800623
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800624 ret1 = create_tenant(netA)
625 if ret1 != 0:
626 print "Creation of Tenant netA Failed"
627
628 ret2 = create_tenant(netB)
629 if ret2 != 0:
630 print "Creation of Tenant netB Failed"
631 while True:
632 floatingip = {"floating_network_id": self.floating_nw_id}
633 fip_info = self.neutron.create_floatingip({'floatingip':floatingip})
634 fip_id = fip_info['floatingip']['id']
635 log.info("Created Floating IP:{0}".format(fip_id))
636 self.fip_ids.append(fip_id)
637 if not self.quota_limit:
638 break
639 self.quota_limit -= 1
640 assert_equal(ret1, ret2)
641
642 def test_cordvtn_10_neutron_networks(self):
643 onos_load_config()
644 status = verify_neutron_crud()
645 if status != 0:
646 print "Issues with Neutron working state"
647
648 ret1 = create_tenant(netA)
649 if ret1 != 0:
650 print "Creation of Tenant netA Failed"
651
652 ret2 = create_tenant(netB)
653 if ret2 != 0:
654 print "Creation of Tenant netB Failed"
655 pool = Pool(processes=10)
656 ret = os.system("neutron quote-update --network 15")
657 if ret1 != 0:
658 print "Neutron network install failed"
659 for i in range(1, 11):
660 pool.apply_asynch(create_network, (i, ))
661
662 pool.close()
663 pool.join()
664 assert_equal(ret1, ret2)
665
666 def test_cordvtn_100_neutron_networks(self):
667 onos_load_config()
668 status = verify_neutron_crud()
669 if status != 0:
670 print "Issues with Neutron working state"
671
672 ret1 = create_tenant(netA)
673 if ret1 != 0:
674 print "Creation of Tenant netA Failed"
675
676 ret2 = create_tenant(netB)
677 if ret2 != 0:
678 print "Creation of Tenant netB Failed"
679 pool = Pool(processes=10)
680
681 ret = os.system("neutron quote-update --network 105")
682 if ret1 != 0:
683 print "Neutron network install failed"
684 for i in range(1, 101):
685 pool.apply_asynch(create_network, (i, ))
686
687 pool.close()
688 pool.join()
689 assert_equal(ret1, ret2)
690
691 def test_cordvtn_service_dependency_for_two_subnets(self):
692 pass
693
694 def test_cordvtn_service_dependency_for_three_subnets(self):
695 pass
696
697 def test_cordvtn_service_dependency_for_four_subnets(self):
698 pass
699
700 def test_cordvtn_service_dependency_for_five_subnets(self):
701 pass
702
703 def test_cordvtn_for_biderectional_connections(self):
704 pass
705
706 def test_cordvtn_authentication_from_openstack(self):
707 pass
708
709 def test_cordvtn_with_gateway(self):
710 pass
711
712 def test_cordvtn_without_gateway(self):
713 pass
714
715 def test_cordvtn_for_service_instance(self):
716 pass
717
718 def test_cordvtn_for_instance_to_network(self):
719 pass
720
721 def test_cordvtn_for_network_to_instance(self):
722 pass
723
724 def test_cordvtn_for_instance_to_instance(self):
725 pass
726
727 def test_cordvtn_for_network_to_network(self):
728 pass
729
730 def test_cordvtn_without_neutron_ml2_plugin(self):
731 pass
732
733 def test_cordvtn_with_neutron_ml2_plugin(self):
734 pass
735
736 def test_cordvtn_service_network_type_private(self):
737 pass
738
739 def test_cordvtn_service_network_type_management_local(self):
740 pass
741
742 def test_cordvtn_service_network_type_management_host(self):
743 pass
744
745 def test_cordvtn_service_network_type_vsg(self):
746 pass
747
748 def test_cordvtn_service_network_type_access_agent(self):
ChetanGaonker901727c2016-11-29 14:05:03 -0800749 pass
750
751 def test_cordvtn_mgmt_network(self):
752 pass
753
754 def test_cordvtn_data_network(self):
755 pass
756
757 def test_cordvtn_public_network(self):
758 pass
759
760 def test_cordvtn_in_same_network(self):
761 pass
762
763 def test_cordvtn_local_mgmt_network(self):
764 pass
765
766 def test_cordvtn_service_dependency(self):
767 pass
768
769 def test_cordvtn_service_dependency_with_xos(self):
770 pass
771
772 def test_cordvtn_vsg_xos_service_profile(self):
773 pass
774
775 def test_cordvtn_access_agent(self):
776 pass
777
778 def test_cordvtn_network_creation(self):
779 pass
780
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800781 def test_cordvtn_network_deletion(self):
782 pass
783
ChetanGaonker901727c2016-11-29 14:05:03 -0800784 def test_cordvtn_removing_service_network(self):
785 pass
786
787 def test_cordvtn_web_application(self):
788 pass
789
790 def test_cordvtn_service_port(self):
791 pass
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800792
793 def test_cordvtn_inetgration_bridge(self):
794 pass
795