ansible_inventory.py 文件源码

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

项目:craton 作者: openstack 项目源码 文件源码
def get(self, context, request_args):
        region_id = request_args["region_id"]
        cell_id = request_args["cell_id"]

        filters = {}
        if region_id:
            filters['region_id'] = region_id

        # TODO(sulo): allow other filters based on services
        if cell_id:
            filters['cell_id'] = cell_id

        try:
            hosts_obj = dbapi.hosts_get_all(context, filters)
        except exceptions.NotFound:
            return self.error_response(404, 'Not Found')
        except Exception as err:
            LOG.error("Error during host get: %s" % err)
            return self.error_response(500, 'Unknown Error')

        _inventory = self.generate_ansible_inventory(hosts_obj)
        inventory = jsonutils.to_primitive(_inventory)
        return inventory, 200, None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号