nodes.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:drydock 作者: att-comdev 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号