From b456a862ad85578bf4cf8e861be56aa5e728f9f4 Mon Sep 17 00:00:00 2001 From: Nikola Dipanov Date: Wed, 19 Sep 2012 14:45:40 +0200 Subject: [PATCH] Adds API sample testing for rescue API extension Adds tests and templates for testing of the server rescue API extension. Tests both json and XML API functionality. Change-Id: Icb241e96ebedde0b6385f8ba60eebd0e768f22da --- .../os-rescue/server-get-resp-rescue.json | 53 ++++++++++++++++++ .../os-rescue/server-get-resp-rescue.xml | 19 +++++++ .../os-rescue/server-get-resp-unrescue.json | 54 +++++++++++++++++++ .../os-rescue/server-get-resp-unrescue.xml | 19 +++++++ .../os-rescue/server-post-req.json | 16 ++++++ doc/api_samples/os-rescue/server-post-req.xml | 19 +++++++ .../os-rescue/server-post-resp.json | 16 ++++++ .../os-rescue/server-post-resp.xml | 6 +++ .../os-rescue/server-rescue-req.json | 5 ++ .../os-rescue/server-rescue-req.xml | 3 ++ doc/api_samples/os-rescue/server-rescue.json | 3 ++ doc/api_samples/os-rescue/server-rescue.xml | 2 + .../os-rescue/server-unrescue-req.json | 3 ++ .../os-rescue/server-unrescue-req.xml | 2 + .../os-rescue/server-get-resp-rescue.json.tpl | 53 ++++++++++++++++++ .../os-rescue/server-get-resp-rescue.xml.tpl | 19 +++++++ .../server-get-resp-unrescue.json.tpl | 54 +++++++++++++++++++ .../server-get-resp-unrescue.xml.tpl | 19 +++++++ .../os-rescue/server-post-req.json.tpl | 16 ++++++ .../os-rescue/server-post-req.xml.tpl | 19 +++++++ .../os-rescue/server-post-resp.json.tpl | 16 ++++++ .../os-rescue/server-post-resp.xml.tpl | 6 +++ .../os-rescue/server-rescue-req.json.tpl | 5 ++ .../os-rescue/server-rescue-req.xml.tpl | 3 ++ .../os-rescue/server-rescue.json.tpl | 3 ++ .../os-rescue/server-rescue.xml.tpl | 2 + .../os-rescue/server-unrescue-req.json.tpl | 3 ++ .../os-rescue/server-unrescue-req.xml.tpl | 2 + nova/tests/integrated/test_api_samples.py | 51 ++++++++++++++++++ 29 files changed, 491 insertions(+) create mode 100644 doc/api_samples/os-rescue/server-get-resp-rescue.json create mode 100644 doc/api_samples/os-rescue/server-get-resp-rescue.xml create mode 100644 doc/api_samples/os-rescue/server-get-resp-unrescue.json create mode 100644 doc/api_samples/os-rescue/server-get-resp-unrescue.xml create mode 100644 doc/api_samples/os-rescue/server-post-req.json create mode 100644 doc/api_samples/os-rescue/server-post-req.xml create mode 100644 doc/api_samples/os-rescue/server-post-resp.json create mode 100644 doc/api_samples/os-rescue/server-post-resp.xml create mode 100644 doc/api_samples/os-rescue/server-rescue-req.json create mode 100644 doc/api_samples/os-rescue/server-rescue-req.xml create mode 100644 doc/api_samples/os-rescue/server-rescue.json create mode 100644 doc/api_samples/os-rescue/server-rescue.xml create mode 100644 doc/api_samples/os-rescue/server-unrescue-req.json create mode 100644 doc/api_samples/os-rescue/server-unrescue-req.xml create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-post-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-post-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-post-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-post-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-rescue-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-rescue-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-rescue.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-rescue.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.xml.tpl diff --git a/doc/api_samples/os-rescue/server-get-resp-rescue.json b/doc/api_samples/os-rescue/server-get-resp-rescue.json new file mode 100644 index 000000000000..d08191977e23 --- /dev/null +++ b/doc/api_samples/os-rescue/server-get-resp-rescue.json @@ -0,0 +1,53 @@ +{ + "server": { + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "192.168.0.3", + "version": 4 + } + ] + }, + "created": "2012-09-19T09:22:27Z", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://openstack.example.com/openstack/flavors/1", + "rel": "bookmark" + } + ] + }, + "hostId": "c02c15d17499304e9893d9fc41c415f5096f8aa880bc651cac092650", + "id": "7e21a264-6cc1-4d90-b7b5-f9f49cec3a85", + "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/7e21a264-6cc1-4d90-b7b5-f9f49cec3a85", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/7e21a264-6cc1-4d90-b7b5-f9f49cec3a85", + "rel": "bookmark" + } + ], + "metadata": { + "My Server Name": "Apache1" + }, + "name": "new-server-test", + "status": "RESCUE", + "tenant_id": "openstack", + "updated": "2012-09-19T09:22:27Z", + "user_id": "fake" + } +} \ No newline at end of file diff --git a/doc/api_samples/os-rescue/server-get-resp-rescue.xml b/doc/api_samples/os-rescue/server-get-resp-rescue.xml new file mode 100644 index 000000000000..b0da738c4cc7 --- /dev/null +++ b/doc/api_samples/os-rescue/server-get-resp-rescue.xml @@ -0,0 +1,19 @@ + + + + + + + + + + Apache1 + + + + + + + + + \ No newline at end of file diff --git a/doc/api_samples/os-rescue/server-get-resp-unrescue.json b/doc/api_samples/os-rescue/server-get-resp-unrescue.json new file mode 100644 index 000000000000..21a35da7f0a1 --- /dev/null +++ b/doc/api_samples/os-rescue/server-get-resp-unrescue.json @@ -0,0 +1,54 @@ +{ + "server": { + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "192.168.0.3", + "version": 4 + } + ] + }, + "created": "2012-09-19T09:22:28Z", + "flavor": { + "id": "1", + "links": [ + { + "href": "http://openstack.example.com/openstack/flavors/1", + "rel": "bookmark" + } + ] + }, + "hostId": "a9410a6a8cb87328b1c43cda5c5a15fc860e977d14feb2c9528a2450", + "id": "f1ec6ac3-5379-4cdc-af9a-6ddc29656e4f", + "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/f1ec6ac3-5379-4cdc-af9a-6ddc29656e4f", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/f1ec6ac3-5379-4cdc-af9a-6ddc29656e4f", + "rel": "bookmark" + } + ], + "metadata": { + "My Server Name": "Apache1" + }, + "name": "new-server-test", + "progress": 0, + "status": "ACTIVE", + "tenant_id": "openstack", + "updated": "2012-09-19T09:22:28Z", + "user_id": "fake" + } +} \ No newline at end of file diff --git a/doc/api_samples/os-rescue/server-get-resp-unrescue.xml b/doc/api_samples/os-rescue/server-get-resp-unrescue.xml new file mode 100644 index 000000000000..41fce846a19c --- /dev/null +++ b/doc/api_samples/os-rescue/server-get-resp-unrescue.xml @@ -0,0 +1,19 @@ + + + + + + + + + + Apache1 + + + + + + + + + \ No newline at end of file diff --git a/doc/api_samples/os-rescue/server-post-req.json b/doc/api_samples/os-rescue/server-post-req.json new file mode 100644 index 000000000000..d88eb4122223 --- /dev/null +++ b/doc/api_samples/os-rescue/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-rescue/server-post-req.xml b/doc/api_samples/os-rescue/server-post-req.xml new file mode 100644 index 000000000000..0a3c8bb5303d --- /dev/null +++ b/doc/api_samples/os-rescue/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-rescue/server-post-resp.json b/doc/api_samples/os-rescue/server-post-resp.json new file mode 100644 index 000000000000..d9114225a2bf --- /dev/null +++ b/doc/api_samples/os-rescue/server-post-resp.json @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "xjDVAYHmc34s", + "id": "784f5005-bec9-4c22-8c42-5a7dcba88d82", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/784f5005-bec9-4c22-8c42-5a7dcba88d82", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/784f5005-bec9-4c22-8c42-5a7dcba88d82", + "rel": "bookmark" + } + ] + } +} \ No newline at end of file diff --git a/doc/api_samples/os-rescue/server-post-resp.xml b/doc/api_samples/os-rescue/server-post-resp.xml new file mode 100644 index 000000000000..3a31871ba9af --- /dev/null +++ b/doc/api_samples/os-rescue/server-post-resp.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/doc/api_samples/os-rescue/server-rescue-req.json b/doc/api_samples/os-rescue/server-rescue-req.json new file mode 100644 index 000000000000..3796600282f1 --- /dev/null +++ b/doc/api_samples/os-rescue/server-rescue-req.json @@ -0,0 +1,5 @@ +{ + "rescue": { + "adminPass": "MySecretPass" + } +} \ No newline at end of file diff --git a/doc/api_samples/os-rescue/server-rescue-req.xml b/doc/api_samples/os-rescue/server-rescue-req.xml new file mode 100644 index 000000000000..737263372937 --- /dev/null +++ b/doc/api_samples/os-rescue/server-rescue-req.xml @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/doc/api_samples/os-rescue/server-rescue.json b/doc/api_samples/os-rescue/server-rescue.json new file mode 100644 index 000000000000..6cd942395fea --- /dev/null +++ b/doc/api_samples/os-rescue/server-rescue.json @@ -0,0 +1,3 @@ +{ + "adminPass": "MySecretPass" +} \ No newline at end of file diff --git a/doc/api_samples/os-rescue/server-rescue.xml b/doc/api_samples/os-rescue/server-rescue.xml new file mode 100644 index 000000000000..582388670248 --- /dev/null +++ b/doc/api_samples/os-rescue/server-rescue.xml @@ -0,0 +1,2 @@ + +MySecretPass \ No newline at end of file diff --git a/doc/api_samples/os-rescue/server-unrescue-req.json b/doc/api_samples/os-rescue/server-unrescue-req.json new file mode 100644 index 000000000000..cafc9b13a84d --- /dev/null +++ b/doc/api_samples/os-rescue/server-unrescue-req.json @@ -0,0 +1,3 @@ +{ + "unrescue": null +} \ No newline at end of file diff --git a/doc/api_samples/os-rescue/server-unrescue-req.xml b/doc/api_samples/os-rescue/server-unrescue-req.xml new file mode 100644 index 000000000000..6a87f8fb21f2 --- /dev/null +++ b/doc/api_samples/os-rescue/server-unrescue-req.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.json.tpl new file mode 100644 index 000000000000..011ed6396edb --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.json.tpl @@ -0,0 +1,53 @@ +{ + "server": { + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "%(ip)s", + "version": 4 + } + ] + }, + "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", + "status": "%(status)s", + "tenant_id": "openstack", + "updated": "%(timestamp)s", + "user_id": "fake" + } +} diff --git a/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.xml.tpl new file mode 100644 index 000000000000..d1d9b7c2cb7e --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-rescue.xml.tpl @@ -0,0 +1,19 @@ + + + + + + + + + + Apache1 + + + + + + + + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.json.tpl new file mode 100644 index 000000000000..bc483c6dae74 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.json.tpl @@ -0,0 +1,54 @@ +{ + "server": { + "accessIPv4": "", + "accessIPv6": "", + "addresses": { + "private": [ + { + "addr": "%(ip)s", + "version": 4 + } + ] + }, + "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": "%(status)s", + "tenant_id": "openstack", + "updated": "%(timestamp)s", + "user_id": "fake" + } +} diff --git a/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.xml.tpl new file mode 100644 index 000000000000..e87ba47f1005 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/server-get-resp-unrescue.xml.tpl @@ -0,0 +1,19 @@ + + + + + + + + + + Apache1 + + + + + + + + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-rescue/server-post-req.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-post-req.json.tpl new file mode 100644 index 000000000000..d3916d1aa68a --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/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-rescue/server-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-post-req.xml.tpl new file mode 100644 index 000000000000..f92614984242 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/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-rescue/server-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-post-resp.json.tpl new file mode 100644 index 000000000000..d5f030c8730b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/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-rescue/server-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-post-resp.xml.tpl new file mode 100644 index 000000000000..3bb13e69bd6d --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/server-post-resp.xml.tpl @@ -0,0 +1,6 @@ + + + + + + diff --git a/nova/tests/integrated/api_samples/os-rescue/server-rescue-req.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-rescue-req.json.tpl new file mode 100644 index 000000000000..d712347537c5 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/server-rescue-req.json.tpl @@ -0,0 +1,5 @@ +{ + "rescue": { + "adminPass": "%(password)s" + } +} \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-rescue/server-rescue-req.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-rescue-req.xml.tpl new file mode 100644 index 000000000000..09acae072aba --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/server-rescue-req.xml.tpl @@ -0,0 +1,3 @@ + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-rescue/server-rescue.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-rescue.json.tpl new file mode 100644 index 000000000000..1922e4db1bdd --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/server-rescue.json.tpl @@ -0,0 +1,3 @@ +{ + "adminPass": "%(password)s" +} \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-rescue/server-rescue.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-rescue.xml.tpl new file mode 100644 index 000000000000..b3b95fdde4aa --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/server-rescue.xml.tpl @@ -0,0 +1,2 @@ + +%(password)s \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.json.tpl b/nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.json.tpl new file mode 100644 index 000000000000..cafc9b13a84d --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.json.tpl @@ -0,0 +1,3 @@ +{ + "unrescue": null +} \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.xml.tpl b/nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.xml.tpl new file mode 100644 index 000000000000..6a87f8fb21f2 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-rescue/server-unrescue-req.xml.tpl @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index a1304c55a368..9beb8c880efd 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -917,3 +917,54 @@ class KeyPairsSampleJsonTest(ApiSampleTestBase): class KeyPairsSampleXmlTest(KeyPairsSampleJsonTest): ctype = 'xml' + + +class RescueJsonTest(ServersSampleBase): + extension_name = ("nova.api.openstack.compute.contrib" + ".rescue.Rescue") + + def _rescue(self, uuid): + req_subs = { + 'password': 'MySecretPass' + } + response = self._do_post('servers/%s/action' % uuid, + 'server-rescue-req', req_subs) + self._verify_response('server-rescue', req_subs, response) + + def _unrescue(self, uuid): + response = self._do_post('servers/%s/action' % uuid, + 'server-unrescue-req', {}) + self.assertEqual(response.status, 202) + + def test_server_rescue(self): + uuid = self._post_server() + + self._rescue(uuid) + + # Do a server get to make sure that the 'RESCUE' state is set + response = self._do_get('servers/%s' % uuid) + subs = self._get_regexes() + subs['hostid'] = '[a-f0-9]+' + subs['id'] = uuid + subs['status'] = 'RESCUE' + + self._verify_response('server-get-resp-rescue', subs, response) + + def test_server_unrescue(self): + uuid = self._post_server() + + self._rescue(uuid) + self._unrescue(uuid) + + # Do a server get to make sure that the 'ACTIVE' state is back + response = self._do_get('servers/%s' % uuid) + subs = self._get_regexes() + subs['hostid'] = '[a-f0-9]+' + subs['id'] = uuid + subs['status'] = 'ACTIVE' + + self._verify_response('server-get-resp-unrescue', subs, response) + + +class RescueXmlTest(RescueJsonTest): + ctype = 'xml'