From 73b3686862a6663493c011d2faa909b61857e19e Mon Sep 17 00:00:00 2001 From: "Mauro S. M. Rodrigues" Date: Fri, 25 Jan 2013 12:39:40 -0500 Subject: [PATCH] Add api-samples to multinic extension Partially implements bp nova-api-samples Fixes bug 1070169 Change-Id: I923054bf92840a7fe81f78c97aa77a9201e94bdc --- .../NMN/multinic-add-fixed-ip-req.json | 5 ++++ .../NMN/multinic-add-fixed-ip-req.xml | 3 +++ .../NMN/multinic-remove-fixed-ip-req.json | 5 ++++ .../NMN/multinic-remove-fixed-ip-req.xml | 3 +++ doc/api_samples/NMN/server-post-req.json | 16 ++++++++++++ doc/api_samples/NMN/server-post-req.xml | 19 ++++++++++++++ doc/api_samples/NMN/server-post-resp.json | 16 ++++++++++++ doc/api_samples/NMN/server-post-resp.xml | 6 +++++ .../NMN/multinic-add-fixed-ip-req.json.tpl | 5 ++++ .../NMN/multinic-add-fixed-ip-req.xml.tpl | 3 +++ .../NMN/multinic-remove-fixed-ip-req.json.tpl | 5 ++++ .../NMN/multinic-remove-fixed-ip-req.xml.tpl | 3 +++ .../api_samples/NMN/server-post-req.json.tpl | 16 ++++++++++++ .../api_samples/NMN/server-post-req.xml.tpl | 19 ++++++++++++++ .../api_samples/NMN/server-post-resp.json.tpl | 16 ++++++++++++ .../api_samples/NMN/server-post-resp.xml.tpl | 6 +++++ nova/tests/integrated/test_api_samples.py | 25 ++++++++++++++++++- 17 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 doc/api_samples/NMN/multinic-add-fixed-ip-req.json create mode 100644 doc/api_samples/NMN/multinic-add-fixed-ip-req.xml create mode 100644 doc/api_samples/NMN/multinic-remove-fixed-ip-req.json create mode 100644 doc/api_samples/NMN/multinic-remove-fixed-ip-req.xml create mode 100644 doc/api_samples/NMN/server-post-req.json create mode 100644 doc/api_samples/NMN/server-post-req.xml create mode 100644 doc/api_samples/NMN/server-post-resp.json create mode 100644 doc/api_samples/NMN/server-post-resp.xml create mode 100644 nova/tests/integrated/api_samples/NMN/multinic-add-fixed-ip-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/NMN/multinic-add-fixed-ip-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/NMN/multinic-remove-fixed-ip-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/NMN/multinic-remove-fixed-ip-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/NMN/server-post-req.json.tpl create mode 100644 nova/tests/integrated/api_samples/NMN/server-post-req.xml.tpl create mode 100644 nova/tests/integrated/api_samples/NMN/server-post-resp.json.tpl create mode 100644 nova/tests/integrated/api_samples/NMN/server-post-resp.xml.tpl diff --git a/doc/api_samples/NMN/multinic-add-fixed-ip-req.json b/doc/api_samples/NMN/multinic-add-fixed-ip-req.json new file mode 100644 index 000000000000..860308403daa --- /dev/null +++ b/doc/api_samples/NMN/multinic-add-fixed-ip-req.json @@ -0,0 +1,5 @@ +{ + "addFixedIp":{ + "networkId": 1 + } +} diff --git a/doc/api_samples/NMN/multinic-add-fixed-ip-req.xml b/doc/api_samples/NMN/multinic-add-fixed-ip-req.xml new file mode 100644 index 000000000000..4c72212a747a --- /dev/null +++ b/doc/api_samples/NMN/multinic-add-fixed-ip-req.xml @@ -0,0 +1,3 @@ + + 1 + diff --git a/doc/api_samples/NMN/multinic-remove-fixed-ip-req.json b/doc/api_samples/NMN/multinic-remove-fixed-ip-req.json new file mode 100644 index 000000000000..0756d039e425 --- /dev/null +++ b/doc/api_samples/NMN/multinic-remove-fixed-ip-req.json @@ -0,0 +1,5 @@ +{ + "removeFixedIp":{ + "address": "10.0.0.2" + } +} diff --git a/doc/api_samples/NMN/multinic-remove-fixed-ip-req.xml b/doc/api_samples/NMN/multinic-remove-fixed-ip-req.xml new file mode 100644 index 000000000000..4e6ccdd87cf0 --- /dev/null +++ b/doc/api_samples/NMN/multinic-remove-fixed-ip-req.xml @@ -0,0 +1,3 @@ + +
10.0.0.2
+
diff --git a/doc/api_samples/NMN/server-post-req.json b/doc/api_samples/NMN/server-post-req.json new file mode 100644 index 000000000000..d88eb4122223 --- /dev/null +++ b/doc/api_samples/NMN/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/NMN/server-post-req.xml b/doc/api_samples/NMN/server-post-req.xml new file mode 100644 index 000000000000..0a3c8bb5303d --- /dev/null +++ b/doc/api_samples/NMN/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/NMN/server-post-resp.json b/doc/api_samples/NMN/server-post-resp.json new file mode 100644 index 000000000000..09d9fb612fef --- /dev/null +++ b/doc/api_samples/NMN/server-post-resp.json @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "xrDLoBeMD28B", + "id": "3f69b6bd-00a8-4636-96ee-650093624304", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/3f69b6bd-00a8-4636-96ee-650093624304", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/3f69b6bd-00a8-4636-96ee-650093624304", + "rel": "bookmark" + } + ] + } +} \ No newline at end of file diff --git a/doc/api_samples/NMN/server-post-resp.xml b/doc/api_samples/NMN/server-post-resp.xml new file mode 100644 index 000000000000..7f84ac03df9d --- /dev/null +++ b/doc/api_samples/NMN/server-post-resp.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/NMN/multinic-add-fixed-ip-req.json.tpl b/nova/tests/integrated/api_samples/NMN/multinic-add-fixed-ip-req.json.tpl new file mode 100644 index 000000000000..b9744ab2c737 --- /dev/null +++ b/nova/tests/integrated/api_samples/NMN/multinic-add-fixed-ip-req.json.tpl @@ -0,0 +1,5 @@ +{ + "addFixedIp":{ + "networkId": %(networkId)s + } +} diff --git a/nova/tests/integrated/api_samples/NMN/multinic-add-fixed-ip-req.xml.tpl b/nova/tests/integrated/api_samples/NMN/multinic-add-fixed-ip-req.xml.tpl new file mode 100644 index 000000000000..ad1112912921 --- /dev/null +++ b/nova/tests/integrated/api_samples/NMN/multinic-add-fixed-ip-req.xml.tpl @@ -0,0 +1,3 @@ + + %(networkId)s + diff --git a/nova/tests/integrated/api_samples/NMN/multinic-remove-fixed-ip-req.json.tpl b/nova/tests/integrated/api_samples/NMN/multinic-remove-fixed-ip-req.json.tpl new file mode 100644 index 000000000000..7367e1242ceb --- /dev/null +++ b/nova/tests/integrated/api_samples/NMN/multinic-remove-fixed-ip-req.json.tpl @@ -0,0 +1,5 @@ +{ + "removeFixedIp":{ + "address": "%(ip)s" + } +} diff --git a/nova/tests/integrated/api_samples/NMN/multinic-remove-fixed-ip-req.xml.tpl b/nova/tests/integrated/api_samples/NMN/multinic-remove-fixed-ip-req.xml.tpl new file mode 100644 index 000000000000..10b722220f7f --- /dev/null +++ b/nova/tests/integrated/api_samples/NMN/multinic-remove-fixed-ip-req.xml.tpl @@ -0,0 +1,3 @@ + +
%(ip)s
+
diff --git a/nova/tests/integrated/api_samples/NMN/server-post-req.json.tpl b/nova/tests/integrated/api_samples/NMN/server-post-req.json.tpl new file mode 100644 index 000000000000..d3916d1aa68a --- /dev/null +++ b/nova/tests/integrated/api_samples/NMN/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/NMN/server-post-req.xml.tpl b/nova/tests/integrated/api_samples/NMN/server-post-req.xml.tpl new file mode 100644 index 000000000000..f92614984242 --- /dev/null +++ b/nova/tests/integrated/api_samples/NMN/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/NMN/server-post-resp.json.tpl b/nova/tests/integrated/api_samples/NMN/server-post-resp.json.tpl new file mode 100644 index 000000000000..d5f030c8730b --- /dev/null +++ b/nova/tests/integrated/api_samples/NMN/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/NMN/server-post-resp.xml.tpl b/nova/tests/integrated/api_samples/NMN/server-post-resp.xml.tpl new file mode 100644 index 000000000000..3bb13e69bd6d --- /dev/null +++ b/nova/tests/integrated/api_samples/NMN/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 4134a7cf6286..d310b1459051 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -373,7 +373,6 @@ class ApiSamplesTrap(ApiSampleTestBase): # NOT be allowed to grow, and should shrink to zero (and be # removed) soon. do_not_approve_additions = [] - do_not_approve_additions.append('NMN') do_not_approve_additions.append('os-config-drive') do_not_approve_additions.append('os-create-server-ext') do_not_approve_additions.append('os-flavor-access') @@ -2687,4 +2686,28 @@ class FloatingIPPoolsSampleJsonTests(ApiSampleTestBase): class FloatingIPPoolsSampleXmlTests(FloatingIPPoolsSampleJsonTests): + ctype = 'xml' + + +class MultinicSampleJsonTest(ServersSampleBase): + extension_name = "nova.api.openstack.compute.contrib.multinic.Multinic" + + def setUp(self): + super(MultinicSampleJsonTest, self).setUp() + self.uuid = self._post_server() + + def test_add_fixed_ip(self): + subs = {"networkId": 1} + response = self._do_post('servers/%s/action' % (self.uuid), + 'multinic-add-fixed-ip-req', subs) + self.assertEqual(response.status, 202) + + def test_remove_fixed_ip(self): + subs = {"ip": "10.0.0.2"} + response = self._do_post('servers/%s/action' % (self.uuid), + 'multinic-remove-fixed-ip-req', subs) + self.assertEqual(response.status, 202) + + +class MultinicSampleXmlTest(MultinicSampleJsonTest): ctype = "xml"