hypervisor list and details page reports invalid data
Nova some times allows to have same hypervisor_hostname for more than one hypervisor. In this scenario, horizon hypervisor Table view and Detail view shows invalid data as follows: Table View: For those hypervisors having same hypervisor_hostname, Table view reports the same values for all of them, irrespective of actual values Detail View: For those hypervisors having same hypervisor_hostname, Details view reports the instance from all them , instead of for the given hypervisor. By using the combination of hypervisor id and name, hypervisor detail veiw is updated to filter the instances from the given hypervisor id. Change-Id: I45925ac70f1a6b123c83888373bddb108380a9c0 Closes-bug: #1402572
This commit is contained in:
@@ -57,7 +57,8 @@ class AdminHypervisorsTable(tables.DataTable):
|
|||||||
verbose_name=_("Instances"))
|
verbose_name=_("Instances"))
|
||||||
|
|
||||||
def get_object_id(self, hypervisor):
|
def get_object_id(self, hypervisor):
|
||||||
return hypervisor.hypervisor_hostname
|
return "%s_%s" % (hypervisor.id,
|
||||||
|
hypervisor.hypervisor_hostname)
|
||||||
|
|
||||||
class Meta(object):
|
class Meta(object):
|
||||||
name = "hypervisors"
|
name = "hypervisors"
|
||||||
|
@@ -88,12 +88,17 @@ class HypervisorViewTest(test.BaseAdminViewTests):
|
|||||||
class HypervisorDetailViewTest(test.BaseAdminViewTests):
|
class HypervisorDetailViewTest(test.BaseAdminViewTests):
|
||||||
@test.create_stubs({api.nova: ('hypervisor_search',)})
|
@test.create_stubs({api.nova: ('hypervisor_search',)})
|
||||||
def test_index(self):
|
def test_index(self):
|
||||||
hypervisor = self.hypervisors.list().pop().hypervisor_hostname
|
hypervisor = self.hypervisors.first()
|
||||||
api.nova.hypervisor_search(
|
api.nova.hypervisor_search(
|
||||||
IsA(http.HttpRequest), hypervisor).AndReturn([])
|
IsA(http.HttpRequest),
|
||||||
|
hypervisor.hypervisor_hostname).AndReturn([
|
||||||
|
hypervisor,
|
||||||
|
self.hypervisors.list()[1]])
|
||||||
self.mox.ReplayAll()
|
self.mox.ReplayAll()
|
||||||
|
|
||||||
url = reverse('horizon:admin:hypervisors:detail', args=[hypervisor])
|
url = reverse('horizon:admin:hypervisors:detail',
|
||||||
|
args=["%s_%s" % (hypervisor.id,
|
||||||
|
hypervisor.hypervisor_hostname)])
|
||||||
res = self.client.get(url)
|
res = self.client.get(url)
|
||||||
self.assertTemplateUsed(res, 'admin/hypervisors/detail.html')
|
self.assertTemplateUsed(res, 'admin/hypervisors/detail.html')
|
||||||
self.assertItemsEqual(res.context['table'].data, [])
|
self.assertItemsEqual(res.context['table'].data, hypervisor.servers)
|
||||||
|
@@ -61,9 +61,11 @@ class AdminDetailView(tables.DataTableView):
|
|||||||
def get_data(self):
|
def get_data(self):
|
||||||
instances = []
|
instances = []
|
||||||
try:
|
try:
|
||||||
|
id, name = self.kwargs['hypervisor'].split('_', 1)
|
||||||
result = api.nova.hypervisor_search(self.request,
|
result = api.nova.hypervisor_search(self.request,
|
||||||
self.kwargs['hypervisor'])
|
name)
|
||||||
for hypervisor in result:
|
for hypervisor in result:
|
||||||
|
if str(hypervisor.id) == id:
|
||||||
try:
|
try:
|
||||||
instances += hypervisor.servers
|
instances += hypervisor.servers
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
@@ -634,7 +634,7 @@ def data(TEST):
|
|||||||
"vcpus_used": 1,
|
"vcpus_used": 1,
|
||||||
"hypervisor_type": "QEMU",
|
"hypervisor_type": "QEMU",
|
||||||
"local_gb_used": 20,
|
"local_gb_used": 20,
|
||||||
"hypervisor_hostname": "devstack002",
|
"hypervisor_hostname": "devstack001",
|
||||||
"memory_mb_used": 1500,
|
"memory_mb_used": 1500,
|
||||||
"memory_mb": 2000,
|
"memory_mb": 2000,
|
||||||
"current_workload": 0,
|
"current_workload": 0,
|
||||||
@@ -650,6 +650,7 @@ def data(TEST):
|
|||||||
"local_gb": 29,
|
"local_gb": 29,
|
||||||
"free_ram_mb": 500,
|
"free_ram_mb": 500,
|
||||||
"id": 2,
|
"id": 2,
|
||||||
|
"servers": [{"name": "test_name_2", "uuid": "test_uuid_2"}]
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
hypervisor_3 = hypervisors.Hypervisor(
|
hypervisor_3 = hypervisors.Hypervisor(
|
||||||
|
Reference in New Issue
Block a user