def on_get(self, req, resp):
try:
maas_client = MaasRequestFactory(
config.config_mgr.conf.maasdriver.maas_api_url,
config.config_mgr.conf.maasdriver.maas_api_key)
machine_list = Machines(maas_client)
machine_list.refresh()
node_view = list()
for m in machine_list:
m.get_power_params()
node_view.append(
dict(
hostname=m.hostname,
memory=m.memory,
cpu_count=m.cpu_count,
status_name=m.status_name,
boot_mac=m.boot_mac,
power_state=m.power_state,
power_address=m.power_parameters.get('power_address'),
boot_ip=m.boot_ip))
resp.body = json.dumps(node_view)
resp.status = falcon.HTTP_200
except Exception as ex:
self.error(req.context, "Unknown error: %s" % str(ex), exc_info=ex)
self.return_error(
resp, falcon.HTTP_500, message="Unknown error", retry=False)
评论列表
文章目录