From: tierno Date: Mon, 7 Oct 2019 16:38:23 +0000 (+0000) Subject: Merge branch 'master' into Azure X-Git-Tag: v7.0.0rc1~15^2~2 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FRO.git;a=commitdiff_plain;h=1fa49b16e92ff2e4f512ccc466fdc3dff31559e4;hp=-c Merge branch 'master' into Azure Change-Id: Ia9726dfe53813157c1e3002a44f041861722d424 Signed-off-by: tierno --- 1fa49b16e92ff2e4f512ccc466fdc3dff31559e4 diff --combined test/test_RO.py index be711c86,932853c5..014030b0 --- a/test/test_RO.py +++ b/test/test_RO.py @@@ -20,15 -20,6 +20,15 @@@ # ## +# DEBUG WITH PDB - import os - if os.getenv('OSMRO_PDB_DEBUG'): ++from os import getenv ++if getenv('OSMRO_PDB_DEBUG'): + import sys + print(sys.path) + import pdb + pdb.set_trace() + + """ Module for testing openmano functionality. It uses openmanoclient.py for invoking openmano """ @@@ -300,7 -291,7 +300,7 @@@ class test_vimconn_connect(test_base) vca_object = test_config["vim_conn"].connect() logger.debug("{}".format(vca_object)) self.assertIsNotNone(vca_object) - elif test_config['vimtype'] == 'openstack': + elif test_config['vimtype'] in ('openstack', 'azure'): test_config["vim_conn"]._reload_connection() network_list = test_config["vim_conn"].get_network_list() logger.debug("{}".format(network_list)) @@@ -499,7 -490,7 +499,7 @@@ class test_vimconn_new_network(test_bas # refresh net status net_dict = test_config["vim_conn"].refresh_nets_status([unknown_net_id]) - if test_config['vimtype'] == 'openstack': + if test_config['vimtype'] in ('openstack', 'azure'): self.assertEqual(net_dict[unknown_net_id]['status'], 'DELETED') else: # TODO : Fix vmware connector to return status DELETED as per vimconn.py @@@ -539,8 -530,7 +539,8 @@@ class test_vimconn_get_network_list(tes self.assertIn(self.__class__.network_name, net.get('name')) self.assertEqual(net.get('type'), self.__class__.net_type) self.assertEqual(net.get('status'), 'ACTIVE') - self.assertEqual(net.get('shared'), False) + if test_config['vimtype'] != 'azure': + self.assertEqual(net.get('shared'), False) def test_010_get_network_list_by_name(self): self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], @@@ -548,7 -538,7 +548,7 @@@ inspect.currentframe().f_code.co_name) self.__class__.test_index += 1 - if test_config['vimtype'] == 'openstack': + if test_config['vimtype'] in ('openstack', 'azure'): network_name = test_config['vim_conn'].get_network(self.__class__.network_id)['name'] else: network_name = test_config['vim_conn'].get_network_name_by_id(self.__class__.network_id) @@@ -582,7 -572,7 +582,7 @@@ inspect.currentframe().f_code.co_name) self.__class__.test_index += 1 - if test_config['vimtype'] == 'openstack': + if test_config['vimtype'] in ('openstack', 'azure'): network_name = test_config['vim_conn'].get_network(self.__class__.network_id)['name'] else: network_name = test_config['vim_conn'].get_network_name_by_id(self.__class__.network_id) @@@ -602,7 -592,7 +602,7 @@@ self.__class__.test_index += 1 tenant_list = test_config["vim_conn"].get_tenant_list() - if test_config['vimtype'] == 'openstack': + if test_config['vimtype'] in ('openstack', 'azure'): network_name = test_config['vim_conn'].get_network(self.__class__.network_id)['name'] else: network_name = test_config['vim_conn'].get_network_name_by_id(self.__class__.network_id) @@@ -626,7 -616,7 +626,7 @@@ self.__class__.test_index += 1 status = 'ACTIVE' - if test_config['vimtype'] == 'openstack': + if test_config['vimtype'] in ('openstack', 'azure'): network_name = test_config['vim_conn'].get_network(self.__class__.network_id)['name'] else: network_name = test_config['vim_conn'].get_network_name_by_id(self.__class__.network_id) @@@ -770,23 -760,16 +770,16 @@@ class test_vimconn_get_flavor(test_base flavor_id = test_config["vim_conn"].new_flavor(flavor_data) # get flavor by id result = test_config["vim_conn"].get_flavor(flavor_id) - - if test_config['vimtype'] != 'azure': - self.assertEqual(ram, result['ram']) - self.assertEqual(vcpus, result['vcpus']) - self.assertEqual(disk, result['disk']) - else: - self.assertTrue(ram <= result['ram']) - self.assertTrue(vcpus <= result['vcpus']) - self.assertTrue(disk <= result['disk']) + self.assertEqual(ram, result['ram']) + self.assertEqual(vcpus, result['vcpus']) + self.assertEqual(disk, result['disk']) # delete flavor - if test_config['vimtype'] != 'azure': - result = test_config["vim_conn"].delete_flavor(flavor_id) - if result: - logger.info("Flavor id {} sucessfully deleted".format(result)) - else: - logger.info("Failed to delete flavor id {}".format(result)) + result = test_config["vim_conn"].delete_flavor(flavor_id) + if result: + logger.info("Flavor id {} sucessfully deleted".format(result)) + else: + logger.info("Failed to delete flavor id {}".format(result)) def test_010_get_flavor_negative(self): Non_exist_flavor_id = str(uuid.uuid4()) @@@ -805,7 -788,7 +798,7 @@@ class test_vimconn_new_flavor(test_base flavor_id = None def test_000_new_flavor(self): - flavor_data = {'name': _get_random_string(20), 'ram': 1024, 'vpcus': 1, 'disk': 10} + flavor_data = {'name': _get_random_string(20), 'ram': 1024, 'vcpus': 1, 'disk': 10} self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], self.__class__.test_index, @@@ -824,18 -807,12 +817,18 @@@ self.__class__.test_index += 1 # delete flavor - result = test_config["vim_conn"].delete_flavor(self.__class__.flavor_id) - if result: - logger.info("Flavor id {} sucessfully deleted".format(result)) + if test_config['vimtype'] == 'azure': + with self.assertRaises(Exception) as context: + test_config["vim_conn"].delete_flavor(self.__class__.flavor_id) + + self.assertEqual((context.exception).http_code, 401) else: - logger.error("Failed to delete flavor id {}".format(result)) - raise Exception ("Failed to delete created flavor") + result = test_config["vim_conn"].delete_flavor(self.__class__.flavor_id) + if result: + logger.info("Flavor id {} sucessfully deleted".format(result)) + else: + logger.error("Failed to delete flavor id {}".format(result)) + raise Exception ("Failed to delete created flavor") def test_020_new_flavor_negative(self): Invalid_flavor_data = {'ram': '1024', 'vcpus': 2.0, 'disk': 2.0} @@@ -848,10 -825,7 +841,7 @@@ with self.assertRaises(Exception) as context: test_config["vim_conn"].new_flavor(Invalid_flavor_data) - if test_config['vimtype'] == 'azure': - self.assertEqual((context.exception).http_code, 404) - else: - self.assertEqual((context.exception).http_code, 400) + self.assertEqual((context.exception).http_code, 400) def test_030_delete_flavor_negative(self): Non_exist_flavor_id = str(uuid.uuid4()) @@@ -864,93 -838,89 +854,89 @@@ with self.assertRaises(Exception) as context: test_config["vim_conn"].delete_flavor(Non_exist_flavor_id) - if test_config['vimtype'] == 'azure': - self.assertEqual((context.exception).http_code, 401) - else: - self.assertEqual((context.exception).http_code, 404) - - class test_vimconn_new_image(test_base): - - def test_000_new_image(self): - self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], - self.__class__.test_index, - inspect.currentframe().f_code.co_name) - self.__class__.test_index += 1 - - image_path = test_config['image_path'] - if image_path: - self.__class__.image_id = test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : image_path, - 'metadata': {'upload_location':None} }) - time.sleep(20) - - self.assertIsInstance(self.__class__.image_id, (str, unicode)) - self.assertIsInstance(uuid.UUID(self.__class__.image_id), uuid.UUID) - else: - self.skipTest("Skipping test as image file not present at RO container") - - def test_010_new_image_negative(self): - Non_exist_image_path = '/temp1/cirros.ovf' - - self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], - self.__class__.test_index, - inspect.currentframe().f_code.co_name) - self.__class__.test_index += 1 - - with self.assertRaises(Exception) as context: - test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : Non_exist_image_path}) - - self.assertEqual((context.exception).http_code, 400) - - def test_020_delete_image(self): - self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], - self.__class__.test_index, - inspect.currentframe().f_code.co_name) - self.__class__.test_index += 1 - - image_id = test_config["vim_conn"].delete_image(self.__class__.image_id) - - self.assertIsInstance(image_id, (str, unicode)) - - def test_030_delete_image_negative(self): - Non_exist_image_id = str(uuid.uuid4()) - - self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], - self.__class__.test_index, - inspect.currentframe().f_code.co_name) - self.__class__.test_index += 1 - - with self.assertRaises(Exception) as context: - test_config["vim_conn"].delete_image(Non_exist_image_id) - self.assertEqual((context.exception).http_code, 404) - class test_vimconn_get_image_id_from_path(test_base): - - def test_000_get_image_id_from_path(self): - self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], - self.__class__.test_index, - inspect.currentframe().f_code.co_name) - self.__class__.test_index += 1 - - image_path = test_config['image_path'] - if image_path: - image_id = test_config["vim_conn"].get_image_id_from_path( image_path ) - self.assertEqual(type(image_id),str) - else: - self.skipTest("Skipping test as image file not present at RO container") - - def test_010_get_image_id_from_path_negative(self): - Non_exist_image_path = '/temp1/cirros.ovf' - - self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], - self.__class__.test_index, - inspect.currentframe().f_code.co_name) - self.__class__.test_index += 1 - - with self.assertRaises(Exception) as context: - test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : Non_exist_image_path }) + # class test_vimconn_new_image(test_base): + # + # def test_000_new_image(self): + # self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], + # self.__class__.test_index, + # inspect.currentframe().f_code.co_name) + # self.__class__.test_index += 1 + # + # image_path = test_config['image_path'] + # if image_path: + # self.__class__.image_id = test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : image_path, 'metadata': {'upload_location':None} }) + # time.sleep(20) + # + # self.assertIsInstance(self.__class__.image_id, (str, unicode)) + # self.assertIsInstance(uuid.UUID(self.__class__.image_id), uuid.UUID) + # else: + # self.skipTest("Skipping test as image file not present at RO container") + # + # def test_010_new_image_negative(self): + # Non_exist_image_path = '/temp1/cirros.ovf' + # + # self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], + # self.__class__.test_index, + # inspect.currentframe().f_code.co_name) + # self.__class__.test_index += 1 + # + # with self.assertRaises(Exception) as context: + # test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : Non_exist_image_path}) + # + # self.assertEqual((context.exception).http_code, 400) + # + # def test_020_delete_image(self): + # self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], + # self.__class__.test_index, + # inspect.currentframe().f_code.co_name) + # self.__class__.test_index += 1 + # + # image_id = test_config["vim_conn"].delete_image(self.__class__.image_id) + # + # self.assertIsInstance(image_id, (str, unicode)) + # + # def test_030_delete_image_negative(self): + # Non_exist_image_id = str(uuid.uuid4()) + # + # self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], + # self.__class__.test_index, + # inspect.currentframe().f_code.co_name) + # self.__class__.test_index += 1 + # + # with self.assertRaises(Exception) as context: + # test_config["vim_conn"].delete_image(Non_exist_image_id) + # + # self.assertEqual((context.exception).http_code, 404) - self.assertEqual((context.exception).http_code, 400) + # class test_vimconn_get_image_id_from_path(test_base): + # + # def test_000_get_image_id_from_path(self): + # self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], + # self.__class__.test_index, + # inspect.currentframe().f_code.co_name) + # self.__class__.test_index += 1 + # + # image_path = test_config['image_path'] + # if image_path: + # image_id = test_config["vim_conn"].get_image_id_from_path( image_path ) + # self.assertEqual(type(image_id),str) + # else: + # self.skipTest("Skipping test as image file not present at RO container") + # + # def test_010_get_image_id_from_path_negative(self): + # Non_exist_image_path = '/temp1/cirros.ovf' + # + # self.__class__.test_text = "{}.{}. TEST {}".format(test_config["test_number"], + # self.__class__.test_index, + # inspect.currentframe().f_code.co_name) + # self.__class__.test_index += 1 + # + # with self.assertRaises(Exception) as context: + # test_config["vim_conn"].new_image({ 'name': 'TestImage', 'location' : Non_exist_image_path }) + # + # self.assertEqual((context.exception).http_code, 400) class test_vimconn_get_image_list(test_base): image_name = None @@@ -961,11 -931,7 +947,11 @@@ self.__class__.test_index, inspect.currentframe().f_code.co_name) self.__class__.test_index += 1 + - if test_config['image_name']: - image_list = test_config['vim_conn'].get_image_list({'name': test_config['image_name']}) - else: - image_list = test_config["vim_conn"].get_image_list() ++ # if test_config['image_name']: ++ # image_list = test_config['vim_conn'].get_image_list({'name': test_config['image_name']}) ++ # else: + image_list = test_config["vim_conn"].get_image_list() for item in image_list: if 'name' in item: @@@ -1065,13 -1031,9 +1051,13 @@@ class test_vimconn_new_vminstance(test_ inspect.currentframe().f_code.co_name) self.__class__.test_index += 1 - net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'vpci': vpci, 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] + net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'vpci': vpci, + 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] - self.__class__.instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, image_id=self.__class__.image_id, flavor_id=flavor_id, net_list=net_list) + self.__class__.instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', + start=False, + image_id=self.__class__.image_id, + flavor_id=flavor_id, net_list=net_list) self.assertIsInstance(self.__class__.instance_id, (str, unicode)) @@@ -1088,12 -1050,9 +1074,12 @@@ inspect.currentframe().f_code.co_name) self.__class__.test_index += 1 - net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'port_security': True, 'model': model_name, 'type': 'virtual', 'net_id': self.__class__.network_id}] + net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'port_security': True, + 'model': model_name, 'type': 'virtual', 'net_id': self.__class__.network_id}] - instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, image_id=self.__class__.image_id,flavor_id=flavor_id,net_list=net_list) + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, + image_id=self.__class__.image_id, + flavor_id=flavor_id,net_list=net_list) self.assertIsInstance(instance_id, (str, unicode)) @@@ -1115,12 -1074,11 +1101,12 @@@ inspect.currentframe().f_code.co_name) self.__class__.test_index += 1 - net_list = [{'use': net_use, 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] + net_list = [{'use': net_use, 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'virtual', + 'net_id': self.__class__.network_id}] - instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, image_id=self.__class__.image_id,disk_list=None, - flavor_id=flavor_id, - net_list=net_list) + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, + image_id=self.__class__.image_id,disk_list=None, + flavor_id=flavor_id, net_list=net_list) self.assertIsInstance(instance_id, (str, unicode)) # Deleting created vm instance @@@ -1150,7 -1108,7 +1136,7 @@@ net_list=net_list) self.assertEqual(type(instance_id),str) - if test_config['vimtype'] == 'openstack': + if test_config['vimtype'] in ('openstack', 'azure'): # create network of type data network_name = _get_random_string(20) net_type = 'data' @@@ -1161,9 -1119,9 +1147,9 @@@ 'type': _type, 'net_id': network_id}] instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, - image_id=self.__class__.image_id, disk_list=None, - flavor_id=flavor_id, - net_list=net_list) + image_id=self.__class__.image_id, disk_list=None, + flavor_id=flavor_id, + net_list=net_list) self.assertEqual(type(instance_id), unicode) @@@ -1184,12 -1142,11 +1170,12 @@@ name = 'eth0' user_name = 'test_user' - key_pairs = ['ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCy2w9GHMKKNkpCmrDK2ovc3XBYDETuLWwaW24S+feHhLBQiZlzh3gSQoINlA+2ycM9zYbxl4BGzEzpTVyCQFZv5PidG4m6ox7LR+KYkDcITMyjsVuQJKDvt6oZvRt6KbChcCi0n2JJD/oUiJbBFagDBlRslbaFI2mmqmhLlJ5TLDtmYxzBLpjuX4m4tv+pdmQVfg7DYHsoy0hllhjtcDlt1nn05WgWYRTu7mfQTWfVTavu+OjIX3e0WN6NW7yIBWZcE/Q9lC0II3W7PZDE3QaT55se4SPIO2JTdqsx6XGbekdG1n6adlduOI27sOU5m4doiyJ8554yVbuDB/z5lRBD alfonso.tiernosepulveda@telefonica.com'] + key_pairs = ['ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDtAjl5R+GSKP3gFrdFxgizKEUzhXKQbyjaxJH9thsK 0/fDiYlaNEjvijgPgiVZkfwvqgWeLprPcpzL2j4jvmmSJ3+7C8ihCwObWP0VUiuewmbIINBPAR0RqusjMRyPsa+q0asFBPOoZLx3Cv3vzmC1AA3mKuCNeT EuA0rlWhDIOVwMcU5sP1grnmuexQB8HcR7BdKcA9y08pTwnCQR8vmtW77SRkaxEGXm4Gnw5qw8Z27mHdk2wWS2SnbVH7aFwWvDXc6jjf5TpEWypdr/EAPC +eJipeS2Oa4FsntEqAu3Fz6gp/9ub8uNqgCgHfMzs6FhYpZpipwS0hXYyF6eVsSx osm@osm'] - users_data = [{'key-pairs': ['ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCy2w9GHMKKNkpCmrDK2ovc3XBYDETuLWwaW24S+feHhLBQiZlzh3gSQoINlA+2ycM9zYbxl4BGzEzpTVyCQFZv5PidG4m6ox7LR+KYkDcITMyjsVuQJKDvt6oZvRt6KbChcCi0n2JJD/oUiJbBFagDBlRslbaFI2mmqmhLlJ5TLDtmYxzBLpjuX4m4tv+pdmQVfg7DYHsoy0hllhjtcDlt1nn05WgWYRTu7mfQTWfVTavu+OjIX3e0WN6NW7yIBWZcE/Q9lC0II3W7PZDE3QaT55se4SPIO2JTdqsx6XGbekdG1n6adlduOI27sOU5m4doiyJ8554yVbuDB/z5lRBD alfonso.tiernosepulveda@telefonica.com'], 'name': user_name}] + users_data = [{'key-pairs': ['ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDtAjl5R+GSKP3gFrdFxgizKEUzhXKQbyjaxJH9thsK0/fDiYlaNEjvijgPgiVZkfwvqgWeLprPcpzL2j4jvmmSJ3+7C8ihCwObWP0VUiuewmbIINBPAR0RqusjMRyPsa+q0asFBPOoZLx3Cv3vzmC1AA3mKuCNeTEuA0rlWhDIOVwMcU5sP1grnmuexQB8HcR7BdKcA9y08pTwnCQR8vmtW77SRkaxEGXm4Gnw5qw8Z27mHdk2wWS2SnbVH7aFwWvDXc6jjf5TpEWypdr/EAPC+eJipeS2Oa4FsntEqAu3Fz6gp/9ub8uNqgCgHfMzs6FhYpZpipwS0hXYyF6eVsSx osm@osm'], 'name': 'cloudinit'}] cloud_data = {'config-files': [{'content': 'auto enp0s3\niface enp0s3 inet dhcp\n', 'dest': '/etc/network/interfaces.d/enp0s3.cfg', 'owner': 'root:root', 'permissions': '0644'}, {'content': '#! /bin/bash\nls -al >> /var/log/osm.log\n', 'dest': '/etc/rc.local', 'permissions': '0755'}, {'content': 'file content', 'dest': '/etc/test_delete'}], 'boot-data-drive': True, 'key-pairs': key_pairs, 'users': users_data } + #cloud_data = {'users': users_data } # create new flavor flavor_id = test_config["vim_conn"].new_flavor(flavor_data) @@@ -1199,13 -1156,10 +1185,13 @@@ inspect.currentframe().f_code.co_name) self.__class__.test_index += 1 - net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] + net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'port_security': True, + 'type': 'virtual', 'net_id': self.__class__.network_id}] instance_id, _ = test_config["vim_conn"].new_vminstance(name='Cloud_vm', description='', start=False, - image_id=self.__class__.image_id, flavor_id=flavor_id,net_list=net_list,cloud_config=cloud_data) + image_id=self.__class__.image_id, + flavor_id=flavor_id,net_list=net_list, + cloud_config=cloud_data) self.assertIsInstance(instance_id, (str, unicode)) @@@ -1228,13 -1182,12 +1214,13 @@@ inspect.currentframe().f_code.co_name) self.__class__.test_index += 1 - net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] + net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'port_security': True, + 'type': 'virtual', 'net_id': self.__class__.network_id}] - instance_id, _ = test_config["vim_conn"].new_vminstance(name='VM_test1', description='', start=False, image_id=self.__class__.image_id, - flavor_id=flavor_id, - net_list=net_list, - disk_list=device_data) + instance_id, _ = test_config["vim_conn"].new_vminstance(name='VM_test1', description='', start=False, + image_id=self.__class__.image_id, + flavor_id=flavor_id, net_list=net_list, + disk_list=device_data) self.assertIsInstance(instance_id, (str, unicode)) # Deleting created vm instance @@@ -1252,14 -1205,12 +1238,14 @@@ inspect.currentframe().f_code.co_name) self.__class__.test_index += 1 - net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] + net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'port_security': True, + 'type': 'virtual', 'net_id': self.__class__.network_id}] with self.assertRaises(Exception) as context: - test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, image_id=unknown_image_id, - flavor_id=unknown_flavor_id, - net_list=net_list) + test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, + image_id=unknown_image_id, + flavor_id=unknown_flavor_id, + net_list=net_list) self.assertIn((context.exception).http_code, (400, 404)) @@@ -1316,7 -1267,7 +1302,7 @@@ if attr == 'interfaces': self.assertEqual(type(vm_info[self.__class__.instance_id][attr]), list) - if test_config['vimtype'] == 'openstack': + if test_config['vimtype'] in ('openstack', 'azure'): vpci = "0000:00:11.0" name = "eth0" @@@ -1325,12 -1276,9 +1311,12 @@@ # create new flavor flavor_id = test_config["vim_conn"].new_flavor(flavor_data) # create new vm instance - net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'vpci': vpci, 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] + net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'vpci': vpci, + 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] - instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, image_id=self.__class__.image_id, flavor_id=flavor_id, net_list=net_list) + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, + image_id=self.__class__.image_id, + flavor_id=flavor_id, net_list=net_list) time.sleep(30) vm_list = [] @@@ -1363,7 -1311,7 +1349,7 @@@ if test_config['vimtype'] == 'vmware': self.assertEqual(vm_dict,{}) - if test_config['vimtype'] == 'openstack': + if test_config['vimtype'] in ('openstack', 'azure'): self.assertEqual(vm_dict[unknown_id]['status'], 'DELETED') def test_110_action_vminstance(self): @@@ -1380,7 -1328,7 +1366,7 @@@ {action: None}) self.assertEqual(instance_id, self.__class__.instance_id) - if test_config['vimtype'] == 'openstack': + if test_config['vimtype'] in ('openstack', 'azure'): # create new vm instance vpci = "0000:00:11.0" name = "eth0" @@@ -1390,27 -1338,22 +1376,28 @@@ # create new flavor flavor_id = test_config["vim_conn"].new_flavor(flavor_data) - net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'vpci': vpci, 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] + net_list = [{'use': self.__class__.net_type, 'name': name, 'floating_ip': False, 'vpci': vpci, + 'port_security': True, 'type': 'virtual', 'net_id': self.__class__.network_id}] - new_instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, image_id=self.__class__.image_id, flavor_id=flavor_id, net_list=net_list) + new_instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', + start=False, image_id=self.__class__.image_id, + flavor_id=flavor_id, net_list=net_list) - action_list = ['shutdown','start','shutoff','rebuild','start','pause','start'] + if test_config['vimtype'] == 'openstack': + action_list = ['shutdown','start','shutoff','rebuild','start','pause','start'] + else: + action_list = ['shutdown','start','stop','start','shutoff','start','reboot'] # various action on vminstace for action in action_list: # sleep for sometime till status is changed time.sleep(25) - instance_id = test_config["vim_conn"].action_vminstance(new_instance_id, {action: None}) + instance_id = test_config["vim_conn"].action_vminstance(new_instance_id, + { action: None}) self.assertTrue(instance_id is None) - #Deleting created vm instance + # Deleting created vm instance logger.info("Deleting created vm intance") test_config["vim_conn"].delete_vminstance(new_instance_id) time.sleep(10) @@@ -1459,12 -1402,9 +1446,12 @@@ self.assertEqual(sriov_net_name, list_item.get('name')) self.__class__.sriov_network_id = list_item.get('id') - net_list = [{'use': 'data', 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'VF', 'net_id': self.__class__.sriov_network_id}] + net_list = [{'use': 'data', 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'VF', + 'net_id': self.__class__.sriov_network_id}] - instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_sriov_vm', description='', start=False, image_id=self.__class__.image_id, flavor_id=flavor_id, net_list=net_list) + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_sriov_vm', description='', start=False, + image_id=self.__class__.image_id, flavor_id=flavor_id, + net_list=net_list) self.assertIsInstance(instance_id, (str, unicode)) @@@ -1559,15 -1499,10 +1546,15 @@@ class test_vimconn_new_tenant(test_base inspect.currentframe().f_code.co_name) self.__class__.test_index += 1 - self.__class__.tenant_id = test_config["vim_conn"].new_tenant(tenant_name, "") - time.sleep(15) + if test_config['vimtype'] != 'azure': + self.__class__.tenant_id = test_config["vim_conn"].new_tenant(tenant_name, "") + time.sleep(15) - self.assertIsInstance(self.__class__.tenant_id, (str, unicode)) + self.assertIsInstance(self.__class__.tenant_id, (str, unicode)) + else: + with self.assertRaises(Exception) as context: + test_config["vim_conn"].new_tenant(self.__class__.tenant_id) + self.assertEqual((context.exception).http_code, 401) def test_010_new_tenant_negative(self): @@@ -1580,10 -1515,7 +1567,10 @@@ with self.assertRaises(Exception) as context: test_config["vim_conn"].new_tenant(Invalid_tenant_name, "") - self.assertEqual((context.exception).http_code, 400) + if test_config['vimtype'] != 'azure': + self.assertEqual((context.exception).http_code, 400) + else: + self.assertEqual((context.exception).http_code, 401) def test_020_delete_tenant(self): @@@ -1592,13 -1524,9 +1579,13 @@@ inspect.currentframe().f_code.co_name) self.__class__.test_index += 1 - tenant_id = test_config["vim_conn"].delete_tenant(self.__class__.tenant_id) - - self.assertIsInstance(tenant_id, (str, unicode)) + if test_config['vimtype'] != 'azure': + tenant_id = test_config["vim_conn"].delete_tenant(self.__class__.tenant_id) + self.assertIsInstance(tenant_id, (str, unicode)) + else: + with self.assertRaises(Exception) as context: + test_config["vim_conn"].delete_tenant(self.__class__.tenant_id) + self.assertEqual((context.exception).http_code, 401) def test_030_delete_tenant_negative(self): Non_exist_tenant_name = 'Test_30_tenant' @@@ -1610,10 -1538,7 +1597,7 @@@ with self.assertRaises(Exception) as context: test_config["vim_conn"].delete_tenant(Non_exist_tenant_name) - if test_config['vimtype'] != 'azure': - self.assertEqual((context.exception).http_code, 404) - else: - self.assertEqual((context.exception).http_code, 401) + self.assertEqual((context.exception).http_code, 404) def get_image_id(): @@@ -1811,8 -1736,8 +1795,8 @@@ class test_vimconn_vminstance_by_adding 'port_security': True, 'type': 'virtual', 'net_id': net_id}) c = c+1 - instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, - image_id=image_id, flavor_id=flavor_id, net_list=net_list) + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=image_id, + flavor_id=flavor_id, net_list=net_list) self.assertEqual(type(instance_id),str) logger.info("Deleting created vm instance") @@@ -1864,8 -1789,7 +1848,8 @@@ class test_vimconn_vminstance_by_existi net_list = [{'use': 'bridge', 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'virtual', 'net_id': self.network_id}] - instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=image_id, + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, + image_id=image_id, flavor_id=flavor_id, net_list=net_list,disk_list=disk_list) self.assertEqual(type(instance_id),str) @@@ -1892,8 -1816,7 +1876,8 @@@ net_list = [{'use': 'bridge', 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'virtual', 'net_id': self.network_id}] - instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=image_id, + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, + image_id=image_id, flavor_id=flavor_id, net_list=net_list,disk_list=disk_list) self.assertEqual(type(instance_id),str) @@@ -1924,8 -1847,7 +1908,8 @@@ net_list = [{'use': 'bridge', 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'virtual', 'net_id': self.network_id}] - instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=image_id, + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, + image_id=image_id, flavor_id=flavor_id, net_list=net_list,disk_list=disk_list ) self.assertEqual(type(instance_id),str) @@@ -1975,8 -1897,7 +1959,8 @@@ class test_vimconn_vminstance_by_affini net_list = [{'use': 'bridge', 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'virtual', 'net_id': self.network_id}] - instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=image_id, + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, + image_id=image_id, flavor_id=flavor_id, net_list=net_list,availability_zone_index=1, availability_zone_list=['HG_174','HG_175']) @@@ -2006,8 -1927,8 +1990,8 @@@ class test_vimconn_vminstance_by_numa_a def test_000_vminstance_by_numa_affinity(self): flavor_data = {'extended': {'numas': [{'paired-threads-id': [['1', '3'], ['2', '4']], - ' paired-threads': 2, 'memory': 1}]}, - 'ram': 1024, 'vcpus': 1, 'disk': 10} + ' paired-threads': 2, 'memory': 1}]}, + 'ram': 1024, 'vcpus': 1, 'disk': 10} name = "eth10" # create new flavor @@@ -2024,8 -1945,7 +2008,8 @@@ net_list = [{'use': 'bridge', 'name': name, 'floating_ip': False, 'port_security': True, 'type': 'virtual', 'net_id': self.network_id}] - instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', image_id=image_id, + instance_id, _ = test_config["vim_conn"].new_vminstance(name='Test1_vm', description='', start=False, + image_id=image_id, flavor_id=flavor_id, net_list=net_list) self.assertEqual(type(instance_id),str) @@@ -2211,8 -2131,7 +2195,8 @@@ def test_vimconnector(args) test_config['sriov_net_name'] = args.sriov_net_name # vmware connector obj - test_config['vim_conn'] = vim.vimconnector(name=org_name, tenant_name=tenant_name, user=org_user,passwd=org_passwd, url=vim_url, config=config_params) + test_config['vim_conn'] = vim.vimconnector(name=org_name, tenant_name=tenant_name, user=org_user, + passwd=org_passwd, url=vim_url, config=config_params) elif args.vimtype == "aws": import vimconn_aws as vim @@@ -2244,32 -2163,6 +2228,32 @@@ elif args.vimtype == "openvim": import vimconn_openvim as vim + elif args.vimtype == "azure": + import vimconn_azure as vim + + test_config["test_directory"] = os.path.dirname(__file__) + "/RO_tests" + + tenant_name = args.tenant_name + test_config['tenant'] = tenant_name + config_params = yaml.load(args.config_param) + os_user = config_params.get('user') + os_passwd = config_params.get('passwd') + vim_url = args.endpoint_url + test_config['image_path'] = args.image_path + test_config['image_name'] = args.image_name + #test_config['sriov_net_name'] = args.sriov_net_name + + # azure connector obj + vim_persistent_info = {} + test_config['vim_conn'] = vim.vimconnector( + uuid="test-uuid-1", name="VIO-azure", + tenant_id=None, tenant_name=tenant_name, + url=vim_url, url_admin=None, + user=os_user, passwd=os_passwd, + config=config_params, persistent_info=vim_persistent_info + ) + test_config['vim_conn'].debug = "true" + else: logger.critical("vimtype '{}' not supported".format(args.vimtype)) sys.exit(1) @@@ -2575,7 -2468,7 +2559,7 @@@ if __name__=="__main__" vimconn_parser.set_defaults(func=test_vimconnector) # Mandatory arguments mandatory_arguments = vimconn_parser.add_argument_group('mandatory arguments') - mandatory_arguments.add_argument('--vimtype', choices=['vmware', 'aws', 'openstack', 'openvim'], required=True, + mandatory_arguments.add_argument('--vimtype', choices=['vmware', 'aws', 'openstack', 'openvim','azure'], required=True, help='Set the vimconnector type to test') mandatory_arguments.add_argument('-c', '--config', dest='config_param', required=True, help='Set the vimconnector specific config parameters in dictionary format')