blob: 3c3ebf226b8e898b69b9862a888944e4ac6dcfb0 [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/'
Chetan Gaonker1f422af2017-01-13 21:59:16 +000040VM_BOOT_TIMEOUT = 100
41VM_DELETE_TIMEOUT = 100
42
ChetanGaonker71fe0302016-12-19 17:45:44 -080043
44#VM SSH CREDENTIALS
45VM_USERNAME = 'ubuntu'
46VM_PASSWORD = 'ubuntu'
47
48TENANT_PREFIX = 'test-'
49VM_PREFIX = 'test-'
50NETWORK_PREFIX = 'test-'
51CIDR_PREFIX = '192.168'
52
ChetanGaonker901727c2016-11-29 14:05:03 -080053class cordvtn_exchange(CordLogger):
54
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080055 app_cordvtn = 'org.opencord.vtn'
56 test_path = os.path.dirname(os.path.realpath(__file__))
57 cordvtn_dir = os.path.join(test_path, '..', 'setup')
58 cordvtn_conf_file = os.path.join(test_path, '..', '../cordvtn/network_cfg.json')
ChetanGaonker901727c2016-11-29 14:05:03 -080059
60 @classmethod
61 def setUpClass(cls):
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080062 ''' Activate the cordvtn app'''
ChetanGaonker901727c2016-11-29 14:05:03 -080063 time.sleep(3)
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080064 cls.onos_ctrl = OnosCtrl(cls.app_cordvtn)
65 status, _ = cls.onos_ctrl.activate()
66 assert_equal(status, False)
67 time.sleep(3)
68 cls.cordvtn_setup()
ChetanGaonker901727c2016-11-29 14:05:03 -080069
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080070 @classmethod
71 def tearDownClass(cls):
ChetanGaonker901727c2016-11-29 14:05:03 -080072 '''Deactivate the cord vtn app'''
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080073 cls.onos_ctrl.deactivate()
74 cls.cord_vtn_cleanup()
ChetanGaonker901727c2016-11-29 14:05:03 -080075
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080076 @classmethod
77 def cordvtn_setup(cls):
78 pass
79
80 @classmethod
81 def cord_vtn_cleanup(cls):
82 ##reset the ONOS port configuration back to default
83 for config in cls.configs.items():
84 OnosCtrl.delete(config)
85
86 @classmethod
87 def onos_load_config(cls, cordvtn_conf_file):
88 status, code = OnosCtrl.config(cordvtn_conf_file)
ChetanGaonker901727c2016-11-29 14:05:03 -080089 if status is False:
90 log.info('JSON request returned status %d' %code)
91 assert_equal(status, True)
92 time.sleep(3)
93
ChetanGaonkeraaea6b62016-12-16 17:06:39 -080094 @classmethod
95 def get_neutron_credentials():
96 n = {}
97 n['username'] = os.environ['OS_USERNAME']
98 n['password'] = os.environ['OS_PASSWORD']
99 n['auth_url'] = os.environ['OS_AUTH_URL']
100 n['tenant_name'] = os.environ['OS_TENANT_NAME']
101 return n
102
103 @classmethod
ChetanGaonker71fe0302016-12-19 17:45:44 -0800104 def create_net(tenant_id, name, shared="", external=""):
105 cmd = "neutron net-create %s %s %s --tenant-id=%s"%(name, shared, external, tenant_id)
106 os.system(cmd)
107 time.sleep(1)
108
109 @classmethod
110 def create_subnet(tenant_id, name, subnet, dhcp=""):
111 cmd = "neutron subnet-create %s %s --name %s %s --tenant-id=%s"%(net, subnet, name, dhcp, tenant_id)
112 os.system(cmd)
113 time.sleep(1)
114
115 @classmethod
116 def del_net( tenant_id, name):
117 cmd = "neutron net-delete %s --tenant-id=%s"%(name, tenant_id)
118 os.system(cmd)
119 time.sleep(1)
120
121 @classmethod
122 def del_subnet( tenant_id, name):
123 cmd = "neutron subnet-create %s %s --name %s %s --tenant-id=%s"%(net,subnet,name, dhcp, tenant_id)
124 os.system(cmd)
125 time.sleep(1)
126
127 @classmethod
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800128 def create_net_and_subnet():
129 network_name = "Subscriber-1"
130
131 creds = get_neutron_credentials()
132 neutron = client.Client(**creds)
133
134 body_example = {
135 "network":
136 {
137 "name": network_name,
138 "admin_state_up":True
139 }
140 }
141 net = neutron.create_network(body=body_example)
142 net_dict = net['network']
143 network_id = net_dict['id']
144 print "Network %s created" %network_id
145
146 create_subnet = {
147 "subnets": [
148 {
149 "cidr":"10.10.0.0/24",
150 "ip_version":4,
151 "network_id":network_id
152 }
153 ]
154 }
155 subnet = neutron.create_subnet(body = create_subnet)
156 print "Created Subnet %s"%subnet
157
158 @classmethod
159 def create_network(i):
160 neutron_credentials = get_neutron_credentials()
161 neutron = neutron_client.Client(**neutron_credentials)
162 json = {'network': {'name': 'network-' + str(i),
163 'admin_state_up': True}}
164 while True:
165 try:
166 neutron.create_network(body=json)
167 print '\nnetwork-' + str(i) + ' created'
168 break
169 except Exception as e:
170 print e
171 continue
172
ChetanGaonker901727c2016-11-29 14:05:03 -0800173 def create_tenant(tenant_name):
174 new_tenant = keystone.tenants.create(tenant_name=tenant_name,
175 description="CORD Tenant \
176 created",
177 enabled=True)
178 tenant_id = new_tenant.id
179 tenant_status = True
180 user_data = []
181 for j in range(2):
182 j += 1
183 user_name = tenant_name + '-user-' + str(j)
184 user_data.append(create_user(user_name, tenant_id))
185
186 print " Tenant and User Created"
187
188 tenant_data = {'tenant_name': tenant_name,
189 'tenant_id': tenant_id,
190 'status': tenant_status}
191 return tenant_data
192
193 def create_user(user_name, tenant_id):
194 new_user = keystone.users.create(name=user_name,
195 password="ubuntu",
196 tenant_id=tenant_id)
197 print(' - Created User %s' % user_name)
198 keystone.roles.add_user_role(new_user, member_role, tenant_id)
199 if assign_admin:
200 admin_user = keystone.users.find(name='admin')
201 admin_role = keystone.roles.find(name='admin')
202 keystone.roles.add_user_role(admin_user, admin_role, tenant_id)
203 user_data = {'name': new_user.name,
204 'id': new_user.id}
205 return user_data
206
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800207 def create_port( router_id, network_id):
208 credentials = get_credentials()
209 neutron = client.Client(**credentials)
210 router = neutron.show_router(router_id)
211
212 value = {'port':{
213 'admin_state_up':True,
214 'device_id': router_id,
215 'name': 'port1',
216 'network_id':network_id,
217 }}
218 response = neutron.create_port(body=value)
219
ChetanGaonker71fe0302016-12-19 17:45:44 -0800220 def router_create(self, name):
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800221 external_network = None
222 for network in self.neutron.list_networks()["networks"]:
223 if network.get("router:external"):
224 external_network = network
225 break
226
227 if not external_network:
228 raise Exception("Alarm! Can not to find external network")
229
230 gw_info = {
231 "network_id": external_network["id"],
232 "enable_snat": True
233 }
234 router_info = {
235 "router": {
236 "name": name,
237 "external_gateway_info": gw_info,
238 "tenant_id": self.tenant_id
239 }
240 }
ChetanGaonker71fe0302016-12-19 17:45:44 -0800241 router = self.neutron.router_create(router_info)['router']
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800242 return router
243
ChetanGaonker901727c2016-11-29 14:05:03 -0800244 def delete_tenant(tenant_name):
245 tenant = keystone.tenants.find(name=tenant_name)
246 for j in range(2):
247 j += 1
248 user_name = tenant_name + '-user-' + str(j)
249 delete_user(user_name, tenant.id)
250 tenant.delete()
251 print(' - Deleted Tenant %s ' % tenant_name)
252 return True
253
254 def delete_user(user_name, tenant_id):
255 user = keystone.users.find(name=user_name)
256 user.delete()
257
258 print(' - Deleted User %s' % user_name)
259 return True
260
ChetanGaonker71fe0302016-12-19 17:45:44 -0800261 def set_environment(tenants_num=0, networks_per_tenant=1, vms_per_network=2):
262 octet = 115
263 vm_inc = 11
264 image = nova_connection.images.get(IMAGE_ID)
265 flavor = nova_connection.flavors.get(FLAVOR_ID)
266
267 admin_user_id = keystone_connection.users.find(name=OS_USERNAME).id
268 member_role_id = keystone_connection.roles.find(name='Member').id
269 for num_tenant in range(1, tenants_num+1):
270 tenant = keystone_connection.tenants.create('%stenant%s' % (TENANT_PREFIX, num_tenant))
271 keystone_connection.roles.add_user_role(admin_user_id, member_role_id, tenant=tenant.id)
272 for num_network in range(networks_per_tenant):
273 network_json = {'name': '%snet%s' % (NETWORK_PREFIX, num_tenant*10+num_network),
274 'admin_state_up': True,
275 'tenant_id': tenant.id}
276 network = neutron_connection.create_network({'network': network_json})
277 subnet_json = {'name': '%ssubnet%s' % (NETWORK_PREFIX, num_tenant*10+num_network),
278 'network_id': network['network']['id'],
279 'tenant_id': tenant.id,
280 'enable_dhcp': True,
281 'cidr': '%s.%s.0/24' % (CIDR_PREFIX, octet), 'ip_version': 4}
282 octet += 1
283 subnet = neutron_connection.create_subnet({'subnet': subnet_json})
284 router_json = {'name': '%srouter%s' % (NETWORK_PREFIX, num_tenant*10+num_network),
285 'tenant_id': tenant.id}
286 router = neutron_connection.router_create({'router': router_json})
287 port = neutron_connection.add_interface_router(router['router']['id'], {'subnet_id': subnet['subnet']['id']})
288 for num_vm in range(vms_per_network):
289 tenant_nova_connection = novacli.Client(OS_USERNAME, OS_PASSWORD, tenant.name, OS_AUTH_URL)
290 m = tenant_nova_connection.servers.create('%svm%s' % (VM_PREFIX, vm_inc), image, flavor, nics=[{'net-id': network['network']['id']}, {'net-id': MGMT_NET}])
291 vm_inc += 1
292
293 @classmethod
294 def get_id(tenant_id, name):
295 cmd = "neutron %s-list --tenant-id=%s"%(objname,sdn_tenant_id)
296 output = os.system(cmd)
297 lis = output.split("\n")
298 for i in lis:
299 tokens = i.split()
Chetan Gaonker29e49842017-01-09 22:55:04 +0000300 if len(tokens)>3 and tokens[3] == name:
ChetanGaonker71fe0302016-12-19 17:45:44 -0800301 return tokens[1]
302 return none
303
304 @classmethod
305 def nova_boot(tenant_id, name, netid=None, portid=None):
306 if netid:
Chetan Gaonker29e49842017-01-09 22:55:04 +0000307 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 -0800308 if portid:
309 cmd = "nova --os-tenant-is %s boot --flavor 1 --image %s --nic port-id=%s %s"%(tenant_id,vm_image_id,portid,name)
310 os.system(cmd)
311
312 @classmethod
313 def port_create(sdn_tenant_id,name, net, fixedip, subnetid):
314 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)
315 os.system(cmd)
316 time.sleep(1)
317
318 @classmethod
319 def nova_wait_boot(sdn_tenant_id,name, state, retries=10):
320 global errno
321 cmd = "nova --os-tenant-id %s list" %(sdn_tenant_id)
322 for i in range(retries):
323 out = os.system(cmd)
324 lis = out.split("\n")
325 for line in lis:
326 toks = line.split()
327 if len(toks) >= 5 and toks[3] == name and toks[5] == state:
328 return
329 time.sleep(5)
Chetan Gaonker29e49842017-01-09 22:55:04 +0000330 errno=1
ChetanGaonker71fe0302016-12-19 17:45:44 -0800331
332 @classmethod
333 def port_delete(sdn_tenant_id,name):
334 cmd = "neutron port-delete %s" %(name)
335 os.system(cmd)
336 time.sleep(1)
337
338 @classmethod
339 def tenant_delete(name):
340 cmd = "keystone tenant-delete %s"%(name)
341 os.system(cmd)
342 time.sleep(1)
343
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800344 @classmethod
345 def verify_neutron_crud():
346 x = os.system("neutron_test.sh")
347 return x
ChetanGaonker901727c2016-11-29 14:05:03 -0800348
Author Name91eaeba2017-01-05 13:41:45 -0800349 def list_floatingips( **kwargs):
350 creds = get_neutron_credentials()
351 neutron = client.Client(**creds)
352 return neutron.list_floatingips(**kwargs)['floatingips']
353
354 def list_security_groups( **kwargs):
355 creds = get_neutron_credentials()
356 neutron = client.Client(**creds)
357 return neutron.list_security_groups(**kwargs)['security_groups']
358
359 def list_subnets( **kwargs):
360 creds = get_neutron_credentials()
361 neutron = client.Client(**creds)
362 return neutron.list_subnets(**kwargs)['subnets']
363
364 def list_networks( **kwargs):
365 creds = get_neutron_credentials()
366 neutron = client.Client(**creds)
367 return neutron.list_networks(**kwargs)['networks']
368
369 def list_ports( **kwargs):
370 creds = get_neutron_credentials()
371 neutron = client.Client(**creds)
372 return neutron.list_ports(**kwargs)['ports']
373
374 def list_routers( **kwargs):
375 creds = get_neutron_credentials()
376 neutron = client.Client(**creds)
377 return neutron.list_routers(**kwargs)['routers']
378
379 def update_floatingip( fip, port_id=None):
380 creds = get_neutron_credentials()
381 neutron = client.Client(**creds)
382 neutron.update_floatingip(fip, {"floatingip":
383 {"port_id": port_id}})
384
385 def update_subnet( subnet_id, **subnet_params):
386 creds = get_neutron_credentials()
387 neutron = client.Client(**creds)
388 neutron.update_subnet(subnet_id, {'subnet': subnet_params})
389
390 def update_router( router_id, **router_params):
391 creds = get_neutron_credentials()
392 neutron = client.Client(**creds)
393 neutron.update_router(router_id, {'router': router_params})
394
395 def router_gateway_set( router_id, external_gateway):
396 creds = get_neutron_credentials()
397 neutron = client.Client(**creds)
398 neutron.update_router(
399 router_id, {'router': {'external_gateway_info':
400 {'network_id': external_gateway}}})
401
402 def router_gateway_clear( router_id):
403 creds = get_neutron_credentials()
404 neutron = client.Client(**creds)
405 neutron.update_router(
406 router_id, {'router': {'external_gateway_info': None}})
407
408 def router_add_interface( router_id, subnet_id):
409 creds = get_neutron_credentials()
410 neutron = client.Client(**creds)
411 neutron.add_interface_router(router_id, {'subnet_id': subnet_id})
412
413 def router_rem_interface( router_id, subnet_id):
414 creds = get_neutron_credentials()
415 neutron = client.Client(**creds)
416 neutron.remove_interface_router(
417 router_id, {'subnet_id': subnet_id})
418
419 def create_floatingip( **floatingip_params):
420 creds = get_neutron_credentials()
421 neutron = client.Client(**creds)
422 response = neutron.create_floatingip(
423 {'floatingip': floatingip_params})
424 if 'floatingip' in response and 'id' in response['floatingip']:
425 return response['floatingip']['id']
426
Chetan Gaonker1f422af2017-01-13 21:59:16 +0000427 def make_iperf_pair(server, client, **kwargs):
428 ssh = SSHClient()
429 ssh.set_missing_host_key_policy(MissingHostKeyPolicy())
430
431 ssh.connect(server, username=VM_USERNAME, password=VM_PASSWORD)
432 ssh.exec_command('/usr/local/bin/iperf3 -s -D')
433
434 ssh.connect(client, username=VM_USERNAME, password=VM_PASSWORD)
435 stdin, stdout, stderr = ssh.exec_command('/usr/local/bin/iperf3 -c %s -J' % server)
436
437 rawdata = stdout.read()
438 data = json.loads(rawdata.translate(None,'\t').translate(None,'\n'))
439
440 return data
441
442 def waitVmActive(nova, vm):
443 sleep_time = 3
444 count = VM_BOOT_TIMEOUT / sleep_time
445 while True:
446 status = openstack_utils.get_instance_status(nova, vm)
447 logger.debug("Status: %s" % status)
448 if status == "ACTIVE":
449 return True
450 if status == "ERROR" or status == "error":
451 return False
452 if count == 0:
453 logger.debug("Booting a VM timed out...")
454 return False
455 count -= 1
456 time.sleep(sleep_time)
457 return False
458
459 def waitVmDeleted(nova, vm):
460 sleep_time = 3
461 count = VM_DELETE_TIMEOUT / sleep_time
462 while True:
463 status = openstack_utils.get_instance_status(nova, vm)
464 if not status:
465 return True
466 elif count == 0:
467 logger.debug("Timeout")
468 return False
469 else:
470 count -= 1
471 time.sleep(sleep_time)
472 return False
ChetanGaonker901727c2016-11-29 14:05:03 -0800473
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800474 def test_cordvtn_config_on_restart(self):
475 pass
ChetanGaonker901727c2016-11-29 14:05:03 -0800476
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800477 def test_cordvtn_arp_proxy(self):
478 pass
479
480 def test_cordvtn_gateway(self):
481 pass
482
483 def test_cordvtn_openstack_access(self):
484 pass
485
486 def test_cordvtn_xos_access(self):
487 pass
488
489 def test_cordvtn_ssh_access(self):
490 pass
491
492 def test_cordvtn_ovsdbport(self):
493 pass
494
495 def test_cordvtn_local_management_ip(self):
496 pass
497
498 def test_cordvtn_compute_nodes(self):
499 pass
500
501 def test_cordvtn_basic_tenant(self):
502 onos_load_config()
503 status = verify_neutron_crud()
ChetanGaonker71fe0302016-12-19 17:45:44 -0800504
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800505 if status != 0:
506 print "Issues with Neutron working state"
507 assert_equal(status, True)
508
ChetanGaonker71fe0302016-12-19 17:45:44 -0800509 tenant_1= create_tenant("CORD_Subscriber_Test_Tenant_1")
510 if ten1 != 0:
511 print "Creation of CORD Subscriber Test Tenant 1"
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800512
ChetanGaonker71fe0302016-12-19 17:45:44 -0800513 tenant_2 = create_tenant("CORD_Subscriber_Test_Tenant_2")
514 if ten2 != 0:
515 print "Creation of CORD Subscriber Test Tenant 2"
516
517 create_net(tenant_1,"a1")
518 create_subnet(tenant_1,"a1","as1","10.0.1.0/24")
519
520 create_net(tenant_2,"a2")
521 create_subnet(tenant_2,"a2","as1","10.0.2.0/24")
522
523 netid_1 = get_id(tenant_1,"net","a1")
524 netid_2 = get_id(tenant_2,"net","a2")
525
526 nova_boot(tenant_1,"vm1",netid=netid)
527 nova_boot(tenant_2,"vm1",netid=netid)
528
529 nova_wait_boot(tenant_1,"vm1", "ACTIVE")
530 nova_wait_boot(tenant_2,"vm1", "ACTIVE")
531
532 router_create(tenant_1,"r1")
533 router_interface_add(tenant_1,"r1","as1")
534 router_create(tenant_2,"r1")
535 router_interface_add(tenant_2,"r1","as1")
536
537 create_net(tenant_1,"x1","","--router:external=True")
538 create_net(tenant_2,"x1","","--router:external=True")
539
540 router_gateway_set(tenant_1,"r1","x1")
541 router_gateway_set(tenant_2,"r1","x1")
542
543 subnetid_1 = get_id(tenant_1,"subnet","as1")
544 subnetid_2 = get_id(tenant_2,"subnet","as1")
545 port_create(tenant_1,"p1","a1","10.0.1.100",subnetid_1)
546 port_create(tenant_2,"p1","a1","10.0.1.100",subnetid_2)
547
548 port_id_1 = get_id(tenant_1,"port","p1")
549 port_id_2 = get_id(tenant_2,"port","p1")
550
551 port_delete(tenant_1,"p1")
552 port_delete(tenant_2,"p1")
553
554 router_gateway_clear(tenant_1,"r1")
555 router_gateway_clear(tenant_2,"r1")
556
557 router_interface_delete(tenant_1,"r1","as1")
558 router_interface_delete(tenant_2,"r1","as1")
559
560 router_delete(tenant_1,"r1")
561 router_delete(tenant_2,"r1")
562
563 nova_delete(tenant_1,"vm1")
564 nova_delete(tenant_2,"vm1")
565
566 delete_subnet(tenant_1,"as1")
567 delete_subnet(tenant_1,"as1")
568
569 delete_net(tenant_1,"x1")
570 delete_net(tenant_2,"x1")
571
572 tenant_delete("CORD_Subscriber_Test_Tenant_1")
573 tenant_delete("CORD_Subscriber_Test_Tenant_2")
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800574 assert_equal(ret1, ret2)
ChetanGaonker901727c2016-11-29 14:05:03 -0800575
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800576 def test_cordvtn_for_create_network(self):
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800577 onos_load_config()
578 status = verify_neutron_crud()
579 if status != 0:
580 print "Issues with Neutron working state"
581
582 ret1 = create_tenant(netA)
583 if ret1 != 0:
584 print "Creation of Tenant netA Failed"
585
586 ret2 = create_tenant(netB)
587 if ret2 != 0:
588 print "Creation of Tenant netB Failed"
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800589 network = {'name': self.network_name, 'admin_state_up': True}
590 self.neutron.create_network({'network':network})
591 log.info("Created network:{0}".format(self.network_name))
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800592 assert_equal(ret1, ret2)
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800593
594 def test_cordvtn_to_create_net_work_with_subnet(self):
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800595 onos_load_config()
596 status = verify_neutron_crud()
597 if status != 0:
598 print "Issues with Neutron working state"
599
600 ret1 = create_tenant(netA)
601 if ret1 != 0:
602 print "Creation of Tenant netA Failed"
603
604 ret2 = create_tenant(netB)
605 if ret2 != 0:
606 print "Creation of Tenant netB Failed"
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800607 network_name = self.network_name
608 network = {'name': network_name, 'admin_state_up': True}
609 network_info = self.neutron.create_network({'network':network})
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800610 network_id = network_info['network']['id']
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800611
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800612 log.info("Created network:{0}".format(network_id))
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800613 self.network_ids.append(network_id)
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800614 subnet_count = 1
615 for cidr in self.subnet_cidrs:
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800616 gateway_ip = str(list(cidr)[1])
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800617 subnet = {"network_id": network_id, "ip_version":4,
618 "cidr":str(cidr), "enable_dhcp":True,
619 "host_routes":[{"destination":"0.0.0.0/0", "nexthop":gateway_ip}]
620 }
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800621 subnet = {"name":"subnet-"+str(subnet_count), "network_id": network_id, "ip_version":4, "cidr":str(cidr), "enable_dhcp":True}
622 print subnet
623 self.neutron.create_subnet({'subnet':subnet})
624 log.info("Created subnet:{0}".format(str(cidr)))
625 if not self.number_of_subnet - 1:
626 break
627 self.number_of_subnet -= 1
628 subnet_count += 1
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800629 assert_equal(ret1, ret2)
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800630
631 def test_cordvtn_subnet_limit(self):
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800632 onos_load_config()
633 status = verify_neutron_crud()
634 if status != 0:
635 print "Issues with Neutron working state"
636
637 ret1 = create_tenant(netA)
638 if ret1 != 0:
639 print "Creation of Tenant netA Failed"
640
641 ret2 = create_tenant(netB)
642 if ret2 != 0:
643 print "Creation of Tenant netB Failed"
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800644 network_name = uuid.uuid4().get_hex()
645 network = {'name': network_name, 'admin_state_up': True}
646 network_info = self.neutron.create_network({'network':network})
647 log.info("Created network:{0}".format(network_name))
648 network_id = network_info['network']['id']
649 self.network_ids.append(network_id)
650 subnet_cidrs = ['11.2.2.0/29', '11.2.2.8/29']
651 for cidr in subnet_cidrs:
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800652 subnet = {"network_id": network_id, "ip_version":4, "cidr": cidr}
653 subnet_info = self.neutron.create_subnet({'subnet':subnet})
654 subnet_id = subnet_info['subnet']['id']
655 log.info("Created subnet:{0}".format(cidr))
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800656 while True:
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800657 port = {"network_id": network_id, "admin_state_up": True}
658 port_info = self.neutron.create_port({'port':port})
659 port_id = port_info['port']['id']
660 self.port_ids.append(port_id)
661 log.info("Created Port:{0}".format(port_info['port']['id']))
662 if not self.quota_limit:
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800663 break
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800664 self.quota_limit -= 1
665 assert_equal(ret1, ret2)
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800666
667 def test_cordvtn_floatingip_limit(self):
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800668 onos_load_config()
669 status = verify_neutron_crud()
670 if status != 0:
671 print "Issues with Neutron working state"
ChetanGaonkerd65b7612016-12-07 01:01:20 -0800672
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800673 ret1 = create_tenant(netA)
674 if ret1 != 0:
675 print "Creation of Tenant netA Failed"
676
677 ret2 = create_tenant(netB)
678 if ret2 != 0:
679 print "Creation of Tenant netB Failed"
680 while True:
681 floatingip = {"floating_network_id": self.floating_nw_id}
682 fip_info = self.neutron.create_floatingip({'floatingip':floatingip})
683 fip_id = fip_info['floatingip']['id']
684 log.info("Created Floating IP:{0}".format(fip_id))
685 self.fip_ids.append(fip_id)
686 if not self.quota_limit:
687 break
688 self.quota_limit -= 1
689 assert_equal(ret1, ret2)
690
691 def test_cordvtn_10_neutron_networks(self):
692 onos_load_config()
693 status = verify_neutron_crud()
694 if status != 0:
695 print "Issues with Neutron working state"
696
697 ret1 = create_tenant(netA)
698 if ret1 != 0:
699 print "Creation of Tenant netA Failed"
700
701 ret2 = create_tenant(netB)
702 if ret2 != 0:
703 print "Creation of Tenant netB Failed"
704 pool = Pool(processes=10)
705 ret = os.system("neutron quote-update --network 15")
706 if ret1 != 0:
707 print "Neutron network install failed"
708 for i in range(1, 11):
709 pool.apply_asynch(create_network, (i, ))
710
711 pool.close()
712 pool.join()
713 assert_equal(ret1, ret2)
714
715 def test_cordvtn_100_neutron_networks(self):
716 onos_load_config()
717 status = verify_neutron_crud()
718 if status != 0:
719 print "Issues with Neutron working state"
720
721 ret1 = create_tenant(netA)
722 if ret1 != 0:
723 print "Creation of Tenant netA Failed"
724
725 ret2 = create_tenant(netB)
726 if ret2 != 0:
727 print "Creation of Tenant netB Failed"
728 pool = Pool(processes=10)
729
730 ret = os.system("neutron quote-update --network 105")
731 if ret1 != 0:
732 print "Neutron network install failed"
733 for i in range(1, 101):
734 pool.apply_asynch(create_network, (i, ))
735
736 pool.close()
737 pool.join()
738 assert_equal(ret1, ret2)
739
740 def test_cordvtn_service_dependency_for_two_subnets(self):
741 pass
742
743 def test_cordvtn_service_dependency_for_three_subnets(self):
744 pass
745
746 def test_cordvtn_service_dependency_for_four_subnets(self):
747 pass
748
749 def test_cordvtn_service_dependency_for_five_subnets(self):
750 pass
751
752 def test_cordvtn_for_biderectional_connections(self):
753 pass
754
755 def test_cordvtn_authentication_from_openstack(self):
756 pass
757
758 def test_cordvtn_with_gateway(self):
759 pass
760
761 def test_cordvtn_without_gateway(self):
762 pass
763
764 def test_cordvtn_for_service_instance(self):
765 pass
766
767 def test_cordvtn_for_instance_to_network(self):
768 pass
769
770 def test_cordvtn_for_network_to_instance(self):
771 pass
772
773 def test_cordvtn_for_instance_to_instance(self):
774 pass
775
776 def test_cordvtn_for_network_to_network(self):
777 pass
778
779 def test_cordvtn_without_neutron_ml2_plugin(self):
780 pass
781
782 def test_cordvtn_with_neutron_ml2_plugin(self):
783 pass
784
785 def test_cordvtn_service_network_type_private(self):
786 pass
787
788 def test_cordvtn_service_network_type_management_local(self):
789 pass
790
791 def test_cordvtn_service_network_type_management_host(self):
792 pass
793
794 def test_cordvtn_service_network_type_vsg(self):
795 pass
796
797 def test_cordvtn_service_network_type_access_agent(self):
ChetanGaonker901727c2016-11-29 14:05:03 -0800798 pass
799
800 def test_cordvtn_mgmt_network(self):
801 pass
802
803 def test_cordvtn_data_network(self):
804 pass
805
806 def test_cordvtn_public_network(self):
807 pass
808
809 def test_cordvtn_in_same_network(self):
810 pass
811
812 def test_cordvtn_local_mgmt_network(self):
813 pass
814
815 def test_cordvtn_service_dependency(self):
816 pass
817
818 def test_cordvtn_service_dependency_with_xos(self):
819 pass
820
821 def test_cordvtn_vsg_xos_service_profile(self):
822 pass
823
824 def test_cordvtn_access_agent(self):
825 pass
826
827 def test_cordvtn_network_creation(self):
828 pass
829
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800830 def test_cordvtn_network_deletion(self):
831 pass
832
ChetanGaonker901727c2016-11-29 14:05:03 -0800833 def test_cordvtn_removing_service_network(self):
834 pass
835
836 def test_cordvtn_web_application(self):
837 pass
838
839 def test_cordvtn_service_port(self):
840 pass
ChetanGaonkeraaea6b62016-12-16 17:06:39 -0800841
842 def test_cordvtn_inetgration_bridge(self):
843 pass
844