name = c[0]
status = c[1]
eth0ip = status.get("docker_network", "-")
+ netw_list = [netw_dict['intf_name'] for netw_dict in status.get("network")]
+ dc_if_list = [netw_dict['dc_portname'] for netw_dict in status.get("network")]
table.append([status.get("datacenter"),
name,
status.get("image"),
- eth0ip,
- status.get("state").get("Status")])
+ ','.join(netw_list),
+ ','.join(dc_if_list)])
+ #status.get("state").get("Status")]
headers = ["Datacenter",
"Container",
"Image",
- "docker0",
- "Status"]
+ "Interface list",
+ "Datacenter interfaces"]
print(tabulate(table, headers=headers, tablefmt="grid"))
def status(self, args):
dict.update({match[0]:m2})
return dict
+ def find_connected_dc_interface(self, vnf_src_name, vnf_src_interface):
+ for connected_sw in self.DCNetwork_graph.neighbors(vnf_src_name):
+ link_dict = self.DCNetwork_graph[vnf_src_name][connected_sw]
+ for link in link_dict:
+ if (link_dict[link]['src_port_id'] == vnf_src_interface or
+ link_dict[link]['src_port_name'] == vnf_src_interface): # Fix: we might also get interface names, e.g, from a son-emu-cli call
+ # found the right link and connected switch
+ src_sw = connected_sw
+ src_sw_inport_nr = link_dict[link]['dst_port_nr']
+ src_sw_inport_name = link_dict[link]['dst_port_name']
+ return src_sw_inport_name
\ No newline at end of file
Helper method to receive information about the virtual networks
this compute instance is connected to.
"""
-
- # format list of tuples (name, Ip, MAC, isUp, status)
- return [{'intf_name':str(i), 'ip':i.IP(), 'mac':i.MAC(), 'up':i.isUp(), 'status':i.status()}
- for i in self.intfList()]
+ # get all links and find dc switch interface
+ networkStatusList = []
+ for i in self.intfList():
+ vnf_name = self.name
+ vnf_interface = str(i)
+ dc_port_name = self.datacenter.net.find_connected_dc_interface(vnf_name, vnf_interface)
+ # format list of tuples (name, Ip, MAC, isUp, status, dc_portname)
+ intf_dict = {'intf_name': str(i), 'ip': i.IP(), 'mac': i.MAC(), 'up': i.isUp(), 'status': i.status(), 'dc_portname': dc_port_name}
+ networkStatusList.append(intf_dict)
+
+ return networkStatusList
def getStatus(self):
"""