From d6e0fdf752cf67ff9729b3fdcdeb925bd0c1cd3f Mon Sep 17 00:00:00 2001 From: "Mauro S. M. Rodrigues" Date: Wed, 10 Oct 2012 22:22:31 -0400 Subject: [PATCH] Add Server diagnostics extension api samples Change-Id: Id53e17caa75dcab01dd3209f771891b4e92debec --- .../server-diagnostics-get-resp.json | 17 +++++++++++++++++ .../server-diagnostics-get-resp.xml | 18 ++++++++++++++++++ .../server-post-req.json | 16 ++++++++++++++++ .../os-server-diagnostics/server-post-req.xml | 19 +++++++++++++++++++ .../server-post-resp.json | 16 ++++++++++++++++ .../server-post-resp.xml | 6 ++++++ .../server-diagnostics-get-resp.json.tpl | 17 +++++++++++++++++ .../server-diagnostics-get-resp.xml.tpl | 18 ++++++++++++++++++ .../server-post-req.json.tpl | 16 ++++++++++++++++ .../server-post-req.xml.tpl | 19 +++++++++++++++++++ .../server-post-resp.json.tpl | 16 ++++++++++++++++ .../server-post-resp.xml.tpl | 6 ++++++ nova/tests/integrated/test_api_samples.py | 17 +++++++++++++++++ 13 files changed, 201 insertions(+) create mode 100644 doc/api_samples/os-server-diagnostics/server-diagnostics-get-resp.json create mode 100644 doc/api_samples/os-server-diagnostics/server-diagnostics-get-resp.xml create mode 100644 doc/api_samples/os-server-diagnostics/server-post-req.json create mode 100644 doc/api_samples/os-server-diagnostics/server-post-req.xml create mode 100644 doc/api_samples/os-server-diagnostics/server-post-resp.json create mode 100644 doc/api_samples/os-server-diagnostics/server-post-resp.xml create mode 100644 nova/tests/integrated/api_samples/os-server-diagnostics/server-diagnostics-get-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-server-diagnostics/server-diagnostics-get-resp.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-server-diagnostics/server-post-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-server-diagnostics/server-post-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/os-server-diagnostics/server-post-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/os-server-diagnostics/server-post-resp.xml.tpl diff --git a/doc/api_samples/os-server-diagnostics/server-diagnostics-get-resp.json b/doc/api_samples/os-server-diagnostics/server-diagnostics-get-resp.json new file mode 100644 index 000000000000..d336543929f0 --- /dev/null +++ b/doc/api_samples/os-server-diagnostics/server-diagnostics-get-resp.json @@ -0,0 +1,17 @@ +{ + "cpu0_time": 17300000000, + "memory": 524288, + "vda_errors": -1, + "vda_read": 262144, + "vda_read_req": 112, + "vda_write": 5778432, + "vda_write_req": 488, + "vnet1_rx": 2070139, + "vnet1_rx_drop": 0, + "vnet1_rx_errors": 0, + "vnet1_rx_packets": 26701, + "vnet1_tx": 140208, + "vnet1_tx_drop": 0, + "vnet1_tx_errors": 0, + "vnet1_tx_packets": 662 +} \ No newline at end of file diff --git a/doc/api_samples/os-server-diagnostics/server-diagnostics-get-resp.xml b/doc/api_samples/os-server-diagnostics/server-diagnostics-get-resp.xml new file mode 100644 index 000000000000..776419f82f49 --- /dev/null +++ b/doc/api_samples/os-server-diagnostics/server-diagnostics-get-resp.xml @@ -0,0 +1,18 @@ + + + 524288 + 5778432 + 26701 + 0 + 0 + 2070139 + 262144 + 488 + 140208 + 0 + 662 + 0 + 17300000000 + 112 + -1 + \ No newline at end of file diff --git a/doc/api_samples/os-server-diagnostics/server-post-req.json b/doc/api_samples/os-server-diagnostics/server-post-req.json new file mode 100644 index 000000000000..d88eb4122223 --- /dev/null +++ b/doc/api_samples/os-server-diagnostics/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-server-diagnostics/server-post-req.xml b/doc/api_samples/os-server-diagnostics/server-post-req.xml new file mode 100644 index 000000000000..0a3c8bb5303d --- /dev/null +++ b/doc/api_samples/os-server-diagnostics/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-server-diagnostics/server-post-resp.json b/doc/api_samples/os-server-diagnostics/server-post-resp.json new file mode 100644 index 000000000000..b14c071cc927 --- /dev/null +++ b/doc/api_samples/os-server-diagnostics/server-post-resp.json @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "gSLumCiGg3V9", + "id": "b10a33d1-6fb5-45d4-876d-4e68962db878", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/b10a33d1-6fb5-45d4-876d-4e68962db878", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/b10a33d1-6fb5-45d4-876d-4e68962db878", + "rel": "bookmark" + } + ] + } +} \ No newline at end of file diff --git a/doc/api_samples/os-server-diagnostics/server-post-resp.xml b/doc/api_samples/os-server-diagnostics/server-post-resp.xml new file mode 100644 index 000000000000..b7210473d5fd --- /dev/null +++ b/doc/api_samples/os-server-diagnostics/server-post-resp.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-server-diagnostics/server-diagnostics-get-resp.json.tpl b/nova/tests/integrated/api_samples/os-server-diagnostics/server-diagnostics-get-resp.json.tpl new file mode 100644 index 000000000000..1afedaee9c4b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-diagnostics/server-diagnostics-get-resp.json.tpl @@ -0,0 +1,17 @@ +{ + "cpu0_time": 17300000000, + "memory": 524288, + "vda_errors": -1, + "vda_read": 262144, + "vda_read_req": 112, + "vda_write": 5778432, + "vda_write_req": 488, + "vnet1_rx": 2070139, + "vnet1_rx_drop": 0, + "vnet1_rx_errors": 0, + "vnet1_rx_packets": 26701, + "vnet1_tx": 140208, + "vnet1_tx_drop": 0, + "vnet1_tx_errors": 0, + "vnet1_tx_packets": 662 +} diff --git a/nova/tests/integrated/api_samples/os-server-diagnostics/server-diagnostics-get-resp.xml.tpl b/nova/tests/integrated/api_samples/os-server-diagnostics/server-diagnostics-get-resp.xml.tpl new file mode 100644 index 000000000000..776419f82f49 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-diagnostics/server-diagnostics-get-resp.xml.tpl @@ -0,0 +1,18 @@ + + + 524288 + 5778432 + 26701 + 0 + 0 + 2070139 + 262144 + 488 + 140208 + 0 + 662 + 0 + 17300000000 + 112 + -1 + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-server-diagnostics/server-post-req.json.tpl b/nova/tests/integrated/api_samples/os-server-diagnostics/server-post-req.json.tpl new file mode 100644 index 000000000000..d3916d1aa68a --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-diagnostics/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-diagnostics/server-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-server-diagnostics/server-post-req.xml.tpl new file mode 100644 index 000000000000..f92614984242 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-diagnostics/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-diagnostics/server-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-server-diagnostics/server-post-resp.json.tpl new file mode 100644 index 000000000000..d5f030c8730b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-diagnostics/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-diagnostics/server-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-server-diagnostics/server-post-resp.xml.tpl new file mode 100644 index 000000000000..3bb13e69bd6d --- /dev/null +++ b/nova/tests/integrated/api_samples/os-server-diagnostics/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 cfdd27bccb69..792384ed66e7 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -1269,3 +1269,20 @@ class SimpleTenantUsageSampleJsonTest(ServersSampleBase): class SimpleTenantUsageSampleXmlTest(SimpleTenantUsageSampleJsonTest): ctype = "xml" + + +class ServerDiagnosticsSamplesJsonTest(ServersSampleBase): + extension_name = ("nova.api.openstack.compute.contrib.server_diagnostics." + "Server_diagnostics") + + def test_server_diagnostics_get(self): + uuid = self._post_server() + response = self._do_get('servers/%s/diagnostics' % uuid) + self.assertEqual(response.status, 200) + subs = self._get_regexes() + return self._verify_response('server-diagnostics-get-resp', subs, + response) + + +class ServerDiagnosticsSamplesXmlTest(ServerDiagnosticsSamplesJsonTest): + ctype = "xml"