• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python common.status_from_state函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nova.api.openstack.common.status_from_state函数的典型用法代码示例。如果您正苦于以下问题:Python status_from_state函数的具体用法?Python status_from_state怎么用?Python status_from_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了status_from_state函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _build_detail

    def _build_detail(self, inst, networks):
        """Returns a detailed model of a server."""
        vm_state = inst.get('vm_state', vm_states.BUILDING)
        task_state = inst.get('task_state')

        inst_dict = {
            'id': inst['id'],
            'name': inst['display_name'],
            'user_id': inst.get('user_id', ''),
            'tenant_id': inst.get('project_id', ''),
            'status': common.status_from_state(vm_state, task_state)}

        # Return the metadata as a dictionary
        metadata = {}
        for item in inst.get('metadata', []):
            metadata[item['key']] = str(item['value'])
        inst_dict['metadata'] = metadata

        inst_dict['hostId'] = ''
        if inst.get('host'):
            inst_dict['hostId'] = hashlib.sha224(inst['host']).hexdigest()

        self._build_image(inst_dict, inst)
        self._build_flavor(inst_dict, inst)
        self._build_addresses(inst_dict, networks)

        return dict(server=inst_dict)
开发者ID:daniel-hou0,项目名称:nova,代码行数:27,代码来源:servers.py


示例2: _build_detail

    def _build_detail(self, inst):
        """Returns a detailed model of a server."""
        vm_state = inst.get("vm_state", vm_states.BUILDING)
        task_state = inst.get("task_state")

        inst_dict = {
            "id": inst["id"],
            "name": inst["display_name"],
            "user_id": inst.get("user_id", ""),
            "tenant_id": inst.get("project_id", ""),
            "status": common.status_from_state(vm_state, task_state),
        }

        # Return the metadata as a dictionary
        metadata = {}
        for item in inst.get("metadata", []):
            metadata[item["key"]] = str(item["value"])
        inst_dict["metadata"] = metadata

        inst_dict["hostId"] = ""
        if inst.get("host"):
            inst_dict["hostId"] = hashlib.sha224(inst["host"]).hexdigest()

        self._build_image(inst_dict, inst)
        self._build_flavor(inst_dict, inst)
        self._build_addresses(inst_dict, inst)

        return dict(server=inst_dict)
开发者ID:rackerlabs,项目名称:reddwarf,代码行数:28,代码来源:servers.py


示例3: test_status_from_state

 def test_status_from_state(self):
     for vm_state in (vm_states.ACTIVE, vm_states.STOPPED):
         for task_state in (task_states.RESIZE_PREP,
                            task_states.RESIZE_MIGRATING,
                            task_states.RESIZE_MIGRATED,
                            task_states.RESIZE_FINISH):
             actual = common.status_from_state(vm_state, task_state)
             expected = 'RESIZE'
             self.assertEqual(expected, actual)
开发者ID:anjoah,项目名称:nova,代码行数:9,代码来源:test_common.py


示例4: test_status_rebuild_from_state

 def test_status_rebuild_from_state(self):
     for vm_state in (vm_states.ACTIVE, vm_states.STOPPED,
                      vm_states.ERROR):
         for task_state in (task_states.REBUILDING,
                            task_states.REBUILD_BLOCK_DEVICE_MAPPING,
                            task_states.REBUILD_SPAWNING):
             actual = common.status_from_state(vm_state, task_state)
             expected = 'REBUILD'
             self.assertEqual(expected, actual)
开发者ID:amadev,项目名称:nova,代码行数:9,代码来源:test_common.py


示例5: _build_detail

    def _build_detail(self, inst):
        """Returns a detailed model of a server."""
        vm_state = inst.get("vm_state", vm_states.BUILDING)
        task_state = inst.get("task_state")

        inst_dict = {
            "id": inst["id"],
            "name": inst["display_name"],
            "user_id": inst.get("user_id", ""),
            "tenant_id": inst.get("project_id", ""),
            "status": common.status_from_state(vm_state, task_state),
        }

        # Return the metadata as a dictionary
        metadata = {}
        for item in inst.get("metadata", []):
            metadata[item["key"]] = str(item["value"])
        inst_dict["metadata"] = metadata

        inst_dict["hostId"] = ""
        if inst.get("host"):
            inst_dict["hostId"] = hashlib.sha224(inst["host"]).hexdigest()

        self._build_image(inst_dict, inst)
        self._build_flavor(inst_dict, inst)
        networks = common.get_networks_for_instance(self.context, inst)
        self._build_addresses(inst_dict, networks)

        inst_dict["created"] = utils.isotime(inst["created_at"])
        inst_dict["updated"] = utils.isotime(inst["updated_at"])

        status = inst_dict.get("status")
        if status in ("ACTIVE", "BUILD", "REBUILD", "RESIZE", "VERIFY_RESIZE"):
            inst_dict["progress"] = inst["progress"] or 0

        inst_dict["accessIPv4"] = inst.get("access_ip_v4") or ""
        inst_dict["accessIPv6"] = inst.get("access_ip_v6") or ""
        inst_dict["key_name"] = inst.get("key_name", "")
        inst_dict["config_drive"] = inst.get("config_drive")

        return dict(server=inst_dict)
开发者ID:gagupta,项目名称:nova,代码行数:41,代码来源:servers.py


示例6: _build_detail

    def _build_detail(self, inst):
        """Returns a detailed model of a server."""
        vm_state = inst.get('vm_state', vm_states.BUILDING)
        task_state = inst.get('task_state')

        inst_dict = {
            'id': inst['uuid'],
            'name': inst['display_name'],
            'user_id': inst.get('user_id', ''),
            'tenant_id': inst.get('project_id', ''),
            'status': common.status_from_state(vm_state, task_state)}

        # Return the metadata as a dictionary
        metadata = {}
        for item in inst.get('metadata', []):
            metadata[item['key']] = str(item['value'])
        inst_dict['metadata'] = metadata

        inst_dict['hostId'] = ''
        if inst.get('host'):
            inst_dict['hostId'] = hashlib.sha224(inst['host']).hexdigest()

        self._build_image(inst_dict, inst)
        self._build_flavor(inst_dict, inst)
        networks = common.get_networks_for_instance(self.context, inst)
        self._build_addresses(inst_dict, networks)

        inst_dict['created'] = utils.isotime(inst['created_at'])
        inst_dict['updated'] = utils.isotime(inst['updated_at'])

        status = inst_dict.get('status')
        if status in ('ACTIVE', 'BUILD', 'REBUILD', 'RESIZE',
                      'VERIFY_RESIZE'):
            inst_dict['progress'] = inst['progress'] or 0

        inst_dict['accessIPv4'] = inst.get('access_ip_v4') or ""
        inst_dict['accessIPv6'] = inst.get('access_ip_v6') or ""
        inst_dict['key_name'] = inst.get('key_name', '')
        inst_dict['config_drive'] = inst.get('config_drive')

        return dict(server=inst_dict)
开发者ID:dragonetail,项目名称:nova,代码行数:41,代码来源:servers.py


示例7: _get_vm_state

 def _get_vm_state(instance):
     return common.status_from_state(instance.get("vm_state"),
                                     instance.get("task_state"))
开发者ID:ammonite,项目名称:nova,代码行数:3,代码来源:servers.py


示例8: test_status_migrating_from_state

 def test_status_migrating_from_state(self):
     for vm_state in (vm_states.ACTIVE, vm_states.PAUSED):
         task_state = task_states.MIGRATING
         actual = common.status_from_state(vm_state, task_state)
         expected = 'MIGRATING'
         self.assertEqual(expected, actual)
开发者ID:amadev,项目名称:nova,代码行数:6,代码来源:test_common.py


示例9: _get_vm_status

 def _get_vm_status(instance):
     # If the instance is deleted the vm and task states don't really matter
     if instance.get("deleted"):
         return "DELETED"
     return common.status_from_state(instance.get("vm_state"),
                                     instance.get("task_state"))
开发者ID:fabian4,项目名称:nova,代码行数:6,代码来源:servers.py



注:本文中的nova.api.openstack.common.status_from_state函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.task_and_vm_state_from_status函数代码示例发布时间:2022-05-27
下一篇:
Python common.remove_version_from_href函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap