83
if quota.allowed_volumes(context, 1, size) < 1:
83
result = quota.allowed_volumes(context, 1, size)
85
overs = result['overs']
86
usages = result['usages']
87
quotas = result['quotas']
88
allowed = result['allowed']
90
if allowed['volumes'] < 1:
84
91
pid = context.project_id
85
LOG.warn(_("Quota exceeded for %(pid)s, tried to create"
86
" %(size)sG volume") % locals())
87
raise exception.QuotaError(code="VolumeSizeTooLarge")
92
if 'gigabytes' in overs:
93
consumed = usages['gigabytes']
94
limit = quotas['gigabytes']
95
LOG.warn(_("Quota exceeded for %(pid)s, tried to create "
96
"%(size)sG volume (%(consumed)dG of %(limit)dG "
97
"already consumed)") % locals())
98
code = "VolumeSizeTooLarge"
99
elif 'volumes' in overs:
100
consumed = usages['volumes']
101
LOG.warn(_("Quota exceeded for %(pid)s, tried to create "
102
"volume (%(consumed)d volumes already consumed)")
104
code = "VolumeLimitExceeded"
105
raise exception.QuotaError(code=code)
89
107
if availability_zone is None:
90
108
availability_zone = FLAGS.storage_availability_zone