From: Ravi Chamarty Date: Sun, 7 Oct 2018 15:45:44 +0000 (+0000) Subject: Bug 556 Fix VCD 9.1 compliance - Align to vcloud 30.0 API X-Git-Tag: v5.0.0~28 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F87%2F6687%2F2;p=osm%2FRO.git Bug 556 Fix VCD 9.1 compliance - Align to vcloud 30.0 API Signed-off-by: Ravi Chamarty --- diff --git a/osm_ro/vimconn_vmware.py b/osm_ro/vimconn_vmware.py index 2e25c507..caaf50de 100644 --- a/osm_ro/vimconn_vmware.py +++ b/osm_ro/vimconn_vmware.py @@ -1588,6 +1588,7 @@ class vimconnector(vimconn.vimconnector): #If no mgmt, then the 1st NN in netlist is considered as primary net. primary_net = None primary_netname = None + primary_net_href = None network_mode = 'bridged' if net_list is not None and len(net_list) > 0: for net in net_list: @@ -1598,6 +1599,8 @@ class vimconnector(vimconn.vimconnector): try: primary_net_id = primary_net['net_id'] + url_list = [self.url, '/api/network/', primary_net_id] + primary_net_href = ''.join(url_list) network_dict = self.get_vcd_network(network_uuid=primary_net_id) if 'name' in network_dict: primary_netname = network_dict['name'] @@ -1667,9 +1670,9 @@ class vimconnector(vimconn.vimconnector): Configuration parameters for logical networks - + - + bridged @@ -1724,6 +1727,8 @@ class vimconnector(vimconn.vimconnector): false """.format(vmname_andid, + primary_netname, + primary_net_href, vapp_tempalte_href, vm_href, vm_id, @@ -1862,8 +1867,8 @@ class vimconnector(vimconn.vimconnector): # add NICs & connect to networks in netlist try: self.logger.info("Request to connect VM to a network: {}".format(net_list)) - nicIndex = 0 primary_nic_index = 0 + nicIndex = 0 for net in net_list: # openmano uses network id in UUID format. # vCloud Director need a name so we do reverse operation from provided UUID we lookup a name @@ -1881,6 +1886,10 @@ class vimconnector(vimconn.vimconnector): interface_net_name = self.get_network_name_by_id(network_uuid=interface_net_id) interface_network_mode = net['use'] + if interface_net_name == primary_netname: + nicIndex += 1 + continue + if interface_network_mode == 'mgmt': primary_nic_index = nicIndex @@ -2774,11 +2783,16 @@ class vimconnector(vimconn.vimconnector): "VM details") xmlroot = XmlElementTree.fromstring(response.content) + result = response.content.replace("\n"," ") - hdd_mb = re.search('vcloud:capacity="(\d+)"\svcloud:storageProfileOverrideVmDefault=',result).group(1) - vm_details['hdd_mb'] = int(hdd_mb) if hdd_mb else None - cpus = re.search('Number of Virtual CPUs(\d+)',result).group(1) - vm_details['cpus'] = int(cpus) if cpus else None + hdd_match = re.search('vcloud:capacity="(\d+)"\svcloud:storageProfileOverrideVmDefault=',result) + if hdd_match: + hdd_mb = hdd_match.group(1) + vm_details['hdd_mb'] = int(hdd_mb) if hdd_mb else None + cpus_match = re.search('Number of Virtual CPUs(\d+)',result) + if cpus_match: + cpus = cpus_match.group(1) + vm_details['cpus'] = int(cpus) if cpus else None memory_mb = re.search('Memory Size(\d+)',result).group(1) vm_details['memory_mb'] = int(memory_mb) if memory_mb else None vm_details['status'] = vcdStatusCode2manoFormat[int(xmlroot.get('status'))] @@ -4634,6 +4648,8 @@ class vimconnector(vimconn.vimconnector): None """ + self.logger.info("Add network adapter to VM: network_name {} nicIndex {}".\ + format(network_name, nicIndex)) try: ip_address = None floating_ip = False