diff --git a/doc/api_samples/os-consoles/get-vnc-console-post-req.json b/doc/api_samples/os-consoles/get-vnc-console-post-req.json new file mode 100644 index 000000000000..1926119ced68 --- /dev/null +++ b/doc/api_samples/os-consoles/get-vnc-console-post-req.json @@ -0,0 +1,5 @@ +{ + "os-getVNCConsole": { + "type": "novnc" + } +} diff --git a/doc/api_samples/os-consoles/get-vnc-console-post-req.xml b/doc/api_samples/os-consoles/get-vnc-console-post-req.xml new file mode 100644 index 000000000000..00f32c6b92c6 --- /dev/null +++ b/doc/api_samples/os-consoles/get-vnc-console-post-req.xml @@ -0,0 +1,2 @@ + + diff --git a/doc/api_samples/os-consoles/get-vnc-console-post-resp.json b/doc/api_samples/os-consoles/get-vnc-console-post-resp.json new file mode 100644 index 000000000000..4bcaf468629a --- /dev/null +++ b/doc/api_samples/os-consoles/get-vnc-console-post-resp.json @@ -0,0 +1,6 @@ +{ + "console": { + "type": "novnc", + "url": "http://example.com:6080/vnc_auto.html?token=f9906a48-b71e-4f18-baca-c987da3ebdb3&title=dafa(75ecef58-3b8e-4659-ab3b-5501454188e9)" + } +} diff --git a/doc/api_samples/os-consoles/get-vnc-console-post-resp.xml b/doc/api_samples/os-consoles/get-vnc-console-post-resp.xml new file mode 100644 index 000000000000..2d74fffa873d --- /dev/null +++ b/doc/api_samples/os-consoles/get-vnc-console-post-resp.xml @@ -0,0 +1,5 @@ + + + novnc + http://example.com:6080/vnc_auto.html?token=f9906a48-b71e-4f18-baca-c987da3ebdb3&title=dafa(75ecef58-3b8e-4659-ab3b-5501454188e9) + diff --git a/doc/api_samples/os-consoles/server-post-req.json b/doc/api_samples/os-consoles/server-post-req.json new file mode 100644 index 000000000000..09366b4c934e --- /dev/null +++ b/doc/api_samples/os-consoles/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==" + } + ] + } +} diff --git a/doc/api_samples/os-consoles/server-post-req.xml b/doc/api_samples/os-consoles/server-post-req.xml new file mode 100644 index 000000000000..077dd7618cf4 --- /dev/null +++ b/doc/api_samples/os-consoles/server-post-req.xml @@ -0,0 +1,19 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + diff --git a/doc/api_samples/os-consoles/server-post-resp.json b/doc/api_samples/os-consoles/server-post-resp.json new file mode 100644 index 000000000000..db9ed3d6d1ed --- /dev/null +++ b/doc/api_samples/os-consoles/server-post-resp.json @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "MVk5HPrazHcG", + "id": "5bbcc3c4-1da2-4437-a48a-66f15b1b13f9", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/5bbcc3c4-1da2-4437-a48a-66f15b1b13f9", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/5bbcc3c4-1da2-4437-a48a-66f15b1b13f9", + "rel": "bookmark" + } + ] + } +} diff --git a/doc/api_samples/os-consoles/server-post-resp.xml b/doc/api_samples/os-consoles/server-post-resp.xml new file mode 100644 index 000000000000..68f0933c7710 --- /dev/null +++ b/doc/api_samples/os-consoles/server-post-resp.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/nova/tests/integrated/api_samples/os-consoles/get-vnc-console-post-req.json.tpl b/nova/tests/integrated/api_samples/os-consoles/get-vnc-console-post-req.json.tpl new file mode 100644 index 000000000000..1926119ced68 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-consoles/get-vnc-console-post-req.json.tpl @@ -0,0 +1,5 @@ +{ + "os-getVNCConsole": { + "type": "novnc" + } +} diff --git a/nova/tests/integrated/api_samples/os-consoles/get-vnc-console-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-consoles/get-vnc-console-post-req.xml.tpl new file mode 100644 index 000000000000..00f32c6b92c6 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-consoles/get-vnc-console-post-req.xml.tpl @@ -0,0 +1,2 @@ + + diff --git a/nova/tests/integrated/api_samples/os-consoles/get-vnc-console-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-consoles/get-vnc-console-post-resp.json.tpl new file mode 100644 index 000000000000..3cf7255759d9 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-consoles/get-vnc-console-post-resp.json.tpl @@ -0,0 +1,6 @@ +{ + "console": { + "type": "novnc", + "url":"%(url)s" + } +} diff --git a/nova/tests/integrated/api_samples/os-consoles/get-vnc-console-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-consoles/get-vnc-console-post-resp.xml.tpl new file mode 100644 index 000000000000..d4904aa9a531 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-consoles/get-vnc-console-post-resp.xml.tpl @@ -0,0 +1,5 @@ + + + novnc + %(url)s + diff --git a/nova/tests/integrated/api_samples/os-consoles/server-post-req.json.tpl b/nova/tests/integrated/api_samples/os-consoles/server-post-req.json.tpl new file mode 100644 index 000000000000..d3916d1aa68a --- /dev/null +++ b/nova/tests/integrated/api_samples/os-consoles/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-consoles/server-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-consoles/server-post-req.xml.tpl new file mode 100644 index 000000000000..f92614984242 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-consoles/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-consoles/server-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-consoles/server-post-resp.json.tpl new file mode 100644 index 000000000000..d5f030c8730b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-consoles/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-consoles/server-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-consoles/server-post-resp.xml.tpl new file mode 100644 index 000000000000..3bb13e69bd6d --- /dev/null +++ b/nova/tests/integrated/api_samples/os-consoles/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 e06e2a67cb04..62d49ad0a5b4 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -1445,3 +1445,24 @@ class AdminActionsSamplesJsonTest(ServersSampleBase): class AdminActionsSamplesXmlTest(AdminActionsSamplesJsonTest): ctype = 'xml' + + +class ConsolesSampleJsonTests(ServersSampleBase): + extension_name = ("nova.api.openstack.compute.contrib" + ".consoles.Consoles") + + def test_get_vnc_console(self): + uuid = self._post_server() + response = self._do_post('servers/%s/action' % uuid, + 'get-vnc-console-post-req', + {'action': 'os-getVNCConsole'}) + self.assertEqual(response.status, 200) + subs = self._get_regexes() + subs["url"] = \ + "((https?):((//)|(\\\\))+([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*)" + return self._verify_response('get-vnc-console-post-resp', + subs, response) + + +class ConsoleOutputSampleXmlTests(ConsoleOutputSampleJsonTest): + ctype = 'xml'