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

Python meta.get_server_external_ipv4函数代码示例

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

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



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

示例1: test_get_server_external_ipv4_neutron_accessIPv4

    def test_get_server_external_ipv4_neutron_accessIPv4(self):
        srv = meta.obj_to_dict(fakes.FakeServer(
            id='test-id', name='test-name', status='ACTIVE',
            accessIPv4=PUBLIC_V4))
        ip = meta.get_server_external_ipv4(cloud=self.cloud, server=srv)

        self.assertEqual(PUBLIC_V4, ip)
开发者ID:LIP-Computing,项目名称:shade,代码行数:7,代码来源:test_meta.py


示例2: test_get_server_internal_provider_ipv4_neutron

    def test_get_server_internal_provider_ipv4_neutron(
            self, mock_list_networks, mock_list_subnets,
            mock_has_service):
        # Testing Clouds with Neutron
        mock_has_service.return_value = True
        mock_list_subnets.return_value = SUBNETS_WITH_NAT
        mock_list_networks.return_value = [{
            'id': 'test-net-id',
            'name': 'test-net',
            'router:external': False,
            'provider:network_type': 'vxlan',
            'provider:physical_network': None,
        }]

        srv = meta.obj_to_dict(fakes.FakeServer(
            id='test-id', name='test-name', status='ACTIVE',
            addresses={'test-net': [{
                'addr': PRIVATE_V4,
                'version': 4}]},
        ))
        self.assertIsNone(
            meta.get_server_external_ipv4(cloud=self.cloud, server=srv))
        int_ip = meta.get_server_private_ip(cloud=self.cloud, server=srv)

        self.assertEqual(PRIVATE_V4, int_ip)
开发者ID:LIP-Computing,项目名称:shade,代码行数:25,代码来源:test_meta.py


示例3: test_get_server_external_ipv4_neutron_accessIPv4

    def test_get_server_external_ipv4_neutron_accessIPv4(self):
        srv = fakes.make_fake_server(
            server_id='test-id', name='test-name', status='ACTIVE')
        srv['accessIPv4'] = PUBLIC_V4
        ip = meta.get_server_external_ipv4(cloud=self.cloud, server=srv)

        self.assertEqual(PUBLIC_V4, ip)
开发者ID:dbckz,项目名称:shade,代码行数:7,代码来源:test_meta.py


示例4: test_get_server_external_none_ipv4_neutron

    def test_get_server_external_none_ipv4_neutron(self):
        # Testing Clouds with Neutron
        self.register_uris([
            dict(method='GET',
                 uri='https://network.example.com/v2.0/networks.json',
                 json={'networks': [{
                     'id': 'test-net-id',
                     'name': 'test-net',
                     'router:external': False,
                 }]}),
            dict(method='GET',
                 uri='https://network.example.com/v2.0/subnets.json',
                 json={'subnets': SUBNETS_WITH_NAT})
        ])

        srv = fakes.make_fake_server(
            server_id='test-id', name='test-name', status='ACTIVE',
            addresses={'test-net': [{
                'addr': PUBLIC_V4,
                'version': 4}]},
        )
        ip = meta.get_server_external_ipv4(cloud=self.cloud, server=srv)

        self.assertEqual(None, ip)
        self.assert_calls()
开发者ID:dbckz,项目名称:shade,代码行数:25,代码来源:test_meta.py


示例5: test_get_server_external_ipv4_nova_none

    def test_get_server_external_ipv4_nova_none(self):
        # Testing Clouds w/o Neutron or a globally routable IP
        self.cloud.cloud_config.config['has_network'] = False

        srv = fakes.make_fake_server(
            server_id='test-id', name='test-name', status='ACTIVE',
            addresses={'test-net': [{'addr': PRIVATE_V4}]})
        ip = meta.get_server_external_ipv4(cloud=self.cloud, server=srv)

        self.assertIsNone(ip)
开发者ID:dbckz,项目名称:shade,代码行数:10,代码来源:test_meta.py


示例6: test_get_server_external_ipv4_nova_public

    def test_get_server_external_ipv4_nova_public(self):
        # Testing Clouds w/o Neutron and a network named public
        self.cloud.cloud_config.config['has_network'] = False

        srv = fakes.make_fake_server(
            server_id='test-id', name='test-name', status='ACTIVE',
            addresses={'public': [{'addr': PUBLIC_V4, 'version': 4}]})
        ip = meta.get_server_external_ipv4(cloud=self.cloud, server=srv)

        self.assertEqual(PUBLIC_V4, ip)
开发者ID:dbckz,项目名称:shade,代码行数:10,代码来源:test_meta.py


示例7: test_get_server_external_ipv4_neutron_exception

    def test_get_server_external_ipv4_neutron_exception(self, mock_get_server_ip, mock_search_ports, mock_has_service):
        # Testing Clouds with a non working Neutron
        mock_has_service.return_value = True
        mock_search_ports.side_effect = neutron_exceptions.NotFound()
        mock_get_server_ip.return_value = PUBLIC_V4

        srv = fakes.FakeServer(id="test-id", name="test-name", status="ACTIVE")
        ip = meta.get_server_external_ipv4(cloud=shade.openstack_cloud(), server=srv)

        self.assertEqual(PUBLIC_V4, ip)
        self.assertTrue(mock_get_server_ip.called)
开发者ID:vaibhavmital,项目名称:shade,代码行数:11,代码来源:test_meta.py


示例8: test_get_server_external_ipv4_nova_public

    def test_get_server_external_ipv4_nova_public(
            self, mock_has_service):
        # Testing Clouds w/o Neutron and a network named public
        mock_has_service.return_value = False

        srv = meta.obj_to_dict(fakes.FakeServer(
            id='test-id', name='test-name', status='ACTIVE',
            addresses={'public': [{'addr': PUBLIC_V4, 'version': 4}]}))
        ip = meta.get_server_external_ipv4(cloud=self.cloud, server=srv)

        self.assertEqual(PUBLIC_V4, ip)
开发者ID:LIP-Computing,项目名称:shade,代码行数:11,代码来源:test_meta.py


示例9: test_get_server_external_ipv4_nova_none

    def test_get_server_external_ipv4_nova_none(
            self, mock_get_server_ip, mock_has_service):
        # Testing Clouds w/o Neutron and a globally routable IP
        mock_has_service.return_value = False
        mock_get_server_ip.return_value = None

        srv = meta.obj_to_dict(fakes.FakeServer(
            id='test-id', name='test-name', status='ACTIVE',
            addresses={'test-net': [{'addr': PRIVATE_V4}]}))
        ip = meta.get_server_external_ipv4(cloud=self.cloud, server=srv)

        self.assertIsNone(ip)
        self.assertTrue(mock_get_server_ip.called)
开发者ID:LIP-Computing,项目名称:shade,代码行数:13,代码来源:test_meta.py


示例10: test_get_server_external_ipv4_neutron

    def test_get_server_external_ipv4_neutron(
        self, mock_get_server_ip, mock_search_networks, mock_search_ports, mock_has_service
    ):
        # Testing Clouds with Neutron
        mock_has_service.return_value = True
        mock_search_ports.return_value = [
            {"network_id": "test-net-id", "fixed_ips": [{"ip_address": PUBLIC_V4}], "device_id": "test-id"}
        ]
        mock_search_networks.return_value = [{"id": "test-net-id"}]

        srv = fakes.FakeServer(id="test-id", name="test-name", status="ACTIVE")
        ip = meta.get_server_external_ipv4(cloud=shade.openstack_cloud(), server=srv)

        self.assertEqual(PUBLIC_V4, ip)
        self.assertFalse(mock_get_server_ip.called)
开发者ID:vaibhavmital,项目名称:shade,代码行数:15,代码来源:test_meta.py


示例11: test_get_server_external_ipv4_neutron_exception

    def test_get_server_external_ipv4_neutron_exception(self):
        # Testing Clouds with a non working Neutron
        self.register_uris([
            dict(method='GET',
                 uri='https://network.example.com/v2.0/networks.json',
                 status_code=404)])

        srv = fakes.make_fake_server(
            server_id='test-id', name='test-name', status='ACTIVE',
            addresses={'public': [{'addr': PUBLIC_V4, 'version': 4}]}
        )
        ip = meta.get_server_external_ipv4(cloud=self.cloud, server=srv)

        self.assertEqual(PUBLIC_V4, ip)
        self.assert_calls()
开发者ID:dbckz,项目名称:shade,代码行数:15,代码来源:test_meta.py


示例12: test_get_server_external_ipv4_neutron_exception

    def test_get_server_external_ipv4_neutron_exception(
            self, mock_get_server_ip, mock_search_ports,
            mock_search_networks,
            mock_has_service):
        # Testing Clouds with a non working Neutron
        mock_has_service.return_value = True
        mock_search_networks.return_value = []
        mock_search_ports.side_effect = neutron_exceptions.NotFound()
        mock_get_server_ip.return_value = PUBLIC_V4

        srv = meta.obj_to_dict(fakes.FakeServer(
            id='test-id', name='test-name', status='ACTIVE'))
        ip = meta.get_server_external_ipv4(cloud=self.cloud, server=srv)

        self.assertEqual(PUBLIC_V4, ip)
        self.assertTrue(mock_get_server_ip.called)
开发者ID:major,项目名称:shade,代码行数:16,代码来源:test_meta.py


示例13: test_get_server_external_ipv4_nova_none

    def test_get_server_external_ipv4_nova_none(
        self, mock_is_globally_routable_ipv4, mock_get_server_ip, mock_has_service
    ):
        # Testing Clouds w/o Neutron and a globally routable IP
        mock_has_service.return_value = False
        mock_get_server_ip.return_value = None
        mock_is_globally_routable_ipv4.return_value = False

        srv = fakes.FakeServer(
            id="test-id", name="test-name", status="ACTIVE", addresses={"test-net": [{"addr": PRIVATE_V4}]}
        )
        ip = meta.get_server_external_ipv4(cloud=shade.openstack_cloud(), server=srv)

        self.assertIsNone(ip)
        self.assertTrue(mock_get_server_ip.called)
        self.assertTrue(mock_is_globally_routable_ipv4.called)
开发者ID:vaibhavmital,项目名称:shade,代码行数:16,代码来源:test_meta.py


示例14: test_get_server_external_ipv4_nova_public

    def test_get_server_external_ipv4_nova_public(
            self, mock_is_globally_routable_ipv4,
            mock_get_server_ip, mock_has_service):
        # Testing Clouds w/o Neutron and a network named public
        mock_has_service.return_value = False
        mock_get_server_ip.return_value = None
        mock_is_globally_routable_ipv4.return_value = True

        srv = meta.obj_to_dict(fakes.FakeServer(
            id='test-id', name='test-name', status='ACTIVE',
            addresses={'test-net': [{'addr': PUBLIC_V4}]}))
        ip = meta.get_server_external_ipv4(
            cloud=shade.openstack_cloud(), server=srv)

        self.assertEqual(PUBLIC_V4, ip)
        self.assertTrue(mock_get_server_ip.called)
        self.assertTrue(mock_is_globally_routable_ipv4.called)
开发者ID:jsmartin,项目名称:shade,代码行数:17,代码来源:test_meta.py


示例15: test_get_server_external_ipv4_neutron

    def test_get_server_external_ipv4_neutron(
            self, mock_search_networks,
            mock_has_service):
        # Testing Clouds with Neutron
        mock_has_service.return_value = True
        mock_search_networks.return_value = [{
            'id': 'test-net-id',
            'name': 'test-net'
        }]

        srv = meta.obj_to_dict(fakes.FakeServer(
            id='test-id', name='test-name', status='ACTIVE',
            addresses={'test-net': [{
                'addr': PUBLIC_V4,
                'version': 4}]},
        ))
        ip = meta.get_server_external_ipv4(cloud=self.cloud, server=srv)

        self.assertEqual(PUBLIC_V4, ip)
开发者ID:major,项目名称:shade,代码行数:19,代码来源:test_meta.py


示例16: test_add_auto_ip

    def test_add_auto_ip(self):
        self._setup_networks()

        new_server = self.cloud.create_server(
            wait=True, name=self.new_item_name + '_server',
            image=self.image,
            flavor=self.flavor, nics=[self.nic])

        # ToDo: remove the following iteration when create_server waits for
        # the IP to be attached
        ip = None
        for _ in _utils._iterate_timeout(
                self.timeout, "Timeout waiting for IP address to be attached"):
            ip = meta.get_server_external_ipv4(self.cloud, new_server)
            if ip is not None:
                break
            new_server = self.cloud.get_server(new_server.id)

        self.addCleanup(self._cleanup_ips, new_server)
开发者ID:erickcantwell,项目名称:shade,代码行数:19,代码来源:test_floating_ip.py


示例17: test_get_server_external_ipv4_neutron

    def test_get_server_external_ipv4_neutron(
            self, mock_get_server_ip, mock_search_networks,
            mock_search_ports, mock_has_service):
        # Testing Clouds with Neutron
        mock_has_service.return_value = True
        mock_search_ports.return_value = [{
            'network_id': 'test-net-id',
            'fixed_ips': [{'ip_address': PUBLIC_V4}],
            'device_id': 'test-id'
        }]
        mock_search_networks.return_value = [{'id': 'test-net-id'}]

        srv = meta.obj_to_dict(fakes.FakeServer(
            id='test-id', name='test-name', status='ACTIVE'))
        ip = meta.get_server_external_ipv4(
            cloud=shade.openstack_cloud(), server=srv)

        self.assertEqual(PUBLIC_V4, ip)
        self.assertFalse(mock_get_server_ip.called)
开发者ID:jsmartin,项目名称:shade,代码行数:19,代码来源:test_meta.py


示例18: test_get_server_external_none_ipv4_neutron

    def test_get_server_external_none_ipv4_neutron(
            self, mock_list_networks, mock_list_subnets,
            mock_has_service):
        # Testing Clouds with Neutron
        mock_has_service.return_value = True
        mock_list_subnets.return_value = SUBNETS_WITH_NAT
        mock_list_networks.return_value = [{
            'id': 'test-net-id',
            'name': 'test-net',
            'router:external': False,
        }]

        srv = meta.obj_to_dict(fakes.FakeServer(
            id='test-id', name='test-name', status='ACTIVE',
            addresses={'test-net': [{
                'addr': PUBLIC_V4,
                'version': 4}]},
        ))
        ip = meta.get_server_external_ipv4(cloud=self.cloud, server=srv)

        self.assertEqual(None, ip)
开发者ID:LIP-Computing,项目名称:shade,代码行数:21,代码来源:test_meta.py


示例19: test_detach_ip_from_server

    def test_detach_ip_from_server(self):
        self._setup_networks()

        new_server = self.cloud.create_server(
            wait=True, name=self.new_item_name + '_server',
            image=self.image,
            flavor=self.flavor, nics=[self.nic])

        # ToDo: remove the following iteration when create_server waits for
        # the IP to be attached
        ip = None
        for _ in _iterate_timeout(
                self.timeout, "Timeout waiting for IP address to be attached"):
            ip = meta.get_server_external_ipv4(self.cloud, new_server)
            if ip is not None:
                break
            new_server = self.cloud.get_server(new_server.id)

        self.addCleanup(self._cleanup_ips, [ip])

        f_ip = self.cloud.get_floating_ip(
            id=None, filters={'floating_ip_address': ip})
        self.cloud.detach_ip_from_server(
            server_id=new_server.id, floating_ip_id=f_ip['id'])
开发者ID:adreznec,项目名称:shade,代码行数:24,代码来源:test_floating_ip.py


示例20: test_get_server_ip

 def test_get_server_ip(self):
     srv = meta.obj_to_dict(FakeServer())
     cloud = shade.openstack_cloud(validate=False)
     self.assertEqual(PRIVATE_V4, meta.get_server_private_ip(srv, cloud))
     self.assertEqual(PUBLIC_V4, meta.get_server_external_ipv4(cloud, srv))
开发者ID:insequent,项目名称:shade,代码行数:5,代码来源:test_meta.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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