def check_quota(context, image_size, db_api, image_id=None):
 remaining = get_remaining_quota(context, db_api, image_id=image_id)
 if (remaining is None):
  return
 user = getattr(context, 'user', '<unknown>')
 if (image_size is None):
  if (remaining <= 0):
   LOG.warn((_LW('User %(user)s attempted to upload an image of unknown size that will exceed the quota. %(remaining)d bytes remaining.') % {'user': user, 'remaining': remaining}))
   raise exception.StorageQuotaFull(image_size=image_size, remaining=remaining)
  return
 if (image_size > remaining):
  LOG.warn((_LW('User %(user)s attempted to upload an image of size %(size)d that will exceed the quota. %(remaining)d bytes remaining.') % {'user': user, 'size': image_size, 'remaining': remaining}))
  raise exception.StorageQuotaFull(image_size=image_size, remaining=remaining)
 return remaining

def check_quota ( context , image_size , db_api , image_id = None ) : remaining = get_remaining_quota ( context , db_api , image_id = image_id ) if ( remaining is None ) : return user = getattr ( context , 'user' , '<unknown>' ) if ( image_size is None ) : if ( remaining <= 0 ) : LOG . warn ( ( _LW ( 'User %(user)s attempted to upload an image of unknown size that will exceed the quota. %(remaining)d bytes remaining.' ) % { 'user' : user , 'remaining' : remaining } ) ) raise exception . StorageQuotaFull ( image_size = image_size , remaining = remaining ) return if ( image_size > remaining ) : LOG . warn ( ( _LW ( 'User %(user)s attempted to upload an image of size %(size)d that will exceed the quota. %(remaining)d bytes remaining.' ) % { 'user' : user , 'size' : image_size , 'remaining' : remaining } ) ) raise exception . StorageQuotaFull ( image_size = image_size , remaining = remaining ) return remaining
method called to see if the user is allowed to store an image .