if dc_label is None or dc_label == 'None':
# return list with all compute nodes in all DCs
all_containers = []
- all_extSAPs = []
for dc in dcs.itervalues():
all_containers += dc.listCompute()
- all_extSAPs += dc.listExtSAPs()
-
- extSAP_list = [(sap.name, sap.getStatus())
- for sap in all_extSAPs]
container_list = [(c.name, c.getStatus())
for c in all_containers]
- total_list = container_list + extSAP_list
- return total_list, 200, CORS_HEADER
+ return container_list, 200, CORS_HEADER
else:
# return list of compute nodes for specified DC
container_list = [(c.name, c.getStatus())
for c in dcs.get(dc_label).listCompute()]
- extSAP_list = [(sap.name, sap.getStatus())
- for sap in dcs.get(dc_label).listExtSAPs()]
- total_list = container_list + extSAP_list
- return total_list, 200, CORS_HEADER
+ return container_list, 200, CORS_HEADER
except Exception as ex:
logging.exception("API error.")
return ex.message, 500, CORS_HEADER
self, name, dimage, **kwargs):
self.datacenter = kwargs.get("datacenter") # pointer to current DC
self.flavor_name = kwargs.get("flavor_name")
+ self._network_state_cache = None
LOG.debug("Starting compute instance %r in data center %r" %
(name, str(self.datacenter)))
# call original Docker.__init__
intf_dict = {'intf_name': str(i), 'ip': "{0}/{1}".format(i.IP(), i.prefixLen), 'netmask': i.prefixLen,
'mac': i.MAC(), 'up': i.isUp(), 'status': i.status(), 'dc_portname': dc_port_name}
networkStatusList.append(intf_dict)
-
return networkStatusList
def getStatus(self):
"""
Helper method to receive information about this compute instance.
"""
+ # inspect container
+ cinspect = self.dcli.inspect_container(self.dc)
+ # inspect networking (slow, so do only once)
+ if self._network_state_cache is None:
+ self._network_state_cache = self.getNetworkStatus()
+ # build status
status = {}
status["name"] = self.name
- status["network"] = self.getNetworkStatus()
+ status["network"] = self._network_state_cache
status["docker_network"] = self.dcinfo['NetworkSettings']['IPAddress']
status["image"] = self.dimage
status["flavor_name"] = self.flavor_name
status["cpuset"] = self.resources.get('cpuset_cpus')
status["mem_limit"] = self.resources.get('mem_limit')
status["memswap_limit"] = self.resources.get('memswap_limit')
- status["state"] = self.dcli.inspect_container(self.dc)["State"]
- status["id"] = self.dcli.inspect_container(self.dc)["Id"]
- status["short_id"] = self.dcli.inspect_container(self.dc)["Id"][:12]
- status["hostname"] = self.dcli.inspect_container(self.dc)[
- "Config"]['Hostname']
+ status["state"] = cinspect["State"]
+ status["id"] = cinspect["Id"]
+ status["short_id"] = cinspect["Id"][:12]
+ status["hostname"] = cinspect["Config"]['Hostname']
status["datacenter"] = (None if self.datacenter is None
else self.datacenter.label)