Expose OS-EXT-SRV-ATTR:{hypervisor_hostname,instance_name} for Server.
This patch exposes these properties for the openstack.compute.v2.Server class, making them available for inspection. Change-Id: I4958450e9853ad52e817da382907517dc3b46e6a
This commit is contained in:
parent
528e6d93b4
commit
d37805e18f
|
@ -130,6 +130,13 @@ class Server(resource2.Resource, metadata.MetadataMixin):
|
|||
#: networks parameter, the server attaches to the only network
|
||||
#: created for the current tenant.
|
||||
networks = resource2.Body('networks')
|
||||
#: The hypervisor host name. Appears in the response for administrative
|
||||
#: users only.
|
||||
hypervisor_hostname = resource2.Body('OS-EXT-SRV-ATTR:hypervisor_hostname')
|
||||
#: The instance name. The Compute API generates the instance name from the
|
||||
#: instance name template. Appears in the response for administrative users
|
||||
#: only.
|
||||
instance_name = resource2.Body('OS-EXT-SRV-ATTR:instance_name')
|
||||
|
||||
def _action(self, session, body):
|
||||
"""Preform server actions given the message body."""
|
||||
|
|
|
@ -51,7 +51,9 @@ EXAMPLE = {
|
|||
'personality': '28',
|
||||
'block_device_mapping_v2': {'key': '29'},
|
||||
'os:scheduler_hints': {'key': '30'},
|
||||
'user_data': '31'
|
||||
'user_data': '31',
|
||||
'OS-EXT-SRV-ATTR:hypervisor_hostname': 'hypervisor.example.com',
|
||||
'OS-EXT-SRV-ATTR:instance_name': 'instance-00000001'
|
||||
}
|
||||
|
||||
|
||||
|
@ -140,6 +142,10 @@ class TestServer(testtools.TestCase):
|
|||
sot.block_device_mapping)
|
||||
self.assertEqual(EXAMPLE['os:scheduler_hints'], sot.scheduler_hints)
|
||||
self.assertEqual(EXAMPLE['user_data'], sot.user_data)
|
||||
self.assertEqual(EXAMPLE['OS-EXT-SRV-ATTR:hypervisor_hostname'],
|
||||
sot.hypervisor_hostname)
|
||||
self.assertEqual(EXAMPLE['OS-EXT-SRV-ATTR:instance_name'],
|
||||
sot.instance_name)
|
||||
|
||||
def test_detail(self):
|
||||
sot = server.ServerDetail()
|
||||
|
|
Loading…
Reference in New Issue