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 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. @property
  18. def id(self):
  19. """QuotaClassSet does not have a 'id' attribute but base.Resource
  20. needs it to self-refresh and QuotaSet is indexed by class_name"""
  21. return self.class_name
  22. def update(self, *args, **kwargs):
  23. return self.manager.update(self.class_name, *args, **kwargs)
  24. class QuotaClassSetManager(base.Manager):
  25. resource_class = QuotaClassSet
  26. def get(self, class_name):
  27. return self._get("/os-quota-class-sets/%s" % (class_name),
  28. "quota_class_set")
  29. def update(self, class_name, metadata_items=None,
  30. injected_file_content_bytes=None, injected_file_path_bytes=None,
  31. volumes=None, gigabytes=None,
  32. ram=None, floating_ips=None, instances=None,
  33. injected_files=None, cores=None, key_pairs=None,
  34. security_groups=None, security_group_rules=None):
  35. body = {'quota_class_set': {
  36. 'class_name': class_name,
  37. 'metadata_items': metadata_items,
  38. 'key_pairs': key_pairs,
  39. 'injected_file_content_bytes': injected_file_content_bytes,
  40. 'injected_file_path_bytes': injected_file_path_bytes,
  41. 'volumes': volumes,
  42. 'gigabytes': gigabytes,
  43. 'ram': ram,
  44. 'floating_ips': floating_ips,
  45. 'instances': instances,
  46. 'injected_files': injected_files,
  47. 'cores': cores,
  48. 'security_groups': security_groups,
  49. 'security_group_rules': security_group_rules}}
  50. for key in body['quota_class_set'].keys():
  51. if body['quota_class_set'][key] is None:
  52. body['quota_class_set'].pop(key)
  53. return self._update('/os-quota-class-sets/%s' % (class_name),
  54. body,
  55. 'quota_class_set')