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


Python meta.get_hostvars_from_server函数代码示例

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


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

示例1: test_image_string

    def test_image_string(self, mock_get_server_external_ipv4):
        mock_get_server_external_ipv4.return_value = PUBLIC_V4

        server = FakeServer()
        server.image = "fake-image-id"
        hostvars = meta.get_hostvars_from_server(FakeCloud(), meta.obj_to_dict(server))
        self.assertEquals("fake-image-id", hostvars["image"]["id"])
开发者ID:vaibhavmital,项目名称:shade,代码行数:7,代码来源:test_meta.py

示例2: _exit_hostvars_count

def _exit_hostvars_count(module, cloud, servers, changed=True):
    hostvars = []
    for server in servers:
        hostvars.append(meta.get_hostvars_from_server(cloud, server))
    server_ids = [server.id for server in servers]
    module.exit_json(
        changed=changed, servers=servers, ids=server_ids, openstack=hostvars)
开发者ID:greg-hellings,项目名称:linch-pin,代码行数:7,代码来源:os_server.py

示例3: test_az

    def test_az(self, mock_get_server_external_ipv4):
        mock_get_server_external_ipv4.return_value = PUBLIC_V4

        server = FakeServer()
        server.__dict__["OS-EXT-AZ:availability_zone"] = "az1"
        hostvars = meta.get_hostvars_from_server(FakeCloud(), meta.obj_to_dict(server))
        self.assertEquals("az1", hostvars["az"])
开发者ID:vaibhavmital,项目名称:shade,代码行数:7,代码来源:test_meta.py

示例4: test_basic_hostvars

    def test_basic_hostvars(
            self, mock_get_server_external_ipv4,
            mock_get_server_external_ipv6):
        mock_get_server_external_ipv4.return_value = PUBLIC_V4
        mock_get_server_external_ipv6.return_value = PUBLIC_V6

        hostvars = meta.get_hostvars_from_server(
            FakeCloud(), self.cloud._normalize_server(
                meta.obj_to_munch(standard_fake_server)))
        self.assertNotIn('links', hostvars)
        self.assertEqual(PRIVATE_V4, hostvars['private_v4'])
        self.assertEqual(PUBLIC_V4, hostvars['public_v4'])
        self.assertEqual(PUBLIC_V6, hostvars['public_v6'])
        self.assertEqual(PUBLIC_V6, hostvars['interface_ip'])
        self.assertEqual('RegionOne', hostvars['region'])
        self.assertEqual('_test_cloud_', hostvars['cloud'])
        self.assertIn('location', hostvars)
        self.assertEqual('_test_cloud_', hostvars['location']['cloud'])
        self.assertEqual('RegionOne', hostvars['location']['region_name'])
        self.assertEqual('admin', hostvars['location']['project']['name'])
        self.assertEqual("test-image-name", hostvars['image']['name'])
        self.assertEqual(
            standard_fake_server['image']['id'], hostvars['image']['id'])
        self.assertNotIn('links', hostvars['image'])
        self.assertEqual(
            standard_fake_server['flavor']['id'], hostvars['flavor']['id'])
        self.assertEqual("test-flavor-name", hostvars['flavor']['name'])
        self.assertNotIn('links', hostvars['flavor'])
        # test having volumes
        # test volume exception
        self.assertEqual([], hostvars['volumes'])
开发者ID:dbckz,项目名称:shade,代码行数:31,代码来源:test_meta.py

示例5: test_basic_hostvars

    def test_basic_hostvars(
            self, mock_get_server_external_ipv4,
            mock_get_server_external_ipv6):
        mock_get_server_external_ipv4.return_value = PUBLIC_V4
        mock_get_server_external_ipv6.return_value = PUBLIC_V6

        hostvars = meta.get_hostvars_from_server(
            FakeCloud(), _utils.normalize_server(
                meta.obj_to_dict(FakeServer()),
                cloud_name='CLOUD_NAME',
                region_name='REGION_NAME'))
        self.assertNotIn('links', hostvars)
        self.assertEqual(PRIVATE_V4, hostvars['private_v4'])
        self.assertEqual(PUBLIC_V4, hostvars['public_v4'])
        self.assertEqual(PUBLIC_V6, hostvars['public_v6'])
        self.assertEqual(PUBLIC_V6, hostvars['interface_ip'])
        self.assertEquals('REGION_NAME', hostvars['region'])
        self.assertEquals('CLOUD_NAME', hostvars['cloud'])
        self.assertEquals("test-image-name", hostvars['image']['name'])
        self.assertEquals(FakeServer.image['id'], hostvars['image']['id'])
        self.assertNotIn('links', hostvars['image'])
        self.assertEquals(FakeServer.flavor['id'], hostvars['flavor']['id'])
        self.assertEquals("test-flavor-name", hostvars['flavor']['name'])
        self.assertNotIn('links', hostvars['flavor'])
        # test having volumes
        # test volume exception
        self.assertEquals([], hostvars['volumes'])
开发者ID:insequent,项目名称:shade,代码行数:27,代码来源:test_meta.py

示例6: test_private_interface_ip

    def test_private_interface_ip(self, mock_get_server_external_ipv4):
        mock_get_server_external_ipv4.return_value = PUBLIC_V4

        cloud = FakeCloud()
        cloud.private = True
        hostvars = meta.get_hostvars_from_server(cloud, meta.obj_to_dict(FakeServer()))
        self.assertEqual(PRIVATE_V4, hostvars["interface_ip"])
开发者ID:vaibhavmital,项目名称:shade,代码行数:7,代码来源:test_meta.py

示例7: test_image_string

    def test_image_string(self, mock_get_server_external_ipv4):
        mock_get_server_external_ipv4.return_value = PUBLIC_V4

        server = standard_fake_server
        server.image = 'fake-image-id'
        hostvars = meta.get_hostvars_from_server(
            FakeCloud(), meta.obj_to_dict(server))
        self.assertEquals('fake-image-id', hostvars['image']['id'])
开发者ID:LIP-Computing,项目名称:shade,代码行数:8,代码来源:test_meta.py

示例8: test_private_interface_ip

    def test_private_interface_ip(self, mock_get_server_external_ipv4):
        mock_get_server_external_ipv4.return_value = PUBLIC_V4

        cloud = FakeCloud()
        cloud.private = True
        hostvars = meta.get_hostvars_from_server(
            cloud, meta.obj_to_munch(standard_fake_server))
        self.assertEqual(PRIVATE_V4, hostvars['interface_ip'])
开发者ID:dbckz,项目名称:shade,代码行数:8,代码来源:test_meta.py

示例9: test_has_no_volume_service

    def test_has_no_volume_service(self):
        mock_cloud = mock.MagicMock()

        def side_effect(*args):
            raise exc.OpenStackCloudException("No Volumes")
        mock_cloud.get_volumes.side_effect = side_effect
        hostvars = meta.get_hostvars_from_server(mock_cloud, FakeServer())
        self.assertEquals([], hostvars['volumes'])
开发者ID:emonty,项目名称:shade,代码行数:8,代码来源:test_meta.py

示例10: test_ipv4_hostvars

    def test_ipv4_hostvars(
            self, mock_get_server_external_ipv4,
            mock_get_server_external_ipv6):
        mock_get_server_external_ipv4.return_value = PUBLIC_V4
        mock_get_server_external_ipv6.return_value = PUBLIC_V6

        fake_cloud = FakeCloud()
        fake_cloud.force_ipv4 = True
        hostvars = meta.get_hostvars_from_server(
            fake_cloud, meta.obj_to_dict(FakeServer()))
        self.assertEqual(PUBLIC_V4, hostvars['interface_ip'])
开发者ID:insequent,项目名称:shade,代码行数:11,代码来源:test_meta.py

示例11: test_has_volume

 def test_has_volume(self):
     mock_cloud = mock.MagicMock()
     mock_volume = mock.MagicMock()
     mock_volume.id = "volume1"
     mock_volume.status = "available"
     mock_volume.display_name = "Volume 1 Display Name"
     mock_volume.attachments = [{"device": "/dev/sda0"}]
     mock_volume_dict = meta.obj_to_dict(mock_volume)
     mock_cloud.get_volumes.return_value = [mock_volume_dict]
     hostvars = meta.get_hostvars_from_server(mock_cloud, meta.obj_to_dict(FakeServer()))
     self.assertEquals("volume1", hostvars["volumes"][0]["id"])
     self.assertEquals("/dev/sda0", hostvars["volumes"][0]["device"])
开发者ID:vaibhavmital,项目名称:shade,代码行数:12,代码来源:test_meta.py

示例12: test_has_volume

 def test_has_volume(self):
     mock_cloud = mock.MagicMock()
     mock_volume = mock.MagicMock()
     mock_volume.id = 'volume1'
     mock_volume.status = 'available'
     mock_volume.display_name = 'Volume 1 Display Name'
     mock_volume.attachments = [{'device': '/dev/sda0'}]
     mock_volume_dict = meta.obj_to_dict(mock_volume)
     mock_cloud.get_volumes.return_value = [mock_volume_dict]
     hostvars = meta.get_hostvars_from_server(mock_cloud, FakeServer())
     self.assertEquals('volume1', hostvars['volumes'][0]['id'])
     self.assertEquals('/dev/sda0', hostvars['volumes'][0]['device'])
开发者ID:emonty,项目名称:shade,代码行数:12,代码来源:test_meta.py

示例13: test_has_volume

    def test_has_volume(self):
        mock_cloud = mock.MagicMock()

        fake_volume = fakes.FakeVolume(
            id='volume1',
            status='available',
            name='Volume 1 Display Name',
            attachments=[{'device': '/dev/sda0'}])
        fake_volume_dict = meta.obj_to_dict(fake_volume)
        mock_cloud.get_volumes.return_value = [fake_volume_dict]
        hostvars = meta.get_hostvars_from_server(
            mock_cloud, meta.obj_to_dict(standard_fake_server))
        self.assertEquals('volume1', hostvars['volumes'][0]['id'])
        self.assertEquals('/dev/sda0', hostvars['volumes'][0]['device'])
开发者ID:LIP-Computing,项目名称:shade,代码行数:14,代码来源:test_meta.py

示例14: test_get_security_groups

    def test_get_security_groups(self,
                                 mock_list_server_security_groups):
        '''This test verifies that calling get_hostvars_froms_server
        ultimately calls list_server_security_groups, and that the return
        value from list_server_security_groups ends up in
        server['security_groups'].'''
        mock_list_server_security_groups.return_value = [
            {'name': 'testgroup', 'id': '1'}]

        server = meta.obj_to_dict(FakeServer())
        hostvars = meta.get_hostvars_from_server(FakeCloud(), server)

        mock_list_server_security_groups.assert_called_once_with(server)
        self.assertEqual('testgroup',
                         hostvars['security_groups'][0]['name'])
开发者ID:insequent,项目名称:shade,代码行数:15,代码来源:test_meta.py

示例15: test_basic_hostvars

 def test_basic_hostvars(self):
     hostvars = meta.get_hostvars_from_server(FakeCloud(), FakeServer())
     self.assertNotIn('links', hostvars)
     self.assertEqual(PRIVATE_V4, hostvars['private_v4'])
     self.assertEqual(PUBLIC_V4, hostvars['public_v4'])
     self.assertEqual(PUBLIC_V4, hostvars['interface_ip'])
     self.assertEquals(FakeCloud.region_name, hostvars['region'])
     self.assertEquals(FakeCloud.name, hostvars['cloud'])
     self.assertEquals("test-image-name", hostvars['image']['name'])
     self.assertEquals(FakeServer.image['id'], hostvars['image']['id'])
     self.assertNotIn('links', hostvars['image'])
     self.assertEquals(FakeServer.flavor['id'], hostvars['flavor']['id'])
     self.assertEquals("test-flavor-name", hostvars['flavor']['name'])
     self.assertNotIn('links', hostvars['flavor'])
     # test having volumes
     # test volume exception
     self.assertEquals([], hostvars['volumes'])
开发者ID:emonty,项目名称:shade,代码行数:17,代码来源:test_meta.py


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