diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-08-24 21:37:18 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-08-24 21:37:18 +0000 |
| commit | e2804797dc5eaa619d38e5d7f96d5baa8eaaf467 (patch) | |
| tree | 59858872070b57493a0e9e2f1831d14089fc25f8 | |
| parent | c1e9f5ec2b017f9e58110f2662963537edae2ccc (diff) | |
| parent | ad087405f1874259f9ac9ce34402ab3c6458a411 (diff) | |
| download | nova-e2804797dc5eaa619d38e5d7f96d5baa8eaaf467.tar.gz nova-e2804797dc5eaa619d38e5d7f96d5baa8eaaf467.tar.xz nova-e2804797dc5eaa619d38e5d7f96d5baa8eaaf467.zip | |
Merge "Returns hypervisor_hostname in xml of extension"
4 files changed, 13 insertions, 3 deletions
diff --git a/nova/api/openstack/compute/contrib/extended_server_attributes.py b/nova/api/openstack/compute/contrib/extended_server_attributes.py index f1ec9b956..6ca10559f 100644 --- a/nova/api/openstack/compute/contrib/extended_server_attributes.py +++ b/nova/api/openstack/compute/contrib/extended_server_attributes.py @@ -102,6 +102,8 @@ def make_server(elem): '%s:instance_name' % Extended_server_attributes.alias) elem.set('{%s}host' % Extended_server_attributes.namespace, '%s:host' % Extended_server_attributes.alias) + elem.set('{%s}hypervisor_hostname' % Extended_server_attributes.namespace, + '%s:hypervisor_hostname' % Extended_server_attributes.alias) class ExtendedServerAttributeTemplate(xmlutil.TemplateBuilder): diff --git a/nova/tests/api/openstack/compute/contrib/test_extended_server_attributes.py b/nova/tests/api/openstack/compute/contrib/test_extended_server_attributes.py index d50749060..66a2ac5db 100644 --- a/nova/tests/api/openstack/compute/contrib/test_extended_server_attributes.py +++ b/nova/tests/api/openstack/compute/contrib/test_extended_server_attributes.py @@ -18,6 +18,7 @@ import webob from nova.api.openstack.compute.contrib import extended_server_attributes from nova import compute +from nova import db from nova import exception from nova import flags from nova.openstack.common import jsonutils @@ -44,6 +45,10 @@ def fake_compute_get_all(*args, **kwargs): ] +def fake_cn_get(context, host): + return {"hypervisor_hostname": host} + + class ExtendedServerAttributesTest(test.TestCase): content_type = 'application/json' prefix = 'OS-EXT-SRV-ATTR:' @@ -53,6 +58,7 @@ class ExtendedServerAttributesTest(test.TestCase): fakes.stub_out_nw_api(self.stubs) self.stubs.Set(compute.api.API, 'get', fake_compute_get) self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all) + self.stubs.Set(db, 'compute_node_get_by_host', fake_cn_get) def _make_request(self, url): req = webob.Request.blank(url) @@ -70,6 +76,8 @@ class ExtendedServerAttributesTest(test.TestCase): self.assertEqual(server.get('%shost' % self.prefix), host) self.assertEqual(server.get('%sinstance_name' % self.prefix), instance_name) + self.assertEqual(server.get('%shypervisor_hostname' % self.prefix), + host) def test_show(self): url = '/v2/fake/servers/%s' % UUID3 diff --git a/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml b/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml index d5adf7806..3441eedcd 100644 --- a/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml +++ b/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml @@ -1,5 +1,5 @@ <?xml version='1.0' encoding='UTF-8'?> -<server xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:OS-EXT-SRV-ATTR="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" status="ACTIVE" updated="2012-08-20T21:11:08Z" hostId="96727264c2742d842c80c182cd505afa6108eb16305773070f893e23" name="new-server-test" created="2012-08-20T21:11:08Z" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="2c7a2ff8-63ce-4dcb-a3fa-1c311fe9fb04" config_drive="" key_name="None" OS-EXT-SRV-ATTR:instance_name="instance-00000001" OS-EXT-SRV-ATTR:host="6d7bdd9082cd4294aae7804dc0e5f214" OS-DCF:diskConfig="AUTO" OS-EXT-SRV-ATTR:vm_state="active" OS-EXT-SRV-ATTR:task_state="None" OS-EXT-SRV-ATTR:power_state="1"> +<server xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:OS-EXT-SRV-ATTR="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" status="ACTIVE" updated="2012-08-20T21:11:08Z" hostId="96727264c2742d842c80c182cd505afa6108eb16305773070f893e23" name="new-server-test" created="2012-08-20T21:11:08Z" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="2c7a2ff8-63ce-4dcb-a3fa-1c311fe9fb04" config_drive="" key_name="None" OS-EXT-SRV-ATTR:instance_name="instance-00000001" OS-EXT-SRV-ATTR:host="6d7bdd9082cd4294aae7804dc0e5f214" OS-EXT-SRV-ATTR:hypervisor_hostname="" OS-DCF:diskConfig="AUTO" OS-EXT-SRV-ATTR:vm_state="active" OS-EXT-SRV-ATTR:task_state="None" OS-EXT-SRV-ATTR:power_state="1"> <image id="70a599e0-31e7-49b7-b260-868f441e862b"> <atom:link href="http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b" rel="bookmark"/> </image> @@ -19,4 +19,4 @@ <security_groups> <security_group name="default"/> </security_groups> -</server>
\ No newline at end of file +</server> diff --git a/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml.tpl b/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml.tpl index 6c73bf60f..585492ffe 100644 --- a/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml.tpl +++ b/nova/tests/integrated/api_samples/all_extensions/server-get-resp.xml.tpl @@ -1,5 +1,5 @@ <?xml version='1.0' encoding='UTF-8'?> -<server xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:OS-EXT-SRV-ATTR="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" status="ACTIVE" updated="%(timestamp)s" hostId="%(hostid)s" name="new-server-test" created="%(timestamp)s" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="%(id)s" config_drive="" key_name="None" OS-EXT-SRV-ATTR:instance_name="instance-00000001" OS-EXT-SRV-ATTR:host="%(compute_host)s" OS-DCF:diskConfig="AUTO" OS-EXT-SRV-ATTR:vm_state="active" OS-EXT-SRV-ATTR:task_state="None" OS-EXT-SRV-ATTR:power_state="1"> +<server xmlns:OS-DCF="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:OS-EXT-SRV-ATTR="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:OS-EXT-STS="http://docs.openstack.org/compute/ext/extended_status/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1" status="ACTIVE" updated="%(timestamp)s" hostId="%(hostid)s" name="new-server-test" created="%(timestamp)s" userId="fake" tenantId="openstack" accessIPv4="" accessIPv6="" progress="0" id="%(id)s" config_drive="" key_name="None" OS-EXT-SRV-ATTR:instance_name="instance-00000001" OS-EXT-SRV-ATTR:host="%(compute_host)s" OS-EXT-SRV-ATTR:hypervisor_hostname="None" OS-DCF:diskConfig="AUTO" OS-EXT-SRV-ATTR:vm_state="active" OS-EXT-SRV-ATTR:task_state="None" OS-EXT-SRV-ATTR:power_state="1"> <image id="%(uuid)s"> <atom:link href="%(host)s/openstack/images/%(uuid)s" rel="bookmark"/> </image> |
