diff options
6 files changed, 29 insertions, 30 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): diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tables.py b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tables.py index 9c7c3cce..d028b955 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tables.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tables.py @@ -75,13 +75,13 @@ class RacksTable(tables.DataTable): resource_class.name) or None,)) node_count = tables.Column('nodes_count', verbose_name=_("Nodes")) state = tables.Column('state', verbose_name=_("State")) - usage = tables.Column('usage', verbose_name=_("Usage")) - # usage = tables.Column( - # 'vm_capacity', - # verbose_name=_("Usage"), - # filters=(lambda vm_capacity: - # "%s %%" % int(round((100 / float(vm_capacity.value)) * - # vm_capacity.usage, 0)),)) + usage = tables.Column( + 'vm_capacity', + verbose_name=_("Usage"), + filters=(lambda vm_capacity: + (vm_capacity.value and + "%s %%" % int(round((100 / float(vm_capacity.value)) * + vm_capacity.usage, 0))) or None,)) class Meta: name = "racks" diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tabs.py b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tabs.py index 06b6ff8e..c3314623 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tabs.py +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/racks/tabs.py @@ -25,7 +25,6 @@ class OverviewTab(tabs.Tab): slug = "rack_overview_tab" template_name = ("infrastructure/resource_management/racks/" "_detail_overview.html") - preload = False def get_context_data(self, request): return {"rack": self.tab_group.kwargs['rack']} diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/racks/detail.html b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/racks/detail.html index 050fa0a2..4068b679 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/racks/detail.html +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/racks/detail.html @@ -38,7 +38,7 @@ data-chart-type="capacity_bar_chart" data-capacity-limit="{{ rack.vm_capacity.value }}" data-capacity-used="{{ rack.vm_capacity.usage }}" - data-average-capacity-used="{{ 4 }}"> + data-average-capacity-used="{{ rack.vm_capacity.average }}"> </div> </td> </tr> diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html index 9921ace8..0d46999c 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/_detail_overview.html @@ -123,9 +123,9 @@ <hr class="header_rule"> <!-- <dl> - {% for flavor_count in resource_class.running_virtual_machines %} - <dt>{{ flavor_count.flavor.name }}</dt> - <dd>{{ flavor_count.max_vms }}</dd> + {% for flavor in resource_class.running_virtual_machines %} + <dt>{{ flavor.name }}</dt> + <dd>{{ flavor.max_vms|default:_(" - ") }}</dd> {% endfor %} </dl> --> diff --git a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/detail.html b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/detail.html index 3d28a224..566929c4 100644 --- a/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/detail.html +++ b/openstack_dashboard/dashboards/infrastructure/resource_management/templates/resource_management/resource_classes/detail.html @@ -27,7 +27,6 @@ data-chart-type="capacity_bar_chart" data-capacity-limit="{{ resource_class.vm_capacity.value }}" data-capacity-used="{{ resource_class.vm_capacity.usage }}" - data-average-capacity-used="{{ 4 }}"> </div> </td> </tr> |