diff --git a/doc/api_samples/OS-SRV-USG/server-get-resp.json b/doc/api_samples/OS-SRV-USG/server-get-resp.json deleted file mode 100644 index ffb03ebc68bf..000000000000 --- a/doc/api_samples/OS-SRV-USG/server-get-resp.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "server": { - "OS-SRV-USG:launched_at": "2013-05-02T19:26:38.326387", - "OS-SRV-USG:terminated_at": null, - "accessIPv4": "", - "accessIPv6": "", - "addresses": { - "private": [ - { - "addr": "192.168.0.3", - "version": 4 - } - ] - }, - "created": "2013-05-02T19:26:37Z", - "flavor": { - "id": "1", - "links": [ - { - "href": "http://openstack.example.com/openstack/flavors/1", - "rel": "bookmark" - } - ] - }, - "hostId": "1127931217d16e2c8b1e1ec54de06f17805bfaadc0d36525879450d1", - "id": "cbdfb561-b94b-4b98-bb22-7d62575114b1", - "image": { - "id": "70a599e0-31e7-49b7-b260-868f441e862b", - "links": [ - { - "href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", - "rel": "bookmark" - } - ] - }, - "links": [ - { - "href": "http://openstack.example.com/v2/openstack/servers/cbdfb561-b94b-4b98-bb22-7d62575114b1", - "rel": "self" - }, - { - "href": "http://openstack.example.com/openstack/servers/cbdfb561-b94b-4b98-bb22-7d62575114b1", - "rel": "bookmark" - } - ], - "metadata": { - "My Server Name": "Apache1" - }, - "name": "new-server-test", - "progress": 0, - "status": "ACTIVE", - "tenant_id": "openstack", - "updated": "2013-05-02T19:26:38Z", - "user_id": "fake" - } -} \ No newline at end of file diff --git a/doc/api_samples/OS-SRV-USG/servers-detail-resp.json b/doc/api_samples/OS-SRV-USG/servers-detail-resp.json deleted file mode 100644 index 183a8c92e0ff..000000000000 --- a/doc/api_samples/OS-SRV-USG/servers-detail-resp.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "servers": [ - { - "OS-SRV-USG:launched_at": "2013-05-02T19:26:45.066375", - "OS-SRV-USG:terminated_at": null, - "accessIPv4": "", - "accessIPv6": "", - "addresses": { - "private": [ - { - "addr": "192.168.0.3", - "version": 4 - } - ] - }, - "created": "2013-05-02T19:26:44Z", - "flavor": { - "id": "1", - "links": [ - { - "href": "http://openstack.example.com/openstack/flavors/1", - "rel": "bookmark" - } - ] - }, - "hostId": "15ac731a430372d42a333d9d316ff2af70e0bf5eee523a0bc43779f5", - "id": "fe828a86-aad7-464b-8995-280bedf4fa9b", - "image": { - "id": "70a599e0-31e7-49b7-b260-868f441e862b", - "links": [ - { - "href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", - "rel": "bookmark" - } - ] - }, - "links": [ - { - "href": "http://openstack.example.com/v2/openstack/servers/fe828a86-aad7-464b-8995-280bedf4fa9b", - "rel": "self" - }, - { - "href": "http://openstack.example.com/openstack/servers/fe828a86-aad7-464b-8995-280bedf4fa9b", - "rel": "bookmark" - } - ], - "metadata": { - "My Server Name": "Apache1" - }, - "name": "new-server-test", - "progress": 0, - "status": "ACTIVE", - "tenant_id": "openstack", - "updated": "2013-05-02T19:26:45Z", - "user_id": "fake" - } - ] -} \ No newline at end of file diff --git a/doc/v3/api_samples/os-server-usage/server-get-resp.json b/doc/v3/api_samples/os-server-usage/server-get-resp.json index 78cda7482bb9..ea59cb496ae5 100644 --- a/doc/v3/api_samples/os-server-usage/server-get-resp.json +++ b/doc/v3/api_samples/os-server-usage/server-get-resp.json @@ -1,5 +1,7 @@ { "server": { + "accessIPv4": "1.2.3.4", + "accessIPv6": "80fe::", "addresses": { "private": [ { @@ -15,7 +17,7 @@ "id": "1", "links": [ { - "href": "http://openstack.example.com/flavors/1", + "href": "http://openstack.example.com/openstack/flavors/1", "rel": "bookmark" } ] @@ -26,7 +28,7 @@ "id": "70a599e0-31e7-49b7-b260-868f441e862b", "links": [ { - "href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b", + "href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", "rel": "bookmark" } ] @@ -34,11 +36,11 @@ "key_name": null, "links": [ { - "href": "http://openstack.example.com/v3/servers/cee6d136-e378-4cfc-9eec-71797f025991", + "href": "http://openstack.example.com/v2/openstack/servers/cee6d136-e378-4cfc-9eec-71797f025991", "rel": "self" }, { - "href": "http://openstack.example.com/servers/cee6d136-e378-4cfc-9eec-71797f025991", + "href": "http://openstack.example.com/openstack/servers/cee6d136-e378-4cfc-9eec-71797f025991", "rel": "bookmark" } ], diff --git a/doc/v3/api_samples/os-server-usage/servers-detail-resp.json b/doc/v3/api_samples/os-server-usage/servers-detail-resp.json index 1346f3350bad..d0f0d5d26aef 100644 --- a/doc/v3/api_samples/os-server-usage/servers-detail-resp.json +++ b/doc/v3/api_samples/os-server-usage/servers-detail-resp.json @@ -1,6 +1,8 @@ { "servers": [ { + "accessIPv4": "1.2.3.4", + "accessIPv6": "80fe::", "addresses": { "private": [ { @@ -16,7 +18,7 @@ "id": "1", "links": [ { - "href": "http://openstack.example.com/flavors/1", + "href": "http://openstack.example.com/openstack/flavors/1", "rel": "bookmark" } ] @@ -27,7 +29,7 @@ "id": "70a599e0-31e7-49b7-b260-868f441e862b", "links": [ { - "href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b", + "href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", "rel": "bookmark" } ] @@ -35,11 +37,11 @@ "key_name": null, "links": [ { - "href": "http://openstack.example.com/v3/servers/ae114799-9164-48f5-a036-6ef9310acbc4", + "href": "http://openstack.example.com/v2/openstack/servers/ae114799-9164-48f5-a036-6ef9310acbc4", "rel": "self" }, { - "href": "http://openstack.example.com/servers/ae114799-9164-48f5-a036-6ef9310acbc4", + "href": "http://openstack.example.com/openstack/servers/ae114799-9164-48f5-a036-6ef9310acbc4", "rel": "bookmark" } ], diff --git a/nova/tests/functional/api_samples/OS-SRV-USG/server-get-resp.json.tpl b/nova/tests/functional/api_samples/OS-SRV-USG/server-get-resp.json.tpl deleted file mode 100644 index 2b2121d34bc6..000000000000 --- a/nova/tests/functional/api_samples/OS-SRV-USG/server-get-resp.json.tpl +++ /dev/null @@ -1,56 +0,0 @@ -{ - "server": { - "OS-SRV-USG:launched_at": "%(strtime)s", - "OS-SRV-USG:terminated_at": null, - "accessIPv4": "", - "accessIPv6": "", - "addresses": { - "private": [ - { - "addr": "%(ip)s", - "version": 4 - } - ] - }, - "created": "%(isotime)s", - "flavor": { - "id": "1", - "links": [ - { - "href": "%(host)s/openstack/flavors/1", - "rel": "bookmark" - } - ] - }, - "hostId": "%(hostid)s", - "id": "%(id)s", - "image": { - "id": "%(uuid)s", - "links": [ - { - "href": "%(host)s/openstack/images/%(uuid)s", - "rel": "bookmark" - } - ] - }, - "links": [ - { - "href": "%(host)s/v2/openstack/servers/%(uuid)s", - "rel": "self" - }, - { - "href": "%(host)s/openstack/servers/%(uuid)s", - "rel": "bookmark" - } - ], - "metadata": { - "My Server Name": "Apache1" - }, - "name": "new-server-test", - "progress": 0, - "status": "ACTIVE", - "tenant_id": "openstack", - "updated": "%(isotime)s", - "user_id": "fake" - } -} diff --git a/nova/tests/functional/api_samples/OS-SRV-USG/servers-detail-resp.json.tpl b/nova/tests/functional/api_samples/OS-SRV-USG/servers-detail-resp.json.tpl deleted file mode 100644 index bef5a2002afa..000000000000 --- a/nova/tests/functional/api_samples/OS-SRV-USG/servers-detail-resp.json.tpl +++ /dev/null @@ -1,57 +0,0 @@ -{ - "servers": [ - { - "status": "ACTIVE", - "updated": "%(isotime)s", - "OS-SRV-USG:launched_at": "%(strtime)s", - "user_id": "fake", - "addresses": { - "private": [ - { - "addr": "%(ip)s", - "version": 4 - } - ] - }, - "links": [ - { - "href": "%(host)s/v2/openstack/servers/%(uuid)s", - "rel": "self" - }, - { - "href": "%(host)s/openstack/servers/%(uuid)s", - "rel": "bookmark" - } - ], - "created": "%(isotime)s", - "name": "new-server-test", - "image": { - "id": "%(uuid)s", - "links": [ - { - "href": "%(host)s/openstack/images/%(uuid)s", - "rel": "bookmark" - } - ] - }, - "id": "%(uuid)s", - "accessIPv4": "", - "accessIPv6": "", - "OS-SRV-USG:terminated_at": null, - "tenant_id": "openstack", - "progress": 0, - "flavor": { - "id": "1", - "links": [ - { - "href": "%(host)s/openstack/flavors/1", - "rel": "bookmark" - } - ] - }, - "hostId": "%(hostid)s", - "metadata": { - "My Server Name": "Apache1" - } - }] -} diff --git a/nova/tests/functional/test_api_samples.py b/nova/tests/functional/test_api_samples.py index ffa177b288f3..16e6f6a4c4ab 100644 --- a/nova/tests/functional/test_api_samples.py +++ b/nova/tests/functional/test_api_samples.py @@ -1165,26 +1165,6 @@ class ExtendedVolumesSampleJsonTests(ServersSampleBase): self._verify_response('servers-detail-resp', subs, response, 200) -class ServerUsageSampleJsonTests(ServersSampleBase): - extension_name = ("nova.api.openstack.compute.contrib" - ".server_usage.Server_usage") - - def test_show(self): - uuid = self._post_server() - response = self._do_get('servers/%s' % uuid) - subs = self._get_regexes() - subs['hostid'] = '[a-f0-9]+' - return self._verify_response('server-get-resp', subs, response, 200) - - def test_detail(self): - self._post_server() - response = self._do_get('servers/detail') - subs = self._get_regexes() - subs['hostid'] = '[a-f0-9]+' - return self._verify_response('servers-detail-resp', subs, - response, 200) - - class ExtendedVIFNetSampleJsonTests(ServersSampleBase): extension_name = ("nova.api.openstack.compute.contrib" ".extended_virtual_interfaces_net.Extended_virtual_interfaces_net") diff --git a/nova/tests/functional/v3/api_samples/os-server-usage/server-get-resp.json.tpl b/nova/tests/functional/v3/api_samples/os-server-usage/server-get-resp.json.tpl index 90e75947e59f..3d3c43f4065a 100644 --- a/nova/tests/functional/v3/api_samples/os-server-usage/server-get-resp.json.tpl +++ b/nova/tests/functional/v3/api_samples/os-server-usage/server-get-resp.json.tpl @@ -1,5 +1,7 @@ { "server": { + "accessIPv4": "%(access_ip_v4)s", + "accessIPv6": "%(access_ip_v6)s", "OS-SRV-USG:launched_at": "%(strtime)s", "OS-SRV-USG:terminated_at": null, "addresses": { @@ -17,7 +19,7 @@ "id": "1", "links": [ { - "href": "%(host)s/flavors/1", + "href": "%(host)s/openstack/flavors/1", "rel": "bookmark" } ] @@ -28,7 +30,7 @@ "id": "%(uuid)s", "links": [ { - "href": "%(host)s/images/%(uuid)s", + "href": "%(host)s/openstack/images/%(uuid)s", "rel": "bookmark" } ] @@ -36,11 +38,11 @@ "key_name": null, "links": [ { - "href": "%(host)s/v3/servers/%(uuid)s", + "href": "%(host)s/v2/openstack/servers/%(uuid)s", "rel": "self" }, { - "href": "%(host)s/servers/%(uuid)s", + "href": "%(host)s/openstack/servers/%(uuid)s", "rel": "bookmark" } ], diff --git a/nova/tests/functional/v3/api_samples/os-server-usage/servers-detail-resp.json.tpl b/nova/tests/functional/v3/api_samples/os-server-usage/servers-detail-resp.json.tpl index ae20daabf751..e1d8fada9589 100644 --- a/nova/tests/functional/v3/api_samples/os-server-usage/servers-detail-resp.json.tpl +++ b/nova/tests/functional/v3/api_samples/os-server-usage/servers-detail-resp.json.tpl @@ -1,6 +1,8 @@ { "servers": [ { + "accessIPv4": "%(access_ip_v4)s", + "accessIPv6": "%(access_ip_v6)s", "status": "ACTIVE", "created": "%(isotime)s", "OS-SRV-USG:launched_at": "%(strtime)s", @@ -18,11 +20,11 @@ "key_name": null, "links": [ { - "href": "%(host)s/v3/servers/%(uuid)s", + "href": "%(host)s/v2/openstack/servers/%(uuid)s", "rel": "self" }, { - "href": "%(host)s/servers/%(id)s", + "href": "%(host)s/openstack/servers/%(id)s", "rel": "bookmark" } ], @@ -32,7 +34,7 @@ "id": "%(uuid)s", "links": [ { - "href": "%(host)s/images/%(uuid)s", + "href": "%(host)s/openstack/images/%(uuid)s", "rel": "bookmark" } ] @@ -45,7 +47,7 @@ "id": "1", "links": [ { - "href": "%(host)s/flavors/1", + "href": "%(host)s/openstack/flavors/1", "rel": "bookmark" } ] diff --git a/nova/tests/functional/v3/test_server_usage.py b/nova/tests/functional/v3/test_server_usage.py index 26e9f2b31ddd..56d0d9dffe12 100644 --- a/nova/tests/functional/v3/test_server_usage.py +++ b/nova/tests/functional/v3/test_server_usage.py @@ -13,11 +13,33 @@ # License for the specific language governing permissions and limitations # under the License. +from oslo_config import cfg + from nova.tests.functional.v3 import test_servers +CONF = cfg.CONF +CONF.import_opt('osapi_compute_extension', + 'nova.api.openstack.compute.extensions') + class ServerUsageSampleJsonTest(test_servers.ServersSampleBase): extension_name = 'os-server-usage' + extra_extensions_to_load = ["os-access-ips"] + _api_version = 'v2' + + def _get_flags(self): + f = super(ServerUsageSampleJsonTest, self)._get_flags() + f['osapi_compute_extension'] = CONF.osapi_compute_extension[:] + f['osapi_compute_extension'].append( + 'nova.api.openstack.compute.contrib.server_usage.Server_usage') + f['osapi_compute_extension'].append( + 'nova.api.openstack.compute.contrib.keypairs.Keypairs') + f['osapi_compute_extension'].append( + 'nova.api.openstack.compute.contrib.extended_ips.Extended_ips') + f['osapi_compute_extension'].append( + 'nova.api.openstack.compute.contrib.extended_ips_mac.' + 'Extended_ips_mac') + return f def setUp(self): """setUp method for server usage.""" @@ -29,6 +51,8 @@ class ServerUsageSampleJsonTest(test_servers.ServersSampleBase): subs = self._get_regexes() subs['id'] = self.uuid subs['hostid'] = '[a-f0-9]+' + subs['access_ip_v4'] = '1.2.3.4' + subs['access_ip_v6'] = '80fe::' self._verify_response('server-get-resp', subs, response, 200) def test_details(self): @@ -36,4 +60,6 @@ class ServerUsageSampleJsonTest(test_servers.ServersSampleBase): subs = self._get_regexes() subs['id'] = self.uuid subs['hostid'] = '[a-f0-9]+' + subs['access_ip_v4'] = '1.2.3.4' + subs['access_ip_v6'] = '80fe::' self._verify_response('servers-detail-resp', subs, response, 200)