Merge "hypervisor list and details page reports invalid data"
This commit is contained in:
commit
71fc685ed9
@ -57,7 +57,8 @@ class AdminHypervisorsTable(tables.DataTable):
|
||||
verbose_name=_("Instances"))
|
||||
|
||||
def get_object_id(self, hypervisor):
|
||||
return hypervisor.hypervisor_hostname
|
||||
return "%s_%s" % (hypervisor.id,
|
||||
hypervisor.hypervisor_hostname)
|
||||
|
||||
class Meta(object):
|
||||
name = "hypervisors"
|
||||
|
@ -88,12 +88,17 @@ class HypervisorViewTest(test.BaseAdminViewTests):
|
||||
class HypervisorDetailViewTest(test.BaseAdminViewTests):
|
||||
@test.create_stubs({api.nova: ('hypervisor_search',)})
|
||||
def test_index(self):
|
||||
hypervisor = self.hypervisors.list().pop().hypervisor_hostname
|
||||
hypervisor = self.hypervisors.first()
|
||||
api.nova.hypervisor_search(
|
||||
IsA(http.HttpRequest), hypervisor).AndReturn([])
|
||||
IsA(http.HttpRequest),
|
||||
hypervisor.hypervisor_hostname).AndReturn([
|
||||
hypervisor,
|
||||
self.hypervisors.list()[1]])
|
||||
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)
|
||||
self.assertTemplateUsed(res, 'admin/hypervisors/detail.html')
|
||||
self.assertItemsEqual(res.context['table'].data, [])
|
||||
self.assertItemsEqual(res.context['table'].data, hypervisor.servers)
|
||||
|
@ -61,13 +61,15 @@ class AdminDetailView(tables.DataTableView):
|
||||
def get_data(self):
|
||||
instances = []
|
||||
try:
|
||||
id, name = self.kwargs['hypervisor'].split('_', 1)
|
||||
result = api.nova.hypervisor_search(self.request,
|
||||
self.kwargs['hypervisor'])
|
||||
name)
|
||||
for hypervisor in result:
|
||||
try:
|
||||
instances += hypervisor.servers
|
||||
except AttributeError:
|
||||
pass
|
||||
if str(hypervisor.id) == id:
|
||||
try:
|
||||
instances += hypervisor.servers
|
||||
except AttributeError:
|
||||
pass
|
||||
except Exception:
|
||||
exceptions.handle(
|
||||
self.request,
|
||||
|
@ -634,7 +634,7 @@ def data(TEST):
|
||||
"vcpus_used": 1,
|
||||
"hypervisor_type": "QEMU",
|
||||
"local_gb_used": 20,
|
||||
"hypervisor_hostname": "devstack002",
|
||||
"hypervisor_hostname": "devstack001",
|
||||
"memory_mb_used": 1500,
|
||||
"memory_mb": 2000,
|
||||
"current_workload": 0,
|
||||
@ -650,6 +650,7 @@ def data(TEST):
|
||||
"local_gb": 29,
|
||||
"free_ram_mb": 500,
|
||||
"id": 2,
|
||||
"servers": [{"name": "test_name_2", "uuid": "test_uuid_2"}]
|
||||
},
|
||||
)
|
||||
hypervisor_3 = hypervisors.Hypervisor(
|
||||
|
Loading…
Reference in New Issue
Block a user