当前位置: 首页>>代码示例>>Python>>正文


Python meta.get_server_external_ipv4函数代码示例

本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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