From d74ad18520e5b17b19e76110aee24e1264793289 Mon Sep 17 00:00:00 2001 From: Adalberto Medeiros Date: Mon, 4 Feb 2013 11:34:55 -0200 Subject: add config drive to api_samples Add config drive extension show and details to api_samples blueprint nova-api-samples bug 1091737 Change-Id: I6ae1f01a417f153723b85d08c2f181909c154946 --- .../server-config-drive-get-resp.json | 55 +++++++++++++++++++++ .../server-config-drive-get-resp.xml | 19 ++++++++ .../os-config-drive/server-post-req.json | 16 ++++++ .../os-config-drive/server-post-req.xml | 19 ++++++++ .../os-config-drive/server-post-resp.json | 16 ++++++ .../os-config-drive/server-post-resp.xml | 6 +++ .../servers-config-drive-details-resp.json | 57 ++++++++++++++++++++++ .../servers-config-drive-details-resp.xml | 21 ++++++++ .../server-config-drive-get-resp.json.tpl | 55 +++++++++++++++++++++ .../server-config-drive-get-resp.xml.tpl | 19 ++++++++ .../os-config-drive/server-post-req.json.tpl | 16 ++++++ .../os-config-drive/server-post-req.xml.tpl | 19 ++++++++ .../os-config-drive/server-post-resp.json.tpl | 16 ++++++ .../os-config-drive/server-post-resp.xml.tpl | 6 +++ .../servers-config-drive-details-resp.json.tpl | 57 ++++++++++++++++++++++ .../servers-config-drive-details-resp.xml.tpl | 21 ++++++++ nova/tests/integrated/test_api_samples.py | 39 ++++++++++++++- 17 files changed, 456 insertions(+), 1 deletion(-) create mode 100644 doc/api_samples/os-config-drive/server-config-drive-get-resp.json create mode 100644 doc/api_samples/os-config-drive/server-config-drive-get-resp.xml create mode 100644 doc/api_samples/os-config-drive/server-post-req.json create mode 100644 doc/api_samples/os-config-drive/server-post-req.xml create mode 100644 doc/api_samples/os-config-drive/server-post-resp.json create mode 100644 doc/api_samples/os-config-drive/server-post-resp.xml create mode 100644 doc/api_samples/os-config-drive/servers-config-drive-details-resp.json create mode 100644 doc/api_samples/os-config-drive/servers-config-drive-details-resp.xml create mode 100644 nova/tests/integrated/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-config-drive/server-config-drive-get-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-config-drive/server-post-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-config-drive/server-post-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-config-drive/server-post-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-config-drive/server-post-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-config-drive/servers-config-drive-details-resp.xml.tpl diff --git a/doc/api_samples/os-config-drive/server-config-drive-get-resp.json b/doc/api_samples/os-config-drive/server-config-drive-get-resp.json new file mode 100644 index 000000000..8745b3d62 --- /dev/null +++ b/doc/api_samples/os-config-drive/server-config-drive-get-resp.json @@ -0,0 +1,55 @@ +{ + "server": { + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "192.168.0.3", + "version": 4 + } + ] + }, + "config_drive": "", + "created": "2013-02-04T13:17:50Z", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://openstack.example.com/openstack/flavors/1", + "rel": "bookmark" + } + ] + }, + "hostId": "8725fb615b191d8249a40f3e90d1efde88d914412e4edb2719176afd", + "id": "dd3b0715-a3fc-43d8-bbd2-2720beb226fb", + "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/dd3b0715-a3fc-43d8-bbd2-2720beb226fb", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/dd3b0715-a3fc-43d8-bbd2-2720beb226fb", + "rel": "bookmark" + } + ], + "metadata": { + "My Server Name": "Apache1" + }, + "name": "new-server-test", + "progress": 0, + "status": "ACTIVE", + "tenant_id": "openstack", + "updated": "2013-02-04T13:17:51Z", + "user_id": "fake" + } +} \ No newline at end of file diff --git a/doc/api_samples/os-config-drive/server-config-drive-get-resp.xml b/doc/api_samples/os-config-drive/server-config-drive-get-resp.xml new file mode 100644 index 000000000..6bb4c5e7c --- /dev/null +++ b/doc/api_samples/os-config-drive/server-config-drive-get-resp.xml @@ -0,0 +1,19 @@ + + + + + + + + + + Apache1 + + + + + + + + + \ No newline at end of file diff --git a/doc/api_samples/os-config-drive/server-post-req.json b/doc/api_samples/os-config-drive/server-post-req.json new file mode 100644 index 000000000..d88eb4122 --- /dev/null +++ b/doc/api_samples/os-config-drive/server-post-req.json @@ -0,0 +1,16 @@ +{ + "server" : { + "name" : "new-server-test", + "imageRef" : "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b", + "flavorRef" : "http://openstack.example.com/openstack/flavors/1", + "metadata" : { + "My Server Name" : "Apache1" + }, + "personality" : [ + { + "path" : "/etc/banner.txt", + "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" + } + ] + } +} \ No newline at end of file diff --git a/doc/api_samples/os-config-drive/server-post-req.xml b/doc/api_samples/os-config-drive/server-post-req.xml new file mode 100644 index 000000000..0a3c8bb53 --- /dev/null +++ b/doc/api_samples/os-config-drive/server-post-req.xml @@ -0,0 +1,19 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + \ No newline at end of file diff --git a/doc/api_samples/os-config-drive/server-post-resp.json b/doc/api_samples/os-config-drive/server-post-resp.json new file mode 100644 index 000000000..231f5b9f4 --- /dev/null +++ b/doc/api_samples/os-config-drive/server-post-resp.json @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "am5LKVsBVQ4s", + "id": "58da039c-dc81-4d8f-8688-a2f819e2f750", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/58da039c-dc81-4d8f-8688-a2f819e2f750", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/58da039c-dc81-4d8f-8688-a2f819e2f750", + "rel": "bookmark" + } + ] + } +} \ No newline at end of file diff --git a/doc/api_samples/os-config-drive/server-post-resp.xml b/doc/api_samples/os-config-drive/server-post-resp.xml new file mode 100644 index 000000000..3cbb199ce --- /dev/null +++ b/doc/api_samples/os-config-drive/server-post-resp.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/doc/api_samples/os-config-drive/servers-config-drive-details-resp.json b/doc/api_samples/os-config-drive/servers-config-drive-details-resp.json new file mode 100644 index 000000000..1373721ef --- /dev/null +++ b/doc/api_samples/os-config-drive/servers-config-drive-details-resp.json @@ -0,0 +1,57 @@ +{ + "servers": [ + { + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "192.168.0.3", + "version": 4 + } + ] + }, + "config_drive": "", + "created": "2013-02-04T13:21:44Z", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://openstack.example.com/openstack/flavors/1", + "rel": "bookmark" + } + ] + }, + "hostId": "76e154b0015e25fad65a7ab0c35a86dd79acfa8312075a6534ef6176", + "id": "720e688f-5ec8-4d4f-b585-dbd1a89ceeb0", + "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/720e688f-5ec8-4d4f-b585-dbd1a89ceeb0", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/720e688f-5ec8-4d4f-b585-dbd1a89ceeb0", + "rel": "bookmark" + } + ], + "metadata": { + "My Server Name": "Apache1" + }, + "name": "new-server-test", + "progress": 0, + "status": "ACTIVE", + "tenant_id": "openstack", + "updated": "2013-02-04T13:21:44Z", + "user_id": "fake" + } + ] +} \ No newline at end of file diff --git a/doc/api_samples/os-config-drive/servers-config-drive-details-resp.xml b/doc/api_samples/os-config-drive/servers-config-drive-details-resp.xml new file mode 100644 index 000000000..6de687a91 --- /dev/null +++ b/doc/api_samples/os-config-drive/servers-config-drive-details-resp.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + Apache1 + + + + + + + + + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl b/nova/tests/integrated/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl new file mode 100644 index 000000000..ea47da06c --- /dev/null +++ b/nova/tests/integrated/api_samples/os-config-drive/server-config-drive-get-resp.json.tpl @@ -0,0 +1,55 @@ +{ + "server": { + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "%(ip)s", + "version": 4 + } + ] + }, + "config_drive": "%(cdrive)s", + "created": "%(timestamp)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/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(id)s", + "rel": "bookmark" + } + ], + "metadata": { + "My Server Name": "Apache1" + }, + "name": "new-server-test", + "progress": 0, + "status": "ACTIVE", + "tenant_id": "openstack", + "updated": "%(timestamp)s", + "user_id": "fake" + } +} diff --git a/nova/tests/integrated/api_samples/os-config-drive/server-config-drive-get-resp.xml.tpl b/nova/tests/integrated/api_samples/os-config-drive/server-config-drive-get-resp.xml.tpl new file mode 100644 index 000000000..c6fb338c7 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-config-drive/server-config-drive-get-resp.xml.tpl @@ -0,0 +1,19 @@ + + + + + + + + + + Apache1 + + + + + + + + + diff --git a/nova/tests/integrated/api_samples/os-config-drive/server-post-req.json.tpl b/nova/tests/integrated/api_samples/os-config-drive/server-post-req.json.tpl new file mode 100644 index 000000000..d3916d1aa --- /dev/null +++ b/nova/tests/integrated/api_samples/os-config-drive/server-post-req.json.tpl @@ -0,0 +1,16 @@ +{ + "server" : { + "name" : "new-server-test", + "imageRef" : "%(host)s/openstack/images/%(image_id)s", + "flavorRef" : "%(host)s/openstack/flavors/1", + "metadata" : { + "My Server Name" : "Apache1" + }, + "personality" : [ + { + "path" : "/etc/banner.txt", + "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/os-config-drive/server-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-config-drive/server-post-req.xml.tpl new file mode 100644 index 000000000..f92614984 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-config-drive/server-post-req.xml.tpl @@ -0,0 +1,19 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + diff --git a/nova/tests/integrated/api_samples/os-config-drive/server-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-config-drive/server-post-resp.json.tpl new file mode 100644 index 000000000..d5f030c87 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-config-drive/server-post-resp.json.tpl @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "%(password)s", + "id": "%(id)s", + "links": [ + { + "href": "%(host)s/v2/openstack/servers/%(uuid)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(uuid)s", + "rel": "bookmark" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/os-config-drive/server-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-config-drive/server-post-resp.xml.tpl new file mode 100644 index 000000000..3bb13e69b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-config-drive/server-post-resp.xml.tpl @@ -0,0 +1,6 @@ + + + + + + diff --git a/nova/tests/integrated/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl b/nova/tests/integrated/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl new file mode 100644 index 000000000..535d00410 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-config-drive/servers-config-drive-details-resp.json.tpl @@ -0,0 +1,57 @@ +{ + "servers": [ + { + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "%(ip)s", + "version": 4 + } + ] + }, + "config_drive": "%(cdrive)s", + "created": "%(timestamp)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/%(id)s", + "rel": "self" + }, + { + "href": "%(host)s/openstack/servers/%(id)s", + "rel": "bookmark" + } + ], + "metadata": { + "My Server Name": "Apache1" + }, + "name": "new-server-test", + "progress": 0, + "status": "ACTIVE", + "tenant_id": "openstack", + "updated": "%(timestamp)s", + "user_id": "fake" + } + ] +} diff --git a/nova/tests/integrated/api_samples/os-config-drive/servers-config-drive-details-resp.xml.tpl b/nova/tests/integrated/api_samples/os-config-drive/servers-config-drive-details-resp.xml.tpl new file mode 100644 index 000000000..c2b2fa3ba --- /dev/null +++ b/nova/tests/integrated/api_samples/os-config-drive/servers-config-drive-details-resp.xml.tpl @@ -0,0 +1,21 @@ + + + + + + + + + + + Apache1 + + + + + + + + + + diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index e3022d48e..97e38fa0c 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -48,6 +48,7 @@ from nova import test from nova.tests.api.openstack.compute.contrib import test_fping from nova.tests.api.openstack.compute.contrib import test_networks from nova.tests.api.openstack.compute.contrib import test_services +from nova.tests.api.openstack import fakes from nova.tests.baremetal.db import base as bm_db_base from nova.tests import fake_instance_actions from nova.tests import fake_network @@ -381,7 +382,6 @@ class ApiSamplesTrap(ApiSampleTestBase): # NOT be allowed to grow, and should shrink to zero (and be # removed) soon. do_not_approve_additions = [] - do_not_approve_additions.append('os-config-drive') do_not_approve_additions.append('os-create-server-ext') do_not_approve_additions.append('os-flavor-access') do_not_approve_additions.append('os-hypervisors') @@ -3172,4 +3172,41 @@ class InstanceActionsSampleJsonTest(ApiSampleTestBase): class InstanceActionsSampleXmlTest(InstanceActionsSampleJsonTest): + ctype = 'xml' + + +class ConfigDriveSampleJsonTest(ServersSampleBase): + extension_name = ("nova.api.openstack.compute.contrib.config_drive." + "Config_drive") + + def setUp(self): + super(ConfigDriveSampleJsonTest, self).setUp() + fakes.stub_out_networking(self.stubs) + fakes.stub_out_rate_limiting(self.stubs) + fake.stub_out_image_service(self.stubs) + + def test_config_drive_show(self): + uuid = self._post_server() + response = self._do_get('servers/%s' % uuid) + self.assertEqual(response.status, 200) + subs = self._get_regexes() + subs['hostid'] = '[a-f0-9]+' + # config drive can be an uuid or empty value + subs['cdrive'] = '(%s)?' % subs['uuid'] + return self._verify_response('server-config-drive-get-resp', subs, + response) + + def test_config_drive_detail(self): + uuid = self._post_server() + response = self._do_get('servers/detail') + self.assertEqual(response.status, 200) + subs = self._get_regexes() + subs['hostid'] = '[a-f0-9]+' + # config drive can be an uuid or empty value + subs['cdrive'] = '(%s)?' % subs['uuid'] + return self._verify_response('servers-config-drive-details-resp', + subs, response) + + +class ConfigDriveSampleXmlTest(ConfigDriveSampleJsonTest): ctype = 'xml' -- cgit