diff --git a/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-req.json b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-req.json new file mode 100644 index 000000000000..63fc8738b03a --- /dev/null +++ b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-req.json @@ -0,0 +1,6 @@ +{ + "extra_specs": { + "key1": "value1", + "key2": "value2" + } +} \ No newline at end of file diff --git a/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-req.xml b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-req.xml new file mode 100644 index 000000000000..95c1daab9fd2 --- /dev/null +++ b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-req.xml @@ -0,0 +1,5 @@ + + + value1 + value2 + \ No newline at end of file diff --git a/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-resp.json b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-resp.json new file mode 100644 index 000000000000..63fc8738b03a --- /dev/null +++ b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-resp.json @@ -0,0 +1,6 @@ +{ + "extra_specs": { + "key1": "value1", + "key2": "value2" + } +} \ No newline at end of file diff --git a/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-resp.xml b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-resp.xml new file mode 100644 index 000000000000..06b01a9fca11 --- /dev/null +++ b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-resp.xml @@ -0,0 +1,5 @@ + + + value2 + value1 + \ No newline at end of file diff --git a/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-get-resp.json b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-get-resp.json new file mode 100644 index 000000000000..e71755fe675a --- /dev/null +++ b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-get-resp.json @@ -0,0 +1,3 @@ +{ + "key1": "value1" +} \ No newline at end of file diff --git a/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-get-resp.xml b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-get-resp.xml new file mode 100644 index 000000000000..d57579ba64b4 --- /dev/null +++ b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-get-resp.xml @@ -0,0 +1,2 @@ + +value1 \ No newline at end of file diff --git a/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-list-resp.json b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-list-resp.json new file mode 100644 index 000000000000..63fc8738b03a --- /dev/null +++ b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-list-resp.json @@ -0,0 +1,6 @@ +{ + "extra_specs": { + "key1": "value1", + "key2": "value2" + } +} \ No newline at end of file diff --git a/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-list-resp.xml b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-list-resp.xml new file mode 100644 index 000000000000..06b01a9fca11 --- /dev/null +++ b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-list-resp.xml @@ -0,0 +1,5 @@ + + + value2 + value1 + \ No newline at end of file diff --git a/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-req.json b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-req.json new file mode 100644 index 000000000000..a40d79e320cf --- /dev/null +++ b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-req.json @@ -0,0 +1,3 @@ +{ + "key1": "new_value1" +} \ No newline at end of file diff --git a/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-req.xml b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-req.xml new file mode 100644 index 000000000000..b7ae6732b4e3 --- /dev/null +++ b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-req.xml @@ -0,0 +1,2 @@ + + new_value1 \ No newline at end of file diff --git a/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-resp.json b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-resp.json new file mode 100644 index 000000000000..a40d79e320cf --- /dev/null +++ b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-resp.json @@ -0,0 +1,3 @@ +{ + "key1": "new_value1" +} \ No newline at end of file diff --git a/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-resp.xml b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-resp.xml new file mode 100644 index 000000000000..13208ad7c953 --- /dev/null +++ b/doc/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-resp.xml @@ -0,0 +1,2 @@ + +new_value1 \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-req.json.tpl b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-req.json.tpl new file mode 100644 index 000000000000..dd858e76c5e4 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-req.json.tpl @@ -0,0 +1,6 @@ +{ + "extra_specs": { + "key1": "%(value1)s", + "key2": "%(value2)s" + } +} diff --git a/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-req.xml.tpl b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-req.xml.tpl new file mode 100644 index 000000000000..c94595cad102 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-req.xml.tpl @@ -0,0 +1,5 @@ + + + %(value1)s + %(value2)s + diff --git a/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-resp.json.tpl b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-resp.json.tpl new file mode 100644 index 000000000000..dd858e76c5e4 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-resp.json.tpl @@ -0,0 +1,6 @@ +{ + "extra_specs": { + "key1": "%(value1)s", + "key2": "%(value2)s" + } +} diff --git a/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-resp.xml.tpl b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-resp.xml.tpl new file mode 100644 index 000000000000..1008b5bb0e5c --- /dev/null +++ b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-create-resp.xml.tpl @@ -0,0 +1,5 @@ + + + %(value2)s + %(value1)s + diff --git a/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-get-resp.json.tpl b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-get-resp.json.tpl new file mode 100644 index 000000000000..adfa77008f6d --- /dev/null +++ b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-get-resp.json.tpl @@ -0,0 +1,3 @@ +{ + "key1": "%(value1)s" +} diff --git a/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-get-resp.xml.tpl b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-get-resp.xml.tpl new file mode 100644 index 000000000000..e3de59a34284 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-get-resp.xml.tpl @@ -0,0 +1,2 @@ + +%(value1)s diff --git a/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-list-resp.json.tpl b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-list-resp.json.tpl new file mode 100644 index 000000000000..dd858e76c5e4 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-list-resp.json.tpl @@ -0,0 +1,6 @@ +{ + "extra_specs": { + "key1": "%(value1)s", + "key2": "%(value2)s" + } +} diff --git a/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-list-resp.xml.tpl b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-list-resp.xml.tpl new file mode 100644 index 000000000000..1008b5bb0e5c --- /dev/null +++ b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-list-resp.xml.tpl @@ -0,0 +1,5 @@ + + + %(value2)s + %(value1)s + diff --git a/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-req.json.tpl b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-req.json.tpl new file mode 100644 index 000000000000..adfa77008f6d --- /dev/null +++ b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-req.json.tpl @@ -0,0 +1,3 @@ +{ + "key1": "%(value1)s" +} diff --git a/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-req.xml.tpl b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-req.xml.tpl new file mode 100644 index 000000000000..6421e5959237 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-req.xml.tpl @@ -0,0 +1,2 @@ + + %(value1)s diff --git a/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-resp.json.tpl b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-resp.json.tpl new file mode 100644 index 000000000000..adfa77008f6d --- /dev/null +++ b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-resp.json.tpl @@ -0,0 +1,3 @@ +{ + "key1": "%(value1)s" +} diff --git a/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-resp.xml.tpl b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-resp.xml.tpl new file mode 100644 index 000000000000..e3de59a34284 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-flavor-extra-specs/flavor-extra-specs-update-resp.xml.tpl @@ -0,0 +1,2 @@ + +%(value1)s diff --git a/nova/tests/integrated/test_api_samples.py b/nova/tests/integrated/test_api_samples.py index 080e4e92b792..eafc31c616c6 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -377,7 +377,6 @@ class ApiSamplesTrap(ApiSampleTestBase): 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') - do_not_approve_additions.append('os-flavor-extra-specs') do_not_approve_additions.append('os-floating-ip-dns') do_not_approve_additions.append('os-fping') do_not_approve_additions.append('os-hypervisors') @@ -2712,4 +2711,59 @@ class InstanceUsageAuditLogJsonTest(ApiSampleTestBase): class InstanceUsageAuditLogXmlTest(InstanceUsageAuditLogJsonTest): + ctype = "xml" + + +class FlavorExtraSpecsSampleJsonTests(ApiSampleTestBase): + extension_name = ("nova.api.openstack.compute.contrib.flavorextraspecs." + "Flavorextraspecs") + + def _flavor_extra_specs_create(self): + subs = {'value1': 'value1', + 'value2': 'value2' + } + response = self._do_post('flavors/1/os-extra_specs', + 'flavor-extra-specs-create-req', subs) + self.assertEqual(response.status, 200) + return self._verify_response('flavor-extra-specs-create-resp', + subs, response) + + def test_flavor_extra_specs_get(self): + subs = {'value1': 'value1'} + self._flavor_extra_specs_create() + response = self._do_get('flavors/1/os-extra_specs/key1') + self.assertEqual(response.status, 200) + return self._verify_response('flavor-extra-specs-get-resp', + subs, response) + + def test_flavor_extra_specs_list(self): + subs = {'value1': 'value1', + 'value2': 'value2' + } + self._flavor_extra_specs_create() + response = self._do_get('flavors/1/os-extra_specs') + self.assertEqual(response.status, 200) + return self._verify_response('flavor-extra-specs-list-resp', + subs, response) + + def test_flavor_extra_specs_create(self): + return self._flavor_extra_specs_create() + + def test_flavor_extra_specs_update(self): + subs = {'value1': 'new_value1'} + self._flavor_extra_specs_create() + response = self._do_put('flavors/1/os-extra_specs/key1', + 'flavor-extra-specs-update-req', subs) + self.assertEqual(response.status, 200) + return self._verify_response('flavor-extra-specs-update-resp', + subs, response) + + def test_flavor_extra_specs_delete(self): + self._flavor_extra_specs_create() + response = self._do_delete('flavors/1/os-extra_specs/key1') + self.assertEqual(response.status, 200) + self.assertEqual(response.read(), '') + + +class FlavorExtraSpecsSampleXmlTests(FlavorExtraSpecsSampleJsonTests): ctype = 'xml'