def create_class(cls, context, class_name, resource, limit): try: db.quota_class_get(context, class_name, resource) except exception.QuotaClassNotFound: cls._create_class_in_db(context, class_name, resource, limit) else: raise exception.QuotaClassExists(class_name=class_name, resource=resource)
def get_by_class(self, context, quota_class, resource): """Get a specific quota by quota class.""" return db.quota_class_get(context, quota_class, resource)
def get_class(cls, context, class_name, resource): try: qclass = cls._get_class_from_db(context, class_name, resource) except exception.QuotaClassNotFound: qclass = db.quota_class_get(context, class_name, resource) return qclass