diff --git a/doc/api_samples/os-virtual-interfaces/server-post-req.json b/doc/api_samples/os-virtual-interfaces/server-post-req.json new file mode 100644 index 000000000000..d88eb4122223 --- /dev/null +++ b/doc/api_samples/os-virtual-interfaces/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-virtual-interfaces/server-post-req.xml b/doc/api_samples/os-virtual-interfaces/server-post-req.xml new file mode 100644 index 000000000000..0a3c8bb5303d --- /dev/null +++ b/doc/api_samples/os-virtual-interfaces/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-virtual-interfaces/server-post-resp.json b/doc/api_samples/os-virtual-interfaces/server-post-resp.json new file mode 100644 index 000000000000..f8379cbb3f5e --- /dev/null +++ b/doc/api_samples/os-virtual-interfaces/server-post-resp.json @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "m62Pu3gkXXV2", + "id": "a98dd3ae-5feb-4b4b-afa4-25e830ad3305", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/a98dd3ae-5feb-4b4b-afa4-25e830ad3305", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/a98dd3ae-5feb-4b4b-afa4-25e830ad3305", + "rel": "bookmark" + } + ] + } +} \ No newline at end of file diff --git a/doc/api_samples/os-virtual-interfaces/server-post-resp.xml b/doc/api_samples/os-virtual-interfaces/server-post-resp.xml new file mode 100644 index 000000000000..d620ed00b066 --- /dev/null +++ b/doc/api_samples/os-virtual-interfaces/server-post-resp.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/doc/api_samples/os-virtual-interfaces/vifs-list-resp.json b/doc/api_samples/os-virtual-interfaces/vifs-list-resp.json new file mode 100644 index 000000000000..c2e62b6ebd06 --- /dev/null +++ b/doc/api_samples/os-virtual-interfaces/vifs-list-resp.json @@ -0,0 +1,8 @@ +{ + "virtual_interfaces": [ + { + "id": "cec8b9bb-5d22-4104-b3c8-4c35db3210a6", + "mac_address": "fa:16:3e:3c:ce:6f" + } + ] +} \ No newline at end of file diff --git a/doc/api_samples/os-virtual-interfaces/vifs-list-resp.xml b/doc/api_samples/os-virtual-interfaces/vifs-list-resp.xml new file mode 100644 index 000000000000..73aafe09b012 --- /dev/null +++ b/doc/api_samples/os-virtual-interfaces/vifs-list-resp.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-virtual-interfaces/server-post-req.json.tpl b/nova/tests/integrated/api_samples/os-virtual-interfaces/server-post-req.json.tpl new file mode 100644 index 000000000000..d3916d1aa68a --- /dev/null +++ b/nova/tests/integrated/api_samples/os-virtual-interfaces/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-virtual-interfaces/server-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-virtual-interfaces/server-post-req.xml.tpl new file mode 100644 index 000000000000..f92614984242 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-virtual-interfaces/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-virtual-interfaces/server-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-virtual-interfaces/server-post-resp.json.tpl new file mode 100644 index 000000000000..d5f030c8730b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-virtual-interfaces/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-virtual-interfaces/server-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-virtual-interfaces/server-post-resp.xml.tpl new file mode 100644 index 000000000000..3bb13e69bd6d --- /dev/null +++ b/nova/tests/integrated/api_samples/os-virtual-interfaces/server-post-resp.xml.tpl @@ -0,0 +1,6 @@ + + + + + + diff --git a/nova/tests/integrated/api_samples/os-virtual-interfaces/vifs-list-resp.json.tpl b/nova/tests/integrated/api_samples/os-virtual-interfaces/vifs-list-resp.json.tpl new file mode 100644 index 000000000000..af0b7e05a795 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-virtual-interfaces/vifs-list-resp.json.tpl @@ -0,0 +1,8 @@ +{ + "virtual_interfaces": [ + { + "id": "%(id)s", + "mac_address": "%(mac_addr)s" + } + ] +} \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-virtual-interfaces/vifs-list-resp.xml.tpl b/nova/tests/integrated/api_samples/os-virtual-interfaces/vifs-list-resp.xml.tpl new file mode 100644 index 000000000000..74d0c6f39461 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-virtual-interfaces/vifs-list-resp.xml.tpl @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index fc6288c388e0..c9d0fddd72de 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -964,3 +964,23 @@ class RescueJsonTest(ServersSampleBase): class RescueXmlTest(RescueJsonTest): ctype = 'xml' + + +class VirtualInterfacesJsonTest(ServersSampleBase): + extension_name = ("nova.api.openstack.compute.contrib" + ".virtual_interfaces.Virtual_interfaces") + + def test_vifs_list(self): + uuid = self._post_server() + + response = self._do_get('servers/%s/os-virtual-interfaces' % uuid) + self.assertEqual(response.status, 200) + + subs = self._get_regexes() + subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}' + + self._verify_response('vifs-list-resp', subs, response) + + +class VirtualInterfacesXmlTest(VirtualInterfacesJsonTest): + ctype = 'xml'