OpenStack Compute (Nova) Client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

quota_classes.py 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # Copyright 2012 OpenStack Foundation
  2. # All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  5. # not use this file except in compliance with the License. You may obtain
  6. # a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. # License for the specific language governing permissions and limitations
  14. # under the License.
  15. from novaclient import base
  16. class QuotaClassSet(base.Resource):
  17. def update(self, *args, **kwargs):
  18. return self.manager.update(self.id, *args, **kwargs)
  19. class QuotaClassSetManager(base.Manager):
  20. resource_class = QuotaClassSet
  21. def get(self, class_name):
  22. return self._get("/os-quota-class-sets/%s" % (class_name),
  23. "quota_class_set")
  24. def _update_body(self, **kwargs):
  25. return {'quota_class_set': kwargs}
  26. def update(self, class_name, **kwargs):
  27. body = self._update_body(**kwargs)
  28. for key in list(body['quota_class_set']):
  29. if body['quota_class_set'][key] is None:
  30. body['quota_class_set'].pop(key)
  31. return self._update('/os-quota-class-sets/%s' % (class_name),
  32. body,
  33. 'quota_class_set')