From: kasar Date: Tue, 15 May 2018 13:15:07 +0000 (-0700) Subject: Modified refresh_vms_status for multiple IPs and MAC addresses X-Git-Tag: v4.0.0~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F47%2F6147%2F1;p=osm%2FRO.git Modified refresh_vms_status for multiple IPs and MAC addresses Change-Id: Ia54d0ee3c6305425658578522cd0dee78005280c Signed-off-by: kasar --- diff --git a/osm_ro/vimconn_vmware.py b/osm_ro/vimconn_vmware.py index 2a8adaf9..e24082c2 100644 --- a/osm_ro/vimconn_vmware.py +++ b/osm_ro/vimconn_vmware.py @@ -2251,27 +2251,32 @@ class vimconnector(vimconn.vimconnector): 'vim_info': yaml.safe_dump(vm_info), 'interfaces': []} # get networks - vm_ip = None - vm_mac = None - if vm.NetworkConnectionSection.NetworkConnection: - vm_mac = vm.NetworkConnectionSection.NetworkConnection.MACAddress - if vm_ip is None: - if not nsx_edge_list: - nsx_edge_list = self.get_edge_details() - if nsx_edge_list is None: - raise vimconn.vimconnException("refresh_vms_status:"\ - "Failed to get edge details from NSX Manager") - if vm_mac is not None: - vm_ip = self.get_ipaddr_from_NSXedge(nsx_edge_list, vm_mac) - - network_name = vm.NetworkConnectionSection.NetworkConnection.get('network') - vm_net_id = self.get_network_id_by_name(network_name) - interface = {"mac_address": vm_mac, - "vim_net_id": vm_net_id, - "vim_interface_id": vm_net_id, - 'ip_address': vm_ip} - - vm_dict["interfaces"].append(interface) + vm_ip= None + vm_mac = None + networks = re.findall('',result) + for network in networks: + mac_s = re.search('(.*?)',network) + vm_mac = mac_s.group(1) if mac_s else None + ip_s = re.search('(.*?)',network) + vm_ip = ip_s.group(1) if ip_s else None + + if vm_ip is None: + if not nsx_edge_list: + nsx_edge_list = self.get_edge_details() + if nsx_edge_list is None: + raise vimconn.vimconnException("refresh_vms_status:"\ + "Failed to get edge details from NSX Manager") + if vm_mac is not None: + vm_ip = self.get_ipaddr_from_NSXedge(nsx_edge_list, vm_mac) + + network_name = vm.NetworkConnectionSection.NetworkConnection.get('network') + vm_net_id = self.get_network_id_by_name(network_name) + interface = {"mac_address": vm_mac, + "vim_net_id": vm_net_id, + "vim_interface_id": vm_net_id, + "ip_address": vm_ip} + + vm_dict["interfaces"].append(interface) # add a vm to vm dict vms_dict.setdefault(vmuuid, vm_dict)