Skip to content

Commit

Permalink
Revert "Use Placement API along with the hypervisor stats"
Browse files Browse the repository at this point in the history
This reverts commit f3225e5.
  • Loading branch information
priteau committed Dec 13, 2024
1 parent 3a85dde commit 9ba7b33
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 226 deletions.
2 changes: 0 additions & 2 deletions openstack_dashboard/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
from openstack_dashboard.api import network
from openstack_dashboard.api import neutron
from openstack_dashboard.api import nova
from openstack_dashboard.api import placement
from openstack_dashboard.api import swift


Expand All @@ -50,6 +49,5 @@
"network",
"neutron",
"nova",
"placement",
"swift",
]
110 changes: 0 additions & 110 deletions openstack_dashboard/api/placement.py

This file was deleted.

60 changes: 12 additions & 48 deletions openstack_dashboard/dashboards/admin/hypervisors/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,36 @@ class AdminHypervisorsTable(tables.DataTable):
hostname = tables.WrappingColumn("hypervisor_hostname",
link="horizon:admin:hypervisors:detail",
verbose_name=_("Hostname"))

hypervisor_type = tables.Column("hypervisor_type",
verbose_name=_("Type"))

vcpus_used = tables.Column("vcpus_used",
verbose_name=_("VCPUs (used)"))

vcpus = tables.Column("vcpus",
verbose_name=_("VCPUs (total)"))

memory_used = tables.Column('memory_mb_used',
verbose_name=_("RAM (used)"),
attrs={'data-type': 'size'},
filters=(sizeformat.mb_float_format,))

memory = tables.Column('memory_mb',
verbose_name=_("RAM (total)"),
attrs={'data-type': 'size'},
filters=(sizeformat.mb_float_format,))

local_used = tables.Column('local_gb_used',
verbose_name=_("Local Storage (used)"),
attrs={'data-type': 'size'},
filters=(sizeformat.diskgbformat,))

local = tables.Column('local_gb',
verbose_name=_("Local Storage (total)"),
attrs={'data-type': 'size'},
filters=(sizeformat.diskgbformat,))

running_vms = tables.Column("running_vms",
verbose_name=_("Instances"))

Expand All @@ -66,51 +78,3 @@ def get_object_id(self, server):
class Meta(object):
name = "hypervisor_instances"
verbose_name = _("Hypervisor Instances")


class AdminProvidersTable(tables.DataTable):
name = tables.WrappingColumn("name",
verbose_name=_("Resource Provider Name"))
vcpus_used = tables.Column("vcpus_used",
verbose_name=_("VCPUs (used)"))
vcpus_reserved = tables.Column("vcpus_reserved",
verbose_name=_("VCPUs (reserved)"))
vcpus = tables.Column("vcpus",
verbose_name=_("VCPUs (total)"))
pcpus_used = tables.Column("pcpus_used",
verbose_name=_("PCPUs (used)"))
pcpus_reserved = tables.Column("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)"),
attrs={'data-type': 'size'},
filters=(sizeformat.mb_float_format,))
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)"),
attrs={'data-type': 'size'},
filters=(sizeformat.mb_float_format,))
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)"),
attrs={'data-type': 'size'},
filters=(sizeformat.diskgbformat,))
disk = tables.Column('disk_gb',
verbose_name=_("Storage (total)"),
attrs={'data-type': 'size'},
filters=(sizeformat.diskgbformat,))

def get_object_id(self, provider):
return provider['uuid']

class Meta(object):
name = "providers"
verbose_name = _("Resource Providers")
20 changes: 1 addition & 19 deletions openstack_dashboard/dashboards/admin/hypervisors/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from horizon.utils import functions as utils

from openstack_dashboard.api import nova
from openstack_dashboard.api import placement
from openstack_dashboard.dashboards.admin.hypervisors.compute \
import tabs as cmp_tabs
from openstack_dashboard.dashboards.admin.hypervisors import tables
Expand All @@ -41,24 +40,7 @@ def get_hypervisors_data(self):
return hypervisors


class ProviderTab(tabs.TableTab):
table_classes = (tables.AdminProvidersTable,)
name = _("Resource Provider")
slug = "provider"
template_name = "horizon/common/_detail_table.html"

def get_providers_data(self):
providers = []
try:
providers = placement.get_providers(self.request)
except Exception:
exceptions.handle(self.request,
_('Unable to retrieve providers information.'))

return providers


class HypervisorHostTabs(tabs.TabGroup):
slug = "hypervisor_info"
tabs = (HypervisorTab, cmp_tabs.ComputeHostTab, ProviderTab)
tabs = (HypervisorTab, cmp_tabs.ComputeHostTab)
sticky = True
Original file line number Diff line number Diff line change
Expand Up @@ -7,61 +7,28 @@
<div class="quota-dynamic">
<h3>{% trans "Hypervisor Summary" %}</h3>
<div class="col-sm-4 d3_quota_bar">
<div class="pie-chart-usage" data-used="{% widthratio stats.memory_mb_used stats.memory_mb 100 %}"></div>
<div class="h5">{% trans "Memory Usage" %}</div>
<div class="h6">
{% blocktrans with used=stats.memory_mb_used|mb_float_format available=stats.memory_mb|mb_float_format %}Used <span> {{ used }} </span> of <span> {{ available }} </span>{% endblocktrans %}
</div>
</div>

<div class="col-sm-4 d3_quota_bar">
<div class="pie-chart-usage" data-used="{% widthratio stats.local_gb_used stats.local_gb 100 %}"></div>
<div class="h5">{% trans "Local Disk Usage" %}</div>
<div class="h6">
{% blocktrans with used=stats.local_gb_used|diskgbformat available=stats.local_gb|diskgbformat %}Used <span> {{ used }} </span> of <span> {{ available }} </span>{% endblocktrans %}
</div>
</div>
</div>
<div class="quota-dynamic">
<h3>{% trans "Resource Providers Summary" %}</h3>
{% 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 stats.vcpus_used stats.vcpus 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 %}
</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="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=stats.vcpus_used|intcomma available=stats.vcpus|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="col-sm-4 d3_quota_bar">
<div class="pie-chart-usage" data-used="{% widthratio stats.memory_mb_used stats.memory_mb 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=stats.memory_mb_used|mb_float_format available=stats.memory_mb|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="col-sm-4 d3_quota_bar">
<div class="pie-chart-usage" data-used="{% widthratio stats.local_gb_used stats.local_gb 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=stats.local_gb_used|diskgbformat available=stats.local_gb|diskgbformat %}Used <span> {{ used }} </span> of <span> {{ available }} </span>{% endblocktrans %}
</div>
</div>
{% endfor %}
</div>
<div class="row-fluid">
<div class="col-sm-12">
Expand Down
2 changes: 1 addition & 1 deletion openstack_dashboard/dashboards/admin/hypervisors/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_service_list_unavailable(self):
self.mock_service_list.side_effect = self.exceptions.nova

resp = self.client.get(reverse('horizon:admin:hypervisors:index'))
self.assertMessageCount(resp, error=2, warning=0)
self.assertMessageCount(resp, error=1, warning=0)

self.mock_hypervisor_list.assert_called_once_with(
test.IsHttpRequest())
Expand Down
6 changes: 1 addition & 5 deletions openstack_dashboard/dashboards/admin/hypervisors/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ def get_context_data(self, **kwargs):
except Exception:
exceptions.handle(self.request,
_('Unable to retrieve hypervisor statistics.'))
try:
context["providers"] = api.placement.get_providers(self.request)
except Exception:
exceptions.handle(self.request,
_('Unable to retrieve providers statistics.'))

return context


Expand Down

0 comments on commit 9ba7b33

Please sign in to comment.