summaryrefslogtreecommitdiff
path: root/openstack_dashboard/api/tuskar.py
diff options
context:
space:
mode:
authorJiri Tomasek <jtomasek@redhat.com>2013-07-24 13:52:57 +0200
committerTomas Sedovic <tomas@sedovic.cz>2013-08-01 16:18:57 +0200
commitb8e3b6e8809f70ce711f3663c61072a01b79ff16 (patch)
tree0c2192499fedbec3cae01f2974d590b0cc81215c /openstack_dashboard/api/tuskar.py
parentc24239951e26440942774176ae4c509a7220d681 (diff)
downloadtuskar-ui-b8e3b6e8809f70ce711f3663c61072a01b79ff16.tar.gz
Rack overal usage in racks table and rack detail, Resource Class overal usage
Change-Id: Ia7c3b8b4c18c5f60cd20762aeb41a67fe4f96f40
Diffstat (limited to 'openstack_dashboard/api/tuskar.py')
-rw-r--r--openstack_dashboard/api/tuskar.py35
1 files changed, 18 insertions, 17 deletions
diff --git a/openstack_dashboard/api/tuskar.py b/openstack_dashboard/api/tuskar.py
index 0f86cadf..c3281638 100644
--- a/openstack_dashboard/api/tuskar.py
+++ b/openstack_dashboard/api/tuskar.py
@@ -381,18 +381,18 @@ class Rack(StringIdAPIResourceWrapper):
@property
def vm_capacity(self):
+ """ Rack VM Capacity is maximum value from It's Resource Class's
+ Flavors max_vms (considering flavor sizes are multiples).
+ """
if not hasattr(self, '_vm_capacity'):
try:
- value = dummymodels.ResourceClassFlavor.objects\
- .filter(resource_class__rack=self._apiresource)\
- .aggregate(Max("max_vms"))['max_vms__max']
+ value = max([flavor.max_vms for flavor in
+ self.resource_class.list_flavors])
except:
- value = _("Unable to retrieve vm capacity")
-
- vm_capacity = dummymodels.Capacity(name=_("Max VMs"),
- value=value,
- unit=_("VMs"))
- self._vm_capacity = Capacity(vm_capacity)
+ value = None
+ self._vm_capacity = Capacity({'name': "VM Capacity",
+ 'value': value,
+ 'unit': 'VMs'})
return self._vm_capacity
@property
@@ -642,18 +642,19 @@ class ResourceClass(StringIdAPIResourceWrapper):
@property
def vm_capacity(self):
+ """ Resource Class VM Capacity is maximum value from It's Flavors
+ max_vms (considering flavor sizes are multiples), multipled by
+ number of Racks in Resource Class.
+ """
if not hasattr(self, '_vm_capacity'):
try:
- value = dummymodels.ResourceClassFlavor.objects\
- .filter(resource_class=self._apiresource)\
- .aggregate(Max("max_vms"))['max_vms__max']
+ value = self.racks_count * max([flavor.max_vms for flavor in
+ self.list_flavors])
except:
value = _("Unable to retrieve vm capacity")
-
- vm_capacity = dummymodels.Capacity(name=_("Max VMs"),
- value=value,
- unit=_("VMs"))
- self._vm_capacity = Capacity(vm_capacity)
+ self._vm_capacity = Capacity({'name': _("VM Capacity"),
+ 'value': value,
+ 'unit': _('VMs')})
return self._vm_capacity
def set_racks(self, request, racks_ids):