diff --git a/doc/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json b/doc/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json new file mode 100644 index 000000000000..e4d0a5b47f98 --- /dev/null +++ b/doc/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json @@ -0,0 +1,16 @@ +{ + "quota_class_set": { + "cores": 20, + "floating_ips": 10, + "id": "test_class", + "injected_file_content_bytes": 10240, + "injected_file_path_bytes": 255, + "injected_files": 5, + "instances": 10, + "key_pairs": 100, + "metadata_items": 128, + "ram": 51200, + "security_group_rules": 20, + "security_groups": 10 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-class-sets/quota-classes-show-get-resp.xml b/doc/api_samples/os-quota-class-sets/quota-classes-show-get-resp.xml new file mode 100644 index 000000000000..74532bc98d64 --- /dev/null +++ b/doc/api_samples/os-quota-class-sets/quota-classes-show-get-resp.xml @@ -0,0 +1,14 @@ + + + 20 + 10 + 10240 + 255 + 5 + 10 + 100 + 128 + 51200 + 20 + 10 + \ No newline at end of file diff --git a/doc/api_samples/os-quota-class-sets/quota-classes-update-post-req.json b/doc/api_samples/os-quota-class-sets/quota-classes-update-post-req.json new file mode 100644 index 000000000000..f074c829ffaa --- /dev/null +++ b/doc/api_samples/os-quota-class-sets/quota-classes-update-post-req.json @@ -0,0 +1,15 @@ +{ + "quota_class_set": { + "instances": 50, + "cores": 50, + "ram": 51200, + "floating_ips": 10, + "metadata_items": 128, + "injected_files": 5, + "injected_file_content_bytes": 10240, + "injected_file_path_bytes": 255, + "security_groups": 10, + "security_group_rules": 20, + "key_pairs": 100 + } +} diff --git a/doc/api_samples/os-quota-class-sets/quota-classes-update-post-req.xml b/doc/api_samples/os-quota-class-sets/quota-classes-update-post-req.xml new file mode 100644 index 000000000000..d14785482022 --- /dev/null +++ b/doc/api_samples/os-quota-class-sets/quota-classes-update-post-req.xml @@ -0,0 +1,14 @@ + + + 50 + 10 + 10240 + 255 + 5 + 50 + 100 + 128 + 51200 + 20 + 10 + diff --git a/doc/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json b/doc/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json new file mode 100644 index 000000000000..99a11f4ffd23 --- /dev/null +++ b/doc/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json @@ -0,0 +1,15 @@ +{ + "quota_class_set": { + "cores": 50, + "floating_ips": 10, + "injected_file_content_bytes": 10240, + "injected_file_path_bytes": 255, + "injected_files": 5, + "instances": 50, + "key_pairs": 100, + "metadata_items": 128, + "ram": 51200, + "security_group_rules": 20, + "security_groups": 10 + } +} \ No newline at end of file diff --git a/doc/api_samples/os-quota-class-sets/quota-classes-update-post-resp.xml b/doc/api_samples/os-quota-class-sets/quota-classes-update-post-resp.xml new file mode 100644 index 000000000000..44c658a410cb --- /dev/null +++ b/doc/api_samples/os-quota-class-sets/quota-classes-update-post-resp.xml @@ -0,0 +1,14 @@ + + + 50 + 10 + 10240 + 255 + 5 + 50 + 100 + 128 + 51200 + 20 + 10 + \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json.tpl b/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json.tpl new file mode 100644 index 000000000000..4b430ad7cb3b --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-show-get-resp.json.tpl @@ -0,0 +1,16 @@ +{ + "quota_class_set": { + "cores": 20, + "floating_ips": 10, + "id": "%(set_id)s", + "injected_file_content_bytes": 10240, + "injected_file_path_bytes": 255, + "injected_files": 5, + "instances": 10, + "key_pairs": 100, + "metadata_items": 128, + "ram": 51200, + "security_group_rules": 20, + "security_groups": 10 + } +} diff --git a/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-show-get-resp.xml.tpl b/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-show-get-resp.xml.tpl new file mode 100644 index 000000000000..3dffd47f06ba --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-show-get-resp.xml.tpl @@ -0,0 +1,14 @@ + + + 20 + 10 + 10240 + 255 + 5 + 10 + 100 + 128 + 51200 + 20 + 10 + diff --git a/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-update-post-req.json.tpl b/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-update-post-req.json.tpl new file mode 100644 index 000000000000..f074c829ffaa --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-update-post-req.json.tpl @@ -0,0 +1,15 @@ +{ + "quota_class_set": { + "instances": 50, + "cores": 50, + "ram": 51200, + "floating_ips": 10, + "metadata_items": 128, + "injected_files": 5, + "injected_file_content_bytes": 10240, + "injected_file_path_bytes": 255, + "security_groups": 10, + "security_group_rules": 20, + "key_pairs": 100 + } +} diff --git a/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-update-post-req.xml.tpl b/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-update-post-req.xml.tpl new file mode 100644 index 000000000000..d14785482022 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-update-post-req.xml.tpl @@ -0,0 +1,14 @@ + + + 50 + 10 + 10240 + 255 + 5 + 50 + 100 + 128 + 51200 + 20 + 10 + diff --git a/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json.tpl b/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json.tpl new file mode 100644 index 000000000000..99a11f4ffd23 --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-update-post-resp.json.tpl @@ -0,0 +1,15 @@ +{ + "quota_class_set": { + "cores": 50, + "floating_ips": 10, + "injected_file_content_bytes": 10240, + "injected_file_path_bytes": 255, + "injected_files": 5, + "instances": 50, + "key_pairs": 100, + "metadata_items": 128, + "ram": 51200, + "security_group_rules": 20, + "security_groups": 10 + } +} \ No newline at end of file diff --git a/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-update-post-resp.xml.tpl b/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-update-post-resp.xml.tpl new file mode 100644 index 000000000000..44c658a410cb --- /dev/null +++ b/nova/tests/integrated/api_samples/os-quota-class-sets/quota-classes-update-post-resp.xml.tpl @@ -0,0 +1,14 @@ + + + 50 + 10 + 10240 + 255 + 5 + 50 + 100 + 128 + 51200 + 20 + 10 + \ 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 e5f3b9ad5a4f..1802998445eb 100644 --- a/nova/tests/integrated/test_api_samples.py +++ b/nova/tests/integrated/test_api_samples.py @@ -372,7 +372,6 @@ class ApiSamplesTrap(ApiSampleTestBase): do_not_approve_additions.append('os-hypervisors') do_not_approve_additions.append('os-instance_usage_audit_log') do_not_approve_additions.append('os-networks') - do_not_approve_additions.append('os-quota-class-sets') do_not_approve_additions.append('os-services') do_not_approve_additions.append('os-volumes') @@ -2305,3 +2304,30 @@ class FlavorDisabledSampleJsonTests(ApiSampleTestBase): class FlavorDisabledSampleXmlTests(FlavorDisabledSampleJsonTests): ctype = "xml" + + +class QuotaClassesSampleJsonTests(ApiSampleTestBase): + extension_name = ("nova.api.openstack.compute.contrib.quota_classes." + "Quota_classes") + set_id = 'test_class' + + def test_show_quota_classes(self): + """Get api sample to show quota classes""" + response = self._do_get('os-quota-class-sets/%s' % self.set_id) + self.assertEqual(response.status, 200) + subs = {'set_id': self.set_id} + return self._verify_response('quota-classes-show-get-resp', subs, + response) + + def test_update_quota_classes(self): + """Get api sample to update quota classes""" + response = self._do_put('os-quota-class-sets/%s' % self.set_id, + 'quota-classes-update-post-req', + {}) + self.assertEqual(response.status, 200) + return self._verify_response('quota-classes-update-post-resp', + {}, response) + + +class QuotaClassesSampleXmlTests(QuotaClassesSampleJsonTests): + ctype = "xml"