Add allocation ratios to Placement stats
All the Placement API stats "total" show the actual amount of the
resource that the provider can accommodate. Using allocation ratio
it is possible to exceed physical constraints.
This patch uses allocation ratios to display the diagrams properly
and adds the data to the stats table.
Closes-Bug: #1974470
Closes-Bug: #1397917
Change-Id: Iab0ce21ae63f4cc26d3ec5684615189b8ab35231
(cherry picked from commit 3acbf227a4
)
This commit is contained in:
parent
1d53792fc0
commit
01968e39c8
@ -95,16 +95,34 @@ def get_providers(request):
|
||||
p['usages'] = usages
|
||||
p['aggregates'] = resource_provider_aggregates(request, p['uuid'])
|
||||
p['traits'] = resource_provider_traits(request, p['uuid'])
|
||||
|
||||
p['vcpus_used'] = usages.get('VCPU')
|
||||
p['vcpus_reserved'] = vcpus['reserved'] if vcpus is not None else None
|
||||
# The actual amount of the resource that the provider can accommodate
|
||||
p['vcpus'] = vcpus['total'] if vcpus is not None else None
|
||||
# Overall capacity
|
||||
p['vcpus_ar'] = vcpus['allocation_ratio'] \
|
||||
if vcpus is not None else None
|
||||
p['vcpus_capacity'] = int(vcpus['allocation_ratio'] * vcpus['total']) \
|
||||
if vcpus is not None else None
|
||||
|
||||
p['pcpus_used'] = usages.get('PCPU')
|
||||
p['pcpus_reserved'] = pcpus['reserved'] if pcpus is not None else None
|
||||
p['pcpus'] = pcpus['total'] if pcpus is not None else None
|
||||
p['pcpus_ar'] = pcpus['allocation_ratio'] \
|
||||
if pcpus is not None else None
|
||||
p['pcpus_capacity'] = int(pcpus['allocation_ratio'] * pcpus['total']) \
|
||||
if pcpus is not None else None
|
||||
|
||||
p['memory_mb_used'] = usages['MEMORY_MB']
|
||||
p['memory_mb_reserved'] = inventories['MEMORY_MB']['reserved']
|
||||
p['memory_mb'] = inventories['MEMORY_MB']['total']
|
||||
p['memory_mb_ar'] = inventories['MEMORY_MB']['allocation_ratio']
|
||||
p['memory_mb_capacity'] = p['memory_mb_ar'] * p['memory_mb']
|
||||
|
||||
p['disk_gb_used'] = usages['DISK_GB']
|
||||
p['disk_gb_reserved'] = inventories['DISK_GB']['reserved']
|
||||
p['disk_gb'] = inventories['DISK_GB']['total']
|
||||
p['disk_gb_ar'] = inventories['DISK_GB']['allocation_ratio']
|
||||
p['disk_gb_capacity'] = p['disk_gb_ar'] * p['disk_gb']
|
||||
return providers
|
||||
|
@ -72,41 +72,49 @@ class AdminProvidersTable(tables.DataTable):
|
||||
name = tables.WrappingColumn("name",
|
||||
verbose_name=_("Resource Provider Name"))
|
||||
vcpus_used = tables.Column("vcpus_used",
|
||||
verbose_name=_("VCPUs (used)"))
|
||||
verbose_name=_("VCPUs used"))
|
||||
vcpus_reserved = tables.Column("vcpus_reserved",
|
||||
verbose_name=_("VCPUs (reserved)"))
|
||||
verbose_name=_("VCPUs reserved"))
|
||||
vcpus = tables.Column("vcpus",
|
||||
verbose_name=_("VCPUs (total)"))
|
||||
verbose_name=_("VCPUs total"))
|
||||
vcpus_ar = tables.Column("vcpus_ar",
|
||||
verbose_name=_("VCPUs allocation ratio"))
|
||||
pcpus_used = tables.Column("pcpus_used",
|
||||
verbose_name=_("PCPUs (used)"))
|
||||
verbose_name=_("PCPUs used"))
|
||||
pcpus_reserved = tables.Column("pcpus_reserved",
|
||||
verbose_name=_("PCPUs (reserved)"))
|
||||
verbose_name=_("PCPUs reserved"))
|
||||
pcpus = tables.Column("pcpus",
|
||||
verbose_name=_("PCPUs (total)"))
|
||||
memory_used = tables.Column('memory_mb_used',
|
||||
verbose_name=_("RAM (used)"),
|
||||
verbose_name=_("PCPUs total"))
|
||||
pcpus_ar = tables.Column("pcpus_ar",
|
||||
verbose_name=_("PCPUs allocation ratio"))
|
||||
memory_used = tables.Column("memory_mb_used",
|
||||
verbose_name=_("RAM used"),
|
||||
attrs={'data-type': 'size'},
|
||||
filters=(sizeformat.mb_float_format,))
|
||||
memory_reserved = tables.Column('memory_mb_reserved',
|
||||
verbose_name=_("RAM (reserved)"),
|
||||
memory_reserved = tables.Column("memory_mb_reserved",
|
||||
verbose_name=_("RAM reserved"),
|
||||
attrs={'data-type': 'size'},
|
||||
filters=(sizeformat.mb_float_format,))
|
||||
memory = tables.Column('memory_mb',
|
||||
verbose_name=_("RAM (total)"),
|
||||
memory = tables.Column("memory_mb",
|
||||
verbose_name=_("RAM total"),
|
||||
attrs={'data-type': 'size'},
|
||||
filters=(sizeformat.mb_float_format,))
|
||||
disk_used = tables.Column('disk_gb_used',
|
||||
verbose_name=_("Storage (used)"),
|
||||
memory_ar = tables.Column("memory_mb_ar",
|
||||
verbose_name=_("RAM allocation ratio"))
|
||||
disk_used = tables.Column("disk_gb_used",
|
||||
verbose_name=_("Storage used"),
|
||||
attrs={'data-type': 'size'},
|
||||
filters=(sizeformat.diskgbformat,))
|
||||
disk_reserved = tables.Column('disk_gb_reserved',
|
||||
verbose_name=_("Storage (reserved)"),
|
||||
disk_reserved = tables.Column("disk_gb_reserved",
|
||||
verbose_name=_("Storage reserved"),
|
||||
attrs={'data-type': 'size'},
|
||||
filters=(sizeformat.diskgbformat,))
|
||||
disk = tables.Column('disk_gb',
|
||||
verbose_name=_("Storage (total)"),
|
||||
disk = tables.Column("disk_gb",
|
||||
verbose_name=_("Storage total"),
|
||||
attrs={'data-type': 'size'},
|
||||
filters=(sizeformat.diskgbformat,))
|
||||
disk_ar = tables.Column("disk_gb_ar",
|
||||
verbose_name=_("Storage allocation ratio"))
|
||||
|
||||
def get_object_id(self, provider):
|
||||
return provider['uuid']
|
||||
|
@ -27,38 +27,38 @@
|
||||
{% for provider in providers %}
|
||||
<h4>{{ provider.name }}</h4>
|
||||
<div class="col-sm-4 d3_quota_bar col-lg-3 col-md-2 col-xs-4">
|
||||
<div class="pie-chart-usage" data-used="{% widthratio provider.usages.VCPU provider.inventories.VCPU.total 100 %}"></div>
|
||||
<div class="pie-chart-usage" data-used="{% widthratio provider.vcpus_used provider.vcpus_capacity 100 %}"></div>
|
||||
<div class="h5">{% trans "VCPU Usage" %}</div>
|
||||
{% if provider.inventories.VCPU != None %}
|
||||
<div class="h6">
|
||||
{% blocktrans with used=provider.usages.VCPU|intcomma available=provider.inventories.VCPU.total|intcomma %}Used <span> {{ used }} </span> of <span> {{ available }} </span>{% endblocktrans %}
|
||||
{% blocktrans with used=provider.vcpus_used|intcomma available=provider.vcpus_capacity|intcomma %}Used <span> {{ used }} </span> of <span> {{ available }} </span>{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4 d3_quota_bar col-lg-3 col-md-2 col-xs-4">
|
||||
<div class="pie-chart-usage" data-used="{% widthratio provider.usages.PCPU provider.inventories.PCPU.total 100 %}"></div>
|
||||
<div class="pie-chart-usage" data-used="{% widthratio provider.pcpus_used provider.pcpus_capacity 100 %}"></div>
|
||||
<div class="h5">{% trans "PCPU Usage" %}</div>
|
||||
{% if provider.inventories.PCPU != None %}
|
||||
<div class="h6">
|
||||
{% blocktrans with used=provider.usages.PCPU|intcomma available=provider.inventories.PCPU.total|intcomma %}Used <span> {{ used }} </span> of <span> {{ available }} </span>{% endblocktrans %}
|
||||
{% blocktrans with used=provider.pcpus_used|intcomma available=provider.pcpus_capacity|intcomma %}Used <span> {{ used }} </span> of <span> {{ available }} </span>{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4 d3_quota_bar col-lg-3 col-md-2 col-xs-4">
|
||||
<div class="pie-chart-usage" data-used="{% widthratio provider.usages.MEMORY_MB provider.inventories.MEMORY_MB.total 100 %}"></div>
|
||||
<div class="pie-chart-usage" data-used="{% widthratio provider.memory_mb_used provider.memory_mb_capacity 100 %}"></div>
|
||||
<div class="h5">{% trans "Memory Usage" %}</div>
|
||||
<div class="h6">
|
||||
{% blocktrans with used=provider.usages.MEMORY_MB|mb_float_format available=provider.inventories.MEMORY_MB.total|mb_float_format %}Used <span> {{ used }} </span> of <span> {{ available }} </span>{% endblocktrans %}
|
||||
{% blocktrans with used=provider.memory_mb_used|mb_float_format available=provider.memory_mb_capacity|mb_float_format %}Used <span> {{ used }} </span> of <span> {{ available }} </span>{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4 d3_quota_bar col-lg-3 col-md-2 col-xs-4">
|
||||
<div class="pie-chart-usage" data-used="{% widthratio provider.usages.DISK_GB provider.inventories.DISK_GB.total 100 %}"></div>
|
||||
<div class="pie-chart-usage" data-used="{% widthratio provider.disk_gb_used provider.disk_gb_capacity 100 %}"></div>
|
||||
<div class="h5">{% trans "Local Disk Usage" %}</div>
|
||||
<div class="h6">
|
||||
{% blocktrans with used=provider.usages.DISK_GB|diskgbformat available=provider.inventories.DISK_GB.total|diskgbformat %}Used <span> {{ used }} </span> of <span> {{ available }} </span>{% endblocktrans %}
|
||||
{% blocktrans with used=provider.disk_gb_used|diskgbformat available=provider.disk_gb_capacity|diskgbformat %}Used <span> {{ used }} </span> of <span> {{ available }} </span>{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
Loading…
Reference in New Issue
Block a user