From: kbsub Date: Thu, 5 Dec 2019 17:20:18 +0000 (+0000) Subject: Bug 920 fixing test_RO.py after python3 conversion X-Git-Tag: v7.0.0rc1~4 X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FRO.git;a=commitdiff_plain;h=3de27d6d03d6e371c385b27354c440bb8c3452fd Bug 920 fixing test_RO.py after python3 conversion Change-Id: I3487f2cf8142711b49d72e1ee7a9afc822a53494 Signed-off-by: kbsub --- diff --git a/RO-VIM-vmware/osm_rovim_vmware/vimconn_vmware.py b/RO-VIM-vmware/osm_rovim_vmware/vimconn_vmware.py index 171f7d44..f353264e 100644 --- a/RO-VIM-vmware/osm_rovim_vmware/vimconn_vmware.py +++ b/RO-VIM-vmware/osm_rovim_vmware/vimconn_vmware.py @@ -3720,21 +3720,21 @@ class vimconnector(vimconn.vimconnector): try: content = self.get_network_action(network_uuid=network_uuid) - vm_list_xmlroot = XmlElementTree.fromstring(content) - - network_configuration['status'] = vm_list_xmlroot.get("status") - network_configuration['name'] = vm_list_xmlroot.get("name") - network_configuration['uuid'] = vm_list_xmlroot.get("id").split(":")[3] + if content is not None: + vm_list_xmlroot = XmlElementTree.fromstring(content) - for child in vm_list_xmlroot: - if child.tag.split("}")[1] == 'IsShared': - network_configuration['isShared'] = child.text.strip() - if child.tag.split("}")[1] == 'Configuration': - for configuration in child.iter(): - tagKey = configuration.tag.split("}")[1].strip() - if tagKey != "": - network_configuration[tagKey] = configuration.text.strip() - return network_configuration + network_configuration['status'] = vm_list_xmlroot.get("status") + network_configuration['name'] = vm_list_xmlroot.get("name") + network_configuration['uuid'] = vm_list_xmlroot.get("id").split(":")[3] + + for child in vm_list_xmlroot: + if child.tag.split("}")[1] == 'IsShared': + network_configuration['isShared'] = child.text.strip() + if child.tag.split("}")[1] == 'Configuration': + for configuration in child.iter(): + tagKey = configuration.tag.split("}")[1].strip() + if tagKey != "": + network_configuration[tagKey] = configuration.text.strip() except Exception as exp : self.logger.debug("get_vcd_network: Failed with Exception {}".format(exp)) raise vimconn.vimconnException("get_vcd_network: Failed with Exception {}".format(exp)) diff --git a/RO/test/test_RO.py b/RO/test/test_RO.py index 85ccdc1c..b325dc4f 100755 --- a/RO/test/test_RO.py +++ b/RO/test/test_RO.py @@ -518,7 +518,7 @@ class test_vimconn_new_network(test_base): #unknown_net_id = "/subscriptions/ca3d18ab-d373-4afb-a5d6-7c44f098d16a/resourceGroups/osmRG/providers/Microsoft.Network/virtualNetworks/osm_vnet/subnets/unnkown_net" net_dict = test_config["vim_conn"].refresh_nets_status([unknown_net_id]) - if test_config['vimtype'] in ('openstack', 'azure'): + if test_config['vimtype'] in ('openstack', 'azure', 'vmware'): self.assertEqual(net_dict[unknown_net_id]['status'], 'DELETED') else: # TODO : Fix vmware connector to return status DELETED as per vimconn.py @@ -2220,7 +2220,7 @@ def _get_random_string(maxLength): if maxLength < min_string: maxLength = min_string maxLength -= len(prefix) length = random.randint(minLength,maxLength) - return 'testing_'+"".join([random.choice(string.letters+string.digits) for i in xrange(length)]) + return 'testing_'+"".join([random.choice(string.ascii_letters+string.digits) for i in range(length)]) def test_vimconnector(args):