diff --git a/doc/api_samples/os-console-output/console-output-post-req.json b/doc/api_samples/os-console-output/console-output-post-req.json new file mode 100644 index 000000000000..7bed9235924f --- /dev/null +++ b/doc/api_samples/os-console-output/console-output-post-req.json @@ -0,0 +1,5 @@ +{ + "os-getConsoleOutput": { + "length": 50 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-console-output/console-output-post-req.xml b/doc/api_samples/os-console-output/console-output-post-req.xml new file mode 100644 index 000000000000..9024061fcf80 --- /dev/null +++ b/doc/api_samples/os-console-output/console-output-post-req.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/doc/api_samples/os-console-output/console-output-post-resp.json b/doc/api_samples/os-console-output/console-output-post-resp.json new file mode 100644 index 000000000000..27ffe7d4c269 --- /dev/null +++ b/doc/api_samples/os-console-output/console-output-post-resp.json @@ -0,0 +1,3 @@ +{ + "output": "FAKE CONSOLE OUTPUT\nANOTHER\nLAST LINE" +} \ No newline at end of file diff --git a/doc/api_samples/os-console-output/console-output-post-resp.xml b/doc/api_samples/os-console-output/console-output-post-resp.xml new file mode 100644 index 000000000000..9c5bad625f7b --- /dev/null +++ b/doc/api_samples/os-console-output/console-output-post-resp.xml @@ -0,0 +1,4 @@ + +FAKE CONSOLE OUTPUT +ANOTHER +LAST LINE \ No newline at end of file diff --git a/doc/api_samples/os-console-output/server-post-req.json b/doc/api_samples/os-console-output/server-post-req.json new file mode 100644 index 000000000000..d88eb4122223 --- /dev/null +++ b/doc/api_samples/os-console-output/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-console-output/server-post-req.xml b/doc/api_samples/os-console-output/server-post-req.xml new file mode 100644 index 000000000000..0a3c8bb5303d --- /dev/null +++ b/doc/api_samples/os-console-output/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-console-output/server-post-resp.json b/doc/api_samples/os-console-output/server-post-resp.json new file mode 100644 index 000000000000..54e47aefa015 --- /dev/null +++ b/doc/api_samples/os-console-output/server-post-resp.json @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "N4Lxd6cMUXmE", + "id": "4e44ac84-f3ed-4219-aa2e-b3d1477f0ac3", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/4e44ac84-f3ed-4219-aa2e-b3d1477f0ac3", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/4e44ac84-f3ed-4219-aa2e-b3d1477f0ac3", + "rel": "bookmark" + } + ] + } +} \ No newline at end of file diff --git a/doc/api_samples/os-console-output/server-post-resp.xml b/doc/api_samples/os-console-output/server-post-resp.xml new file mode 100644 index 000000000000..0efd9029d527 --- /dev/null +++ b/doc/api_samples/os-console-output/server-post-resp.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-console-output/console-output-post-req.json.tpl b/nova/tests/integrated/api_samples/os-console-output/console-output-post-req.json.tpl new file mode 100644 index 000000000000..caeb2a550232 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-console-output/console-output-post-req.json.tpl @@ -0,0 +1,5 @@ +{ + "os-getConsoleOutput": { + "length": 50 + } +} diff --git a/nova/tests/integrated/api_samples/os-console-output/console-output-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-console-output/console-output-post-req.xml.tpl new file mode 100644 index 000000000000..af477004df68 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-console-output/console-output-post-req.xml.tpl @@ -0,0 +1,2 @@ + + diff --git a/nova/tests/integrated/api_samples/os-console-output/console-output-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-console-output/console-output-post-resp.json.tpl new file mode 100644 index 000000000000..fae6b128e9db --- /dev/null +++ b/nova/tests/integrated/api_samples/os-console-output/console-output-post-resp.json.tpl @@ -0,0 +1,3 @@ +{ + "output": "FAKE CONSOLE OUTPUT\nANOTHER\nLAST LINE" +} diff --git a/nova/tests/integrated/api_samples/os-console-output/console-output-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-console-output/console-output-post-resp.xml.tpl new file mode 100644 index 000000000000..e93d81df3556 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-console-output/console-output-post-resp.xml.tpl @@ -0,0 +1,4 @@ + +FAKE CONSOLE OUTPUT +ANOTHER +LAST LINE diff --git a/nova/tests/integrated/api_samples/os-console-output/server-post-req.json.tpl b/nova/tests/integrated/api_samples/os-console-output/server-post-req.json.tpl new file mode 100644 index 000000000000..d3916d1aa68a --- /dev/null +++ b/nova/tests/integrated/api_samples/os-console-output/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-console-output/server-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-console-output/server-post-req.xml.tpl new file mode 100644 index 000000000000..f92614984242 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-console-output/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-console-output/server-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-console-output/server-post-resp.json.tpl new file mode 100644 index 000000000000..d5f030c8730b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-console-output/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-console-output/server-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-console-output/server-post-resp.xml.tpl new file mode 100644 index 000000000000..3bb13e69bd6d --- /dev/null +++ b/nova/tests/integrated/api_samples/os-console-output/server-post-resp.xml.tpl @@ -0,0 +1,6 @@ + + + + + + diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index f3d9cc478e1e..dc4883315747 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -690,3 +690,22 @@ class SchedulerHintsJsonTest(ApiSampleTestBase): class SchedulerHintsXmlTest(SchedulerHintsJsonTest): ctype = 'xml' + + +class ConsoleOutputSampleJsonTest(ServersSampleBase): + extension_name = "nova.api.openstack.compute.contrib" + \ + ".console_output.Console_output" + + def test_get_console_output(self): + uuid = self._post_server() + response = self._do_post('servers/%s/action' % uuid, + 'console-output-post-req', + {'action': 'os-getConsoleOutput'}) + self.assertEqual(response.status, 200) + subs = self._get_regexes() + return self._verify_response('console-output-post-resp', + subs, response) + + +class ConsoleOutputSampleXmlTest(ConsoleOutputSampleJsonTest): + ctype = 'xml'