diff --git a/doc/v3/api_samples/os-hypervisors/hypervisors-servers-resp.json b/doc/v3/api_samples/os-hypervisors/hypervisors-servers-resp.json index 857a1b216659..375627499df6 100644 --- a/doc/v3/api_samples/os-hypervisors/hypervisors-servers-resp.json +++ b/doc/v3/api_samples/os-hypervisors/hypervisors-servers-resp.json @@ -4,8 +4,7 @@ "hypervisor_hostname": "fake-mini", "id": 1, "state": "up", - "status": "enabled", - "servers": [] + "status": "enabled" } ] } diff --git a/nova/api/openstack/compute/plugins/v3/hypervisors.py b/nova/api/openstack/compute/plugins/v3/hypervisors.py index 77e93fd581c9..6cc2502bd74b 100644 --- a/nova/api/openstack/compute/plugins/v3/hypervisors.py +++ b/nova/api/openstack/compute/plugins/v3/hypervisors.py @@ -64,7 +64,7 @@ class HypervisorsController(wsgi.Controller): 'disabled_reason': service.disabled_reason, } - if servers is not None: + if servers: hyp_dict['servers'] = [dict(name=serv['name'], uuid=serv['uuid']) for serv in servers] diff --git a/nova/tests/functional/v3/api_samples/os-hypervisors/hypervisors-servers-resp.json.tpl b/nova/tests/functional/v3/api_samples/os-hypervisors/hypervisors-servers-resp.json.tpl index 857a1b216659..375627499df6 100644 --- a/nova/tests/functional/v3/api_samples/os-hypervisors/hypervisors-servers-resp.json.tpl +++ b/nova/tests/functional/v3/api_samples/os-hypervisors/hypervisors-servers-resp.json.tpl @@ -4,8 +4,7 @@ "hypervisor_hostname": "fake-mini", "id": 1, "state": "up", - "status": "enabled", - "servers": [] + "status": "enabled" } ] } diff --git a/nova/tests/unit/api/openstack/compute/contrib/test_hypervisors.py b/nova/tests/unit/api/openstack/compute/contrib/test_hypervisors.py index 3c437a954eba..9f63a3d1160f 100644 --- a/nova/tests/unit/api/openstack/compute/contrib/test_hypervisors.py +++ b/nova/tests/unit/api/openstack/compute/contrib/test_hypervisors.py @@ -179,10 +179,6 @@ class HypervisorsTestV21(test.NoDBTestCase): dict(id=2, hypervisor_hostname="hyper2", state='up', status='enabled')] - NO_SERVER_HYPER_DICTS = copy.deepcopy(INDEX_HYPER_DICTS) - NO_SERVER_HYPER_DICTS[0].update({'servers': []}) - NO_SERVER_HYPER_DICTS[1].update({'servers': []}) - def _get_request(self, use_admin_context): return fakes.HTTPRequest.blank('', use_admin_context=use_admin_context) @@ -385,7 +381,7 @@ class HypervisorsTestV21(test.NoDBTestCase): fake_instance_get_all_by_host_return_empty) req = self._get_request(True) result = self.controller.servers(req, '1') - self.assertEqual(result, dict(hypervisors=self.NO_SERVER_HYPER_DICTS)) + self.assertEqual(result, dict(hypervisors=self.INDEX_HYPER_DICTS)) def test_statistics(self): req = self._get_request(True) @@ -429,15 +425,6 @@ class HypervisorsTestV2(HypervisorsTestV21): del INDEX_HYPER_DICTS[0]['status'] del INDEX_HYPER_DICTS[1]['status'] - NO_SERVER_HYPER_DICTS = copy.deepcopy( - HypervisorsTestV21.NO_SERVER_HYPER_DICTS) - del NO_SERVER_HYPER_DICTS[0]['state'] - del NO_SERVER_HYPER_DICTS[1]['state'] - del NO_SERVER_HYPER_DICTS[0]['status'] - del NO_SERVER_HYPER_DICTS[1]['status'] - del NO_SERVER_HYPER_DICTS[0]['servers'] - del NO_SERVER_HYPER_DICTS[1]['servers'] - def _set_up_controller(self): self.context = context.get_admin_context() self.ext_mgr = extensions.ExtensionManager()