diff --git a/doc/api_samples/os-server-start-stop/server_start_stop.json b/doc/api_samples/os-server-start-stop/server_start_stop.json new file mode 100644 index 000000000000..7fdb5fd30efd --- /dev/null +++ b/doc/api_samples/os-server-start-stop/server_start_stop.json @@ -0,0 +1,3 @@ +{ + "os-stop" : null +} \ No newline at end of file diff --git a/doc/api_samples/os-server-start-stop/server_start_stop.xml b/doc/api_samples/os-server-start-stop/server_start_stop.xml new file mode 100644 index 000000000000..69aac4af42cc --- /dev/null +++ b/doc/api_samples/os-server-start-stop/server_start_stop.xml @@ -0,0 +1,2 @@ + + diff --git a/nova/tests/integrated/api_samples/os-server-start-stop/server-post-req.json.tpl b/nova/tests/integrated/api_samples/os-server-start-stop/server-post-req.json.tpl new file mode 100644 index 000000000000..d3916d1aa68a --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-start-stop/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-server-start-stop/server-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-server-start-stop/server-post-req.xml.tpl new file mode 100644 index 000000000000..f92614984242 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-start-stop/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-server-start-stop/server-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-server-start-stop/server-post-resp.json.tpl new file mode 100644 index 000000000000..d5f030c8730b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-start-stop/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-server-start-stop/server-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-server-start-stop/server-post-resp.xml.tpl new file mode 100644 index 000000000000..3bb13e69bd6d --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-start-stop/server-post-resp.xml.tpl @@ -0,0 +1,6 @@ + + + + + + diff --git a/nova/tests/integrated/api_samples/os-server-start-stop/server_start_stop.json.tpl b/nova/tests/integrated/api_samples/os-server-start-stop/server_start_stop.json.tpl new file mode 100644 index 000000000000..a993b3f684a1 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-start-stop/server_start_stop.json.tpl @@ -0,0 +1,3 @@ +{ + "%(action)s" : null +} diff --git a/nova/tests/integrated/api_samples/os-server-start-stop/server_start_stop.xml.tpl b/nova/tests/integrated/api_samples/os-server-start-stop/server_start_stop.xml.tpl new file mode 100644 index 000000000000..35cc3c2045e4 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-start-stop/server_start_stop.xml.tpl @@ -0,0 +1,2 @@ + +<%(action)s/> diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 3786e29755e1..d51240871606 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -476,3 +476,28 @@ class LimitsSampleJsonTest(ApiSampleTestBase): class LimitsSampleXmlTest(LimitsSampleJsonTest): ctype = 'xml' + + +class ServerStartStopJsonTest(ServersSampleBase): + extension_name = "nova.api.openstack.compute.contrib" + \ + ".server_start_stop.Server_start_stop" + + def _test_server_action(self, uuid, action): + response = self._do_post('servers/%s/action' % uuid, + 'server_start_stop', + {'action': action}) + self.assertEqual(response.status, 202) + self.assertEqual(response.read(), "") + + def test_server_start(self): + uuid = self._post_server() + self._test_server_action(uuid, 'os-stop') + self._test_server_action(uuid, 'os-start') + + def test_server_stop(self): + uuid = self._post_server() + self._test_server_action(uuid, 'os-stop') + + +class ServerStartStopXmlTest(ServerStartStopJsonTest): + ctype = 'xml'