Resource Classes capacity graphs

Change-Id: I2f6dc07ba35545d0eb02b3382cf5dd1523c0b457
This commit is contained in:
Jiri Tomasek 2013-07-08 14:12:24 +02:00 committed by Tomas Sedovic
parent eec0013c5b
commit c6329f592b
4 changed files with 214 additions and 86 deletions

View File

@ -538,8 +538,8 @@ class ResourceClass(StringIdAPIResourceWrapper):
return self.__dict__['_running_virtual_machines']
@property
def total_cpu(self):
if "_total_cpu" not in self.__dict__:
def cpu(self):
if "_cpu" not in self.__dict__:
try:
attrs = dummymodels.Capacity.objects\
.filter(node__rack__resource_class=self._apiresource)\
@ -550,15 +550,15 @@ class ResourceClass(StringIdAPIResourceWrapper):
'value': _('Unable to retrieve '
'(Are the nodes configured properly?)'),
'unit': ''}
total_cpu = dummymodels.Capacity(name=attrs['name'],
cpu = dummymodels.Capacity(name=attrs['name'],
value=attrs['value'],
unit=attrs['unit'])
self._total_cpu = Capacity(total_cpu)
return self.__dict__['_total_cpu']
self._cpu = Capacity(cpu)
return self.__dict__['_cpu']
@property
def total_ram(self):
if "_total_ram" not in self.__dict__:
def ram(self):
if "_ram" not in self.__dict__:
try:
attrs = dummymodels.Capacity.objects\
.filter(node__rack__resource_class=self._apiresource)\
@ -569,15 +569,15 @@ class ResourceClass(StringIdAPIResourceWrapper):
'value': _('Unable to retrieve '
'(Are the nodes configured properly?)'),
'unit': ''}
total_ram = dummymodels.Capacity(name=attrs['name'],
ram = dummymodels.Capacity(name=attrs['name'],
value=attrs['value'],
unit=attrs['unit'])
self._total_ram = Capacity(total_ram)
return self.__dict__['_total_ram']
self._ram = Capacity(ram)
return self.__dict__['_ram']
@property
def total_storage(self):
if "_total_storage" not in self.__dict__:
def storage(self):
if "_storage" not in self.__dict__:
try:
attrs = dummymodels.Capacity.objects\
.filter(node__rack__resource_class=self._apiresource)\
@ -588,11 +588,46 @@ class ResourceClass(StringIdAPIResourceWrapper):
'value': _('Unable to retrieve '
'(Are the nodes configured properly?)'),
'unit': ''}
total_storage = dummymodels.Capacity(name=attrs['name'],
storage = dummymodels.Capacity(name=attrs['name'],
value=attrs['value'],
unit=attrs['unit'])
self._total_storage = Capacity(total_storage)
return self.__dict__['_total_storage']
self._storage = Capacity(storage)
return self.__dict__['_storage']
@property
def network(self):
if "_network" not in self.__dict__:
try:
attrs = dummymodels.Capacity.objects\
.filter(node__rack__resource_class=self._apiresource)\
.values('name', 'unit').annotate(value=Sum('value'))\
.filter(name='network')[0]
except:
attrs = {'name': 'network',
'value': _('Unable to retrieve '
'(Are the nodes configured properly?)'),
'unit': ''}
network = dummymodels.Capacity(name=attrs['name'],
value=attrs['value'],
unit=attrs['unit'])
self._network = Capacity(network)
return self.__dict__['_network']
@property
def vm_capacity(self):
if "_vm_capacity" not in self.__dict__:
try:
value = dummymodels.ResourceClassFlavor.objects\
.filter(resource_class=self._apiresource)\
.aggregate(Max("max_vms"))['max_vms__max']
except:
value = _("Unable to retrieve vm capacity")
vm_capacity = dummymodels.Capacity(name=_("Max VMs"),
value=value,
unit=_("VMs"))
self._vm_capacity = Capacity(vm_capacity)
return self.__dict__['_vm_capacity']
##########################################################################
# ResourceClass Instance methods

View File

@ -162,14 +162,18 @@ class UpdateFlavorsClass(tables.LinkAction):
class ResourceClassDetailResourcesTable(racks_tables.RacksTable):
total_cpu = tables.Column("total_cpu",
verbose_name=_("Total CPU"))
total_ram = tables.Column("total_ram",
verbose_name=_("Total RAM"))
total_disk = tables.Column("total_disk",
verbose_name=_("Total DISK"))
usage = tables.Column("usage",
verbose_name=_("Usage"))
cpu = tables.Column("cpu",
verbose_name=_("Total CPU"),
filters=(lambda x: getattr(x, 'value', ''),))
ram = tables.Column("ram",
verbose_name=_("Total RAM"),
filters=(lambda x: getattr(x, 'value', ''),))
storage = tables.Column("storage",
verbose_name=_("Total Disk"),
filters=(lambda x: getattr(x, 'value', ''),))
vm_capacity = tables.Column("vm_capacity",
verbose_name=_("VM Capacity"),
filters=(lambda x: getattr(x, 'value', ''),))
class Meta:
name = "resources"
@ -177,7 +181,7 @@ class ResourceClassDetailResourcesTable(racks_tables.RacksTable):
table_actions = (ResourcesFilterAction, UpdateResourcesClass)
columns = (
'name', 'subnet', 'location', 'node_count',
'total_cpu', 'total_ram', 'total_disk', 'usage')
'cpu', 'ram', 'storage', 'vm_capacity')
class ResourceClassDetailFlavorsTable(flavors_tables.FlavorsTable):

View File

@ -4,68 +4,127 @@
<h3>{% trans "Resource Class Overview" %}</h3>
<div class="status row-fluid detail">
<h4>{% trans "Info" %}</h4>
<hr class="header_rule">
<dl>
<dt>{% trans "Name" %}</dt>
<dd>{{ resource_class.name }}</dd>
<dt>{% trans "Service Type" %}</dt>
<dd>{{ resource_class.service_type }}</dd>
<dt>{% trans "Status" %}</dt>
<dd>{{ resource_class.status|default:_("normal") }}</dd>
</dl>
</div>
<div class="status row-fluid detail">
<h4>{% trans "Compute Power" %}</h4>
<hr class="header_rule">
<dl>
<dt>{% trans "Racks" %}</dt>
<dd>{{ resource_class.racks|length }}</dd>
<dt>{% trans "Nodes" %}</dt>
<dd>{{ resource_class.nodes|length }}</dd>
<dt>{% trans "Total CPU" %}</dt>
<dd>{{ resource_class.total_cpu.value }} {{ resource_class.total_cpu.unit }}</dd>
<dt>{% trans "Total RAM" %}</dt>
<dd>{{ resource_class.total_ram.value }} {{ resource_class.total_ram.unit }}</dd>
<dt>{% trans "Total Storage" %}</dt>
<dd>{{ resource_class.total_storage.value }} {{ resource_class.total_storage.unit }}</dd>
</dl>
</div>
<div class="status row-fluid detail">
<h4>{% trans "Running Virtual Machines" %}</h4>
<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>
{% endfor %}
</dl>
</div>
<div class="status row-fluid detail">
<h4>{% trans "Virtual Capacity" %}</h4>
<hr class="header_rule">
<dl>
{% for flavor_count in resource_class.resource_class_flavors %}
<dt>{{ flavor_count.flavor.name }}</dt>
<dd>{{ flavor_count.max_vms }}</dd>
{% endfor %}
</dl>
</div>
<div class="row-fluid">
<div class="span6">
<div class="span3">
<h4>Summary of instances and usage</h4>
</div>
<div class="span4">
<h4>{% trans "About" %}</h4>
<hr class="header_rule">
<dl>
<dt>{% trans "Racks" %}</dt>
<dd>{{ resource_class.racks|length }}</dd>
<dt>{% trans "Nodes" %}</dt>
<dd>{{ resource_class.nodes|length }}</dd>
</dl>
</div>
<div class="span4">
<h4>{% trans "Provided Service" %}</h4>
<hr class="header_rule">
<dl>
<dt>{% trans "Type" %}</dt>
<dd>{{ resource_class.service_type }}</dd>
<dt>{% trans "Flavors" %}</dt>
<dd>{{ resource_class.flavors|length }}</dd>
<dt>{% trans "Active Instances" %}</dt>
<dd>{{ resource_class.running_virtual_machines|length }}</dd>
</dl>
</dl>
</div>
<div class="span4">
<h4>{% trans "Capacities" %}</h4>
<hr class="header_rule">
<table class="capacities">
<tr>
<td class="capacity_label">{% trans "CPU" %}:</td>
<td>
<div id="cpu_capacity_usage"
class="capacity_bar"
data-capacity-limit="{{ resource_class.cpu.value }}"
data-capacity-used="{{ resource_class.cpu.usage }}"
data-average-capacity-used="{{ 12 }}">
</div>
</td>
<td>
<a href="#" class="modal_chart">{{ resource_class.cpu.usage }}/{{ resource_class.cpu.value }} {{ resource_class.cpu.unit }}</a>
</td>
</tr>
<tr>
<td class="capacity_label">{% trans "RAM" %}:</td>
<td>
<div id="ram_capacity_usage"
class="capacity_bar"
data-capacity-limit="{{ resource_class.ram.value }}"
data-capacity-used="{{ resource_class.ram.usage }}"
data-average-capacity-used="{{ 12 }}">
</div>
</td>
<td>
<a href="#" class="modal_chart">{{ resource_class.ram.usage }}/{{ resource_class.ram.value }} {{ resource_class.ram.unit }}</a>
</td>
</tr>
<tr>
<td class="capacity_label">{% trans "Storage" %}:</td>
<td>
<div id="storage_capacity_usage"
class="capacity_bar"
data-capacity-limit="{{ resource_class.storage.value }}"
data-capacity-used="{{ resource_class.storage.usage }}"
data-average-capacity-used="{{ 12 }}">
</div>
</td>
<td>
<a href="#" class="modal_chart">{{ resource_class.storage.usage }}/{{ resource_class.storage.value }} {{ resource_class.storage.unit }}</a>
</td>
</tr>
<tr>
<td class="capacity_label">{% trans "Network" %}:</td>
<td>
<div id="network_capacity_usage"
class="capacity_bar"
data-capacity-limit="{{ resource_class.network.value }}"
data-capacity-used="{{ resource_class.network.usage }}"
data-average-capacity-used="{{ 12 }}">
</div>
</td>
<td>
<a href="#" class="modal_chart">{{ resource_class.network.usage }}/{{ resource_class.network.value }} {{ resource_class.network.unit }}</a>
</td>
</tr>
</table>
</div>
</div>
<div class="status row-fluid detail">
<div class="span6">
<div class="span3">
<h4>Rack health</h4>
</div>
<div class="span3 circles_chart_time_picker">
<h4>{% trans "Running Virtual Machines" %}</h4>
<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>
{% endfor %}
</dl>
</div>
<div class="span6">
<h4>{% trans "Virtual Capacity" %}</h4>
<hr class="header_rule">
<dl>
{% for flavor_count in resource_class.resource_class_flavors %}
<dt>{{ flavor_count.flavor.name }}</dt>
<dd>{{ flavor_count.max_vms }}</dd>
{% endfor %}
</dl>
</div>
</div>
<div class="row-fluid detail">
<div class="span6">
<h4>Summary of instances and usage</h4>
<hr class="header_rule">
</div>
<div class="span6">
<div class="circles_chart_time_picker">
<select data-circles-chart-command="change_time"
data-receiver=".rack_health_chart">
<option value="now">Now</option>
@ -74,6 +133,8 @@
<option value="last_month">Last Month</option>
</select>
</div>
<h4>Rack health</h4>
<hr class="header_rule">
<div class="clear"></div>
<ul class="nav nav-tabs"

View File

@ -3,13 +3,41 @@
{% block title %}{% trans "Resource Class Detail" %}{% endblock %}
{% block page_header %}
{% include "horizon/common/_page_header.html" with title="Resource Class Detail: "|add:resource_class.name %}
{% include "horizon/common/_page_header.html" with title="Resource Class Detail" %}
{% endblock page_header %}
{% block main %}
<h3>{{ resource_class.name }}</h3>
<div class="row-fluid">
<div class="span12">
{{ tab_group.render }}
<div class="pull-right">
<table class="capacities overall_usage">
<tr>
<td class="capacity_label">{% trans "Usage" %}:</td>
<td>
<div id="resource_class_usage"
class="capacity_bar"
data-capacity-limit="{{ resource_class.vm_capacity.value }}"
data-capacity-used="{{ resource_class.vm_capacity.usage }}"
data-average-capacity-used="{{ 4 }}">
</div>
</td>
</tr>
</table>
</div>
{{ tab_group.render }}
</div>
</div>
<script type="text/javascript" charset="utf-8">
if(typeof horizon.Capacity !== 'undefined') {
horizon.Capacity.init();
} else {
addHorizonLoadEvent(function() {
horizon.Capacity.init();
});
}
</script>
{% endblock %}