Commit 6d8f9bb0 authored by Giorgos Korfiatis's avatar Giorgos Korfiatis

astakos: Change response for API call `quotas'

The following indicators are returned for each holding:
"limit": the quota limit (as before)
"usage": the current usage (pessimistically, includes any pending
         allocations)
"pending": the difference of max and min allocation, indicates
           that there are pending commissions on this holding
parent 5cbda43d
......@@ -370,22 +370,22 @@ resources = {
quotas = {
"system": {
"cyclades.ram": {
"available": 536870912,
"pending": 0,
"limit": 1073741824,
"used": 536870912},
"usage": 536870912},
"cyclades.vm": {
"available": 0,
"pending": 0,
"limit": 2,
"used": 2}},
"usage": 2}},
"project:1": {
"cyclades.ram": {
"available": 0,
"pending": 0,
"limit": 2147483648,
"used": 2147483648},
"usage": 2147483648},
"cyclades.vm": {
"available": 3,
"pending": 1,
"limit": 5,
"used": 2}}}
"usage": 2}}}
commission_request = {
"force": False,
......
......@@ -65,26 +65,27 @@ Status Description
{
"system": {
"cyclades.ram": {
"available": 536870912,
"usage": 536870912,
"limit": 1073741824,
"used": 536870912
"pending": 0
},
"cyclades.vm": {
"available": 0,
"usage": 2,
"limit": 2,
"used": 2
"pending": 0
}
},
"project:1": {
"cyclades.ram": {
"available": 0,
"usage": 2147483648,
"limit": 2147483648,
"used": 2147483648
"pending": 0
},
"cyclades.vm": {
"available": 3,
"usage": 2,
"limit": 5,
"used": 2
"pending": 1
}
}
}
......@@ -121,26 +122,26 @@ Status Description
"1a6165d0-5020-4b6d-a4ad-83476632a584": {
"system": {
"cyclades.ram": {
"available": 536870912,
"usage": 536870912,
"limit": 1073741824,
"used": 536870912
"pending": 0
},
"cyclades.vm": {
"available": 0,
"usage": 2,
"limit": 2,
"used": 2
"pending": 0
}
},
"project:1": {
"cyclades.ram": {
"available": 0,
"usage": 2147483648,
"limit": 2147483648,
"used": 2147483648
"pending": 0
},
"cyclades.vm": {
"available": 3,
"usage": 2,
"limit": 5,
"used": 2
"pending": 1
}
}
}
......
......@@ -144,9 +144,10 @@ class Command(BaseCommand):
initial = s_initial.get(resource) if s_initial else None
initial = str(initial)
capacity = str(values['limit'])
used = str(values['used'])
usage = str(values['usage'])
fields = holder, email, source, resource, initial, capacity, used
fields = (holder, email, source, resource,
initial, capacity, usage)
output = []
for field, width in zip(fields, columns):
s = field.rjust(width)
......
......@@ -42,8 +42,8 @@ qh = QuotaholderDjangoDBCallpoint()
def from_holding(holding):
limit, imported_min, imported_max = holding
body = {'limit': limit,
'used': imported_min,
'available': max(0, limit-imported_max),
'usage': imported_max,
'pending': imported_max-imported_min,
}
return body
......
......@@ -162,12 +162,12 @@ _.extend(UsageView.prototype, {
var value, limit, percentage;
limit = resource.limit;
value = resource.limit - resource.available;
value = resource.usage;
if (value < 0 ) { value = 0 }
percentage = (value/limit) * 100;
if (value == 0) { percentage = 0 }
if (resource.available <= 0) {
if (value > limit) {
percentage = 100;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment