Add new detail kwarg to show_quota_set to QuotasClient.
Currently, quotas_client.QuotasClient doesn't support the
'os-quota-sets/{tenant_id}/detail' endpoint [0] but is supported
by Nova [1].
Nova uses the policy 'os_compute_api:os-quota-sets:detail'
for the endpoint ending with /detail and
'os_compute_api:os-quota-sets:show' without the /detail uri [2].
This is needed by Patrole for complete test coverage for Nova.
This patch adds the kwarg to show_quota_set which calls the '/detail'
endpoint, if True. Also updated quotas schema with
get_quota_set_details, because each property in the response body
is of type object, not integer [1].
[0] https://github.com/openstack/tempest/blob/master/tempest/lib/services/compute/quotas_client.py
[1] https://developer.openstack.org/api-ref/compute/?expanded=show-the-detail-of-quota-detail#show-the-detail-of-quota
[2] https://github.com/openstack/nova/blob/master/nova/policies/quota_sets.py
Change-Id: I9a65411c6bf65bf20842719bffe46c7fa7db82eb
Closes-Bug: #1662593
diff --git a/tempest/lib/services/compute/quotas_client.py b/tempest/lib/services/compute/quotas_client.py
index a2b0397..3839c74 100644
--- a/tempest/lib/services/compute/quotas_client.py
+++ b/tempest/lib/services/compute/quotas_client.py
@@ -14,6 +14,7 @@
# under the License.
from oslo_serialization import jsonutils as json
+from six.moves.urllib import parse as urllib
from tempest.lib.api_schema.response.compute.v2_1 import quotas as schema
from tempest.lib.common import rest_client
@@ -22,15 +23,29 @@
class QuotasClient(base_compute_client.BaseComputeClient):
- def show_quota_set(self, tenant_id, user_id=None):
- """List the quota set for a tenant."""
+ def show_quota_set(self, tenant_id, user_id=None, detail=False):
+ """List the quota set for a tenant.
+ For a full list of available parameters, please refer to the official
+ API reference:
+ http://developer.openstack.org/api-ref-compute-v2.1.html/#show-a-quota
+ http://developer.openstack.org/api-ref-compute-v2.1.html/#show-the-detail-of-quota
+ """
+
+ params = {}
url = 'os-quota-sets/%s' % tenant_id
+ if detail:
+ url += '/detail'
if user_id:
- url += '?user_id=%s' % user_id
+ params.update({'user_id': user_id})
+ if params:
+ url += '?%s' % urllib.urlencode(params)
resp, body = self.get(url)
body = json.loads(body)
- self.validate_response(schema.get_quota_set, resp, body)
+ if detail:
+ self.validate_response(schema.get_quota_set_details, resp, body)
+ else:
+ self.validate_response(schema.get_quota_set, resp, body)
return rest_client.ResponseBody(resp, body)
def show_default_quota_set(self, tenant_id):