diff --git a/doc/api_samples/os-multiple-create/multiple-create-no-resv-post-req.json b/doc/api_samples/os-multiple-create/multiple-create-no-resv-post-req.json new file mode 100644 index 000000000000..0408620b25a9 --- /dev/null +++ b/doc/api_samples/os-multiple-create/multiple-create-no-resv-post-req.json @@ -0,0 +1,18 @@ +{ + "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" + }, + "min_count": "2", + "max_count": "3", + "personality" : [ + { + "path" : "/etc/banner.txt", + "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" + } + ] + } +} \ No newline at end of file diff --git a/doc/api_samples/os-multiple-create/multiple-create-no-resv-post-req.xml b/doc/api_samples/os-multiple-create/multiple-create-no-resv-post-req.xml new file mode 100644 index 000000000000..7ed374b3f869 --- /dev/null +++ b/doc/api_samples/os-multiple-create/multiple-create-no-resv-post-req.xml @@ -0,0 +1,24 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + \ No newline at end of file diff --git a/doc/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.json b/doc/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.json new file mode 100644 index 000000000000..5024d777c215 --- /dev/null +++ b/doc/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.json @@ -0,0 +1,16 @@ +{ + "server": { + "adminPass": "wfksH3GTTseP", + "id": "440cf918-3ee0-4143-b289-f63e1d2000e6", + "links": [ + { + "href": "http://openstack.example.com/v2/openstack/servers/440cf918-3ee0-4143-b289-f63e1d2000e6", + "rel": "self" + }, + { + "href": "http://openstack.example.com/openstack/servers/440cf918-3ee0-4143-b289-f63e1d2000e6", + "rel": "bookmark" + } + ] + } +} \ No newline at end of file diff --git a/doc/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.xml b/doc/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.xml new file mode 100644 index 000000000000..de1df128dd8e --- /dev/null +++ b/doc/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/doc/api_samples/os-multiple-create/multiple-create-post-req.json b/doc/api_samples/os-multiple-create/multiple-create-post-req.json new file mode 100644 index 000000000000..df90cfd5cdc5 --- /dev/null +++ b/doc/api_samples/os-multiple-create/multiple-create-post-req.json @@ -0,0 +1,19 @@ +{ + "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" + }, + "return_reservation_id": "True", + "min_count": "2", + "max_count": "3", + "personality" : [ + { + "path" : "/etc/banner.txt", + "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" + } + ] + } +} \ No newline at end of file diff --git a/doc/api_samples/os-multiple-create/multiple-create-post-req.xml b/doc/api_samples/os-multiple-create/multiple-create-post-req.xml new file mode 100644 index 000000000000..abe36f7ff60a --- /dev/null +++ b/doc/api_samples/os-multiple-create/multiple-create-post-req.xml @@ -0,0 +1,25 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + \ No newline at end of file diff --git a/doc/api_samples/os-multiple-create/multiple-create-post-resp.json b/doc/api_samples/os-multiple-create/multiple-create-post-resp.json new file mode 100644 index 000000000000..a67d680a11c4 --- /dev/null +++ b/doc/api_samples/os-multiple-create/multiple-create-post-resp.json @@ -0,0 +1,3 @@ +{ + "reservation_id": "r-3fhpjulh" +} \ No newline at end of file diff --git a/doc/api_samples/os-multiple-create/multiple-create-post-resp.xml b/doc/api_samples/os-multiple-create/multiple-create-post-resp.xml new file mode 100644 index 000000000000..84a400061a10 --- /dev/null +++ b/doc/api_samples/os-multiple-create/multiple-create-post-resp.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.json.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.json.tpl new file mode 100644 index 000000000000..a7690d7b699d --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.json.tpl @@ -0,0 +1,18 @@ +{ + "server" : { + "name" : "new-server-test", + "imageRef" : "%(host)s/openstack/images/%(image_id)s", + "flavorRef" : "%(host)s/openstack/flavors/1", + "metadata" : { + "My Server Name" : "Apache1" + }, + "min_count": "%(min_count)s", + "max_count": "%(max_count)s", + "personality" : [ + { + "path" : "/etc/banner.txt", + "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.xml.tpl new file mode 100644 index 000000000000..1548974da30f --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-req.xml.tpl @@ -0,0 +1,24 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.json.tpl new file mode 100644 index 000000000000..d5f030c8730b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-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-multiple-create/multiple-create-no-resv-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.xml.tpl new file mode 100644 index 000000000000..2ad5c102b088 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-no-resv-post-resp.xml.tpl @@ -0,0 +1,8 @@ + + + + + + diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.json.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.json.tpl new file mode 100644 index 000000000000..9984c0588434 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.json.tpl @@ -0,0 +1,19 @@ +{ + "server" : { + "name" : "new-server-test", + "imageRef" : "%(host)s/openstack/images/%(image_id)s", + "flavorRef" : "%(host)s/openstack/flavors/1", + "metadata" : { + "My Server Name" : "Apache1" + }, + "return_reservation_id": "True", + "min_count": "%(min_count)s", + "max_count": "%(max_count)s", + "personality" : [ + { + "path" : "/etc/banner.txt", + "contents" : "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBpdCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5kIGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVsc2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4gQnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRoZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlvdSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vyc2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6b25zLiINCg0KLVJpY2hhcmQgQmFjaA==" + } + ] + } +} diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.xml.tpl new file mode 100644 index 000000000000..7ac9b23d670c --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-req.xml.tpl @@ -0,0 +1,25 @@ + + + + Apache1 + + + + ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp + dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k + IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs + c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g + QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo + ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv + dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy + c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 + b25zLiINCg0KLVJpY2hhcmQgQmFjaA== + + + diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.json.tpl new file mode 100644 index 000000000000..22d2880feb6a --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.json.tpl @@ -0,0 +1,3 @@ +{ + "reservation_id": "%(reservation_id)s" +} diff --git a/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.xml.tpl new file mode 100644 index 000000000000..a361612b22ad --- /dev/null +++ b/nova/tests/integrated/api_samples/os-multiple-create/multiple-create-post-resp.xml.tpl @@ -0,0 +1,4 @@ + + + + diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 9aca460cf0ca..bc1dcda86ff9 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -224,6 +224,7 @@ class ApiSampleTestBase(integrated_helpers._IntegratedTestBase): '-[0-9a-f]{4}-[0-9a-f]{12})', 'uuid': '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}' '-[0-9a-f]{4}-[0-9a-f]{12}', + 'reservation_id': 'r-[0-9a-zA-Z]{8}', 'private_key': '-----BEGIN RSA PRIVATE KEY-----' '[a-zA-Z0-9\n/+=]*' '-----END RSA PRIVATE KEY-----', @@ -1171,3 +1172,39 @@ class CertificatesSamplesJsonTest(ApiSampleTestBase): class CertificatesSamplesXmlTest(CertificatesSamplesJsonTest): ctype = "xml" + + +class MultipleCreateJsonTest(ServersSampleBase): + extension_name = ("nova.api.openstack.compute.contrib.multiple_create." + "Multiple_create") + + def test_multiple_create(self): + subs = { + 'image_id': fake.get_valid_image_id(), + 'host': self._get_host(), + 'min_count': "2", + 'max_count': "3" + } + response = self._do_post('servers', 'multiple-create-post-req', subs) + self.assertEqual(response.status, 202) + subs.update(self._get_regexes()) + return self._verify_response('multiple-create-post-resp', + subs, response) + + def test_multiple_create_without_reservation_id(self): + subs = { + 'image_id': fake.get_valid_image_id(), + 'host': self._get_host(), + 'min_count': "2", + 'max_count': "3" + } + response = self._do_post('servers', 'multiple-create-no-resv-post-req', + subs) + self.assertEqual(response.status, 202) + subs.update(self._get_regexes()) + return self._verify_response('multiple-create-no-resv-post-resp', + subs, response) + + +class MultipleCreateXmlTest(MultipleCreateJsonTest): + ctype = 'xml'