def allowed(self, request, image=None): project_id = request.session['tenant_id'] # Get the total number of images owned by the user owned_image_count = api.get_image_count(project_id, request) image_limit = api.get_image_quota(project_id) if image_limit > owned_image_count: return True else: return False
def __init__(self, request, *args, **kwargs): super(UpdateProjectQuotaAction, self).__init__(request, *args, **kwargs) if 'project_id' in args[0]: project_id = args[0]['project_id'] self.fields['images'].initial = api.get_image_quota(project_id) self.fields['expiration'].initial = api.get_expiration_date(project_id) self.fields['object_mb'].initial = api.get_object_mb_quota(project_id) else: self.fields['images'].initial = 5 self.fields['expiration'].initial = 'Information not available.' self.fields['object_mb'].initial = 204800
def allowed(self, request, instance=None): #return instance.status in ACTIVE_STATES and not _is_deleting(instance) # jt if instance.status in ACTIVE_STATES and not _is_deleting(instance): # Check the limit to how many images the user can own project_id = request.session['tenant_id'] owned_image_count = api.get_image_count(project_id, request) image_limit = api.get_image_quota(project_id) if image_limit > owned_image_count: return True else: return False else: return False
def get_quotas(self): try: self.quota = api.nova.tenant_quota_usages(self.request) # jt project_id = self.request.session['tenant_id'] owned_image_count = api.get_image_count(project_id, self.request) image_limit = api.get_image_quota(project_id) self.quota['images'] = {'used': owned_image_count, 'quota': image_limit} self.quota['expiration'] = api.get_expiration_date(project_id) object_mb_usage = api.get_object_mb_usage(project_id) object_mb_limit = api.get_object_mb_quota(project_id) self.quota['object_mb'] = {'used': object_mb_usage, 'quota': object_mb_limit} except: exceptions.handle(self.request, _("Unable to retrieve quota information."))