本文整理汇总了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函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_basic_hostvars
def test_basic_hostvars(self, mock_get_server_external_ipv4):
mock_get_server_external_ipv4.return_value = PUBLIC_V4
hostvars = meta.get_hostvars_from_server(FakeCloud(), meta.obj_to_dict(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:vaibhavmital,项目名称:shade,代码行数:19,代码来源:test_meta.py
示例17: main
def main():
argument_spec = openstack_full_argument_spec(
server=dict(required=True),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec, **module_kwargs)
if not HAS_SHADE:
module.fail_json(msg='shade is required for this module')
try:
cloud = shade.openstack_cloud(**module.params)
server = cloud.get_server(module.params['server'])
hostvars = dict(openstack=meta.get_hostvars_from_server(
cloud, server))
module.exit_json(changed=False, ansible_facts=hostvars)
except shade.OpenStackCloudException as e:
module.fail_json(msg=e.message)
开发者ID:victron,项目名称:paramiko_ssh-i,代码行数:20,代码来源:os_server_facts.py
示例18: _exit_hostvars
def _exit_hostvars(module, cloud, server, changed=True):
hostvars = meta.get_hostvars_from_server(cloud, server)
module.exit_json(
changed=changed, server=server, id=server.id, openstack=hostvars)
开发者ID:mpryc,项目名称:InfraRed,代码行数:4,代码来源:os_server.py
示例19: main
def main():
argument_spec = openstack_full_argument_spec(
server=dict(required=True),
volume=dict(required=True),
device=dict(default=None), # None == auto choose device name
state=dict(default='present', choices=['absent', 'present']),
)
module_kwargs = openstack_module_kwargs()
module = AnsibleModule(argument_spec,
supports_check_mode=True,
**module_kwargs)
if not HAS_SHADE:
module.fail_json(msg='shade is required for this module')
state = module.params['state']
wait = module.params['wait']
timeout = module.params['timeout']
try:
cloud = shade.openstack_cloud(**module.params)
server = cloud.get_server(module.params['server'])
volume = cloud.get_volume(module.params['volume'])
dev = cloud.get_volume_attach_device(volume, server.id)
if module.check_mode:
module.exit_json(changed=_system_state_change(state, dev))
if state == 'present':
if dev:
# Volume is already attached to this server
module.exit_json(changed=False)
cloud.attach_volume(server, volume, module.params['device'],
wait=wait, timeout=timeout)
server = cloud.get_server(module.params['server']) # refresh
volume = cloud.get_volume(module.params['volume']) # refresh
hostvars = meta.get_hostvars_from_server(cloud, server)
module.exit_json(
changed=True,
id=volume['id'],
attachments=volume['attachments'],
openstack=hostvars
)
elif state == 'absent':
if not dev:
# Volume is not attached to this server
module.exit_json(changed=False)
cloud.detach_volume(server, volume, wait=wait, timeout=timeout)
module.exit_json(
changed=True,
result='Detached volume from server'
)
except (shade.OpenStackCloudException, shade.OpenStackCloudTimeout) as e:
module.fail_json(msg=e.message)
开发者ID:abriening,项目名称:ansible-modules-core,代码行数:61,代码来源:os_server_volume.py
示例20: test_has_no_volume_service
def test_has_no_volume_service(self):
fake_cloud = FakeCloud()
fake_cloud.service_val = False
hostvars = meta.get_hostvars_from_server(
fake_cloud, meta.obj_to_dict(FakeServer()))
self.assertEquals([], hostvars['volumes'])
开发者ID:insequent,项目名称:shade,代码行数:6,代码来源:test_meta.py
注:本文中的shade.meta.get_hostvars_from_server函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论