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

Python common.get_networks_for_instance函数代码示例

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

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



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

示例1: _get_instance_ips

 def _get_instance_ips(context, instance):
     ret = []
     for network in common.get_networks_for_instance(
             context, instance).values():
         all_ips = itertools.chain(network["ips"], network["floating_ips"])
         ret += [ip["address"] for ip in all_ips]
     return ret
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Nova,代码行数:7,代码来源:fping.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)
        networks = common.get_networks_for_instance(self.context, inst)
        self._build_addresses(inst_dict, networks)

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


示例3: _get_addresses

 def _get_addresses(self, request, instance, extend_address=False):
     # Hide server addresses while the server is building.
     if instance.vm_state == vm_states.BUILDING:
         return {}
     context = request.environ["nova.context"]
     networks = common.get_networks_for_instance(context, instance)
     return self._address_builder.index(networks,
                                        extend_address)["addresses"]
开发者ID:mikalstill,项目名称:nova,代码行数:8,代码来源:servers.py


示例4: show

    def show(self, req, server_id, id):
        context = req.environ["nova.context"]
        instance = self._get_instance(context, server_id)
        networks = common.get_networks_for_instance(context, instance)
        if id not in networks:
            msg = _("Instance is not a member of specified network")
            raise exc.HTTPNotFound(explanation=msg)

        return self._view_builder.show(networks[id], id)
开发者ID:B-Rich,项目名称:nova-1,代码行数:9,代码来源:ips.py


示例5: test_get_networks_for_instance_handles_instance_not_found

    def test_get_networks_for_instance_handles_instance_not_found(self):

        def raise_not_found(*args, **kwargs):
            raise exception.InstanceNotFound(instance_id='abcd')

        self.stubs.Set(network.API, 'get_instance_nw_info', raise_not_found)

        networks = common.get_networks_for_instance(context={}, instance={})
        self.assertEqual(networks, {})
开发者ID:ironcamel,项目名称:nova,代码行数:9,代码来源:test_common.py


示例6: show

    def show(self, req, server_id, id):
        context = req.environ["nova.context"]
        context.can(ips_policies.POLICY_ROOT % 'show')
        instance = common.get_instance(self._compute_api, context, server_id)
        networks = common.get_networks_for_instance(context, instance)
        if id not in networks:
            msg = _("Instance is not a member of specified network")
            raise exc.HTTPNotFound(explanation=msg)

        return self._view_builder.show(networks[id], id)
开发者ID:arbrandes,项目名称:nova,代码行数:10,代码来源:ips.py


示例7: _extend_server

 def _extend_server(self, context, server, instance):
     key = "%s:mac_addr" % Extended_ips_mac.alias
     networks = common.get_networks_for_instance(context, instance)
     for label, network in networks.items():
         # NOTE(vish): ips are hidden in some states via the
         #             hide_server_addresses extension.
         if label in server['addresses']:
             all_ips = itertools.chain(network["ips"],
                                       network["floating_ips"])
             for i, ip in enumerate(all_ips):
                 server['addresses'][label][i][key] = ip['mac_address']
开发者ID:375670450,项目名称:nova,代码行数:11,代码来源:extended_ips_mac.py


示例8: show

    def show(self, req, server_id, id):
        context = req.environ['nova.context']
        instance = self._get_instance(context, server_id)
        networks = common.get_networks_for_instance(context, instance)
        network = self._get_view_builder(req).build_network(networks, id)

        if network is None:
            msg = _("Instance is not a member of specified network")
            raise exc.HTTPNotFound(explanation=msg)

        return network
开发者ID:blamarvt,项目名称:nova,代码行数:11,代码来源:ips.py


示例9: show

    def show(self, req, server_id, id):
        context = req.environ['nova.context']
        instance = self._get_instance(context, server_id)
        networks = common.get_networks_for_instance(context, instance)
        builder = self._get_view_builder(req)
        if id == 'private':
            view = builder.build_private_parts(networks)
        elif id == 'public':
            view = builder.build_public_parts(networks)
        else:
            msg = _("Only private and public networks available")
            raise exc.HTTPNotFound(explanation=msg)

        return {id: view}
开发者ID:Oneiroi,项目名称:nova,代码行数:14,代码来源:ips.py


示例10: _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


示例11: _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


示例12: index

 def index(self, req, server_id):
     context = req.environ["nova.context"]
     instance = self._get_instance(context, server_id)
     networks = common.get_networks_for_instance(context, instance)
     return self._view_builder.index(networks)
开发者ID:B-Rich,项目名称:nova-1,代码行数:5,代码来源:ips.py


示例13: _get_addresses

 def _get_addresses(self, request, instance):
     context = request.environ["nova.context"]
     networks = common.get_networks_for_instance(context, instance)
     return self._address_builder.index(networks)["addresses"]
开发者ID:ammonite,项目名称:nova,代码行数:4,代码来源:servers.py


示例14: index

 def index(self, req, server_id):
     context = req.environ["nova.context"]
     authorize(context, action='index')
     instance = common.get_instance(self._compute_api, context, server_id)
     networks = common.get_networks_for_instance(context, instance)
     return self._view_builder.index(networks)
开发者ID:binarycode,项目名称:nova,代码行数:6,代码来源:ips.py


示例15: index

 def index(self, req, server_id):
     context = req.environ['nova.context']
     instance = self._get_instance(context, server_id)
     networks = common.get_networks_for_instance(context, instance)
     return {'addresses': self._get_view_builder(req).build(networks)}
开发者ID:blamarvt,项目名称:nova,代码行数:5,代码来源:ips.py


示例16: index

 def index(self, req, server_id):
     context = req.environ["nova.context"]
     context.can(ips_policies.POLICY_ROOT % 'index')
     instance = common.get_instance(self._compute_api, context, server_id)
     networks = common.get_networks_for_instance(context, instance)
     return self._view_builder.index(networks)
开发者ID:arbrandes,项目名称:nova,代码行数:6,代码来源:ips.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python common.get_pagination_params函数代码示例发布时间:2022-05-27
下一篇:
Python common.get_limit_and_marker函数代码示例发布时间: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