From: bhangare Date: Tue, 27 Dec 2016 09:41:28 +0000 (-0800) Subject: Changes in vimconn_vmware.py: Fixed Bug ID 121: VMWARE Connector: Return Nic status... X-Git-Tag: v1.0.3^2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F41%2F841%2F2;p=osm%2FRO.git Changes in vimconn_vmware.py: Fixed Bug ID 121: VMWARE Connector: Return Nic status to include IP address and MAC Signed-off-by: bhangare --- diff --git a/vimconn_vmware.py b/vimconn_vmware.py index ef3ada51..27583e0b 100644 --- a/vimconn_vmware.py +++ b/vimconn_vmware.py @@ -1482,8 +1482,8 @@ class vimconnector(vimconn.vimconnector): for vm_network in vapp_network: if vm_network['name'] == vmname: interface = {"mac_address": vm_network['mac'], - "vim_net_id": self.get_network_name_by_id(vm_network['network_name']), - "vim_interface_id": vm_network['network_name'], + "vim_net_id": self.get_network_id_by_name(vm_network['network_name']), + "vim_interface_id": self.get_network_id_by_name(vm_network['network_name']), 'ip_address': vm_network['ip']} # interface['vim_info'] = yaml.safe_dump(vm_network) vm_dict["interfaces"].append(interface) @@ -1643,6 +1643,37 @@ class vimconnector(vimconn.vimconnector): return None + def get_network_id_by_name(self, network_name=None): + """Method gets vcloud director network uuid based on supplied name. + + Args: + network_name: network_name + Returns: + The return network uuid. + network_uuid: network_id + """ + + vca = self.connect() + if not vca: + raise vimconn.vimconnConnectionException("self.connect() is failed.") + + if not network_name: + self.logger.debug("get_network_id_by_name() : Network name is empty") + return None + + try: + org_dict = self.get_org(self.org_uuid) + if org_dict and 'networks' in org_dict: + org_network_dict = org_dict['networks'] + for net_uuid,net_name in org_network_dict.iteritems(): + if net_name == network_name: + return net_uuid + + except KeyError as exp: + self.logger.debug("get_network_id_by_name() : KeyError- {} ".format(exp)) + + return None + def list_org_action(self): """ Method leverages vCloud director and query for available organization for particular user