Skip to content

Commit 27e88f6

Browse files
committed
Stop handling cells v1 in '/os-hypervisors' API
Part of blueprint remove-cells-v1 Change-Id: I5d2ff94bc7c2f0b282e3abf1b50d96aeed9c8407 Signed-off-by: Stephen Finucane <[email protected]>
1 parent fb14f24 commit 27e88f6

File tree

3 files changed

+1
-139
lines changed

3 files changed

+1
-139
lines changed

nova/api/openstack/compute/hypervisors.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from nova.api.openstack.compute.views import hypervisors as hyper_view
2828
from nova.api.openstack import wsgi
2929
from nova.api import validation
30-
from nova.cells import utils as cells_utils
3130
from nova import compute
3231
from nova import exception
3332
from nova.i18n import _
@@ -267,11 +266,6 @@ def _validate_id(req, hypervisor_id):
267266
msg = _('Invalid uuid %s') % hypervisor_id
268267
raise webob.exc.HTTPBadRequest(explanation=msg)
269268
else:
270-
# This API is supported for cells v1 and as such the id can be
271-
# a cell v1 delimited string, so we have to parse it first.
272-
if cells_utils.CELL_ITEM_SEP in str(hypervisor_id):
273-
hypervisor_id = cells_utils.split_cell_and_item(
274-
hypervisor_id)[1]
275269
try:
276270
utils.validate_integer(hypervisor_id, 'id')
277271
except exception.InvalidInput:

nova/tests/functional/api_sample_tests/test_hypervisors.py

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
import mock
1717

18-
from nova.cells import utils as cells_utils
19-
from nova import objects
2018
from nova.tests.functional.api_sample_tests import api_sample_base
2119
from nova.virt import fake
2220

@@ -94,48 +92,6 @@ def fake_get_host_uptime(self, context, hyp):
9492
self._verify_response('hypervisors-uptime-resp', subs, response, 200)
9593

9694

97-
@mock.patch("nova.servicegroup.API.service_is_up", return_value=True)
98-
class HypervisorsCellsSampleJsonTests(api_sample_base.ApiSampleTestBaseV21):
99-
ADMIN_API = True
100-
sample_dir = "os-hypervisors"
101-
102-
def setUp(self):
103-
self.flags(enable=True, cell_type='api', group='cells')
104-
super(HypervisorsCellsSampleJsonTests, self).setUp()
105-
106-
def test_hypervisor_uptime(self, mocks):
107-
fake_hypervisor = objects.ComputeNode(id=1, host='fake-mini',
108-
hypervisor_hostname='fake-mini')
109-
110-
def fake_get_host_uptime(self, context, hyp):
111-
return (" 08:32:11 up 93 days, 18:25, 12 users, load average:"
112-
" 0.20, 0.12, 0.14")
113-
114-
def fake_compute_node_get(self, context, hyp):
115-
return fake_hypervisor
116-
117-
def fake_service_get_by_compute_host(self, context, host):
118-
return cells_utils.ServiceProxy(
119-
objects.Service(id=1, host='fake-mini', disabled=False,
120-
disabled_reason=None),
121-
'cell1')
122-
123-
self.stub_out(
124-
'nova.compute.cells_api.HostAPI.compute_node_get',
125-
fake_compute_node_get)
126-
self.stub_out(
127-
'nova.compute.cells_api.HostAPI.service_get_by_compute_host',
128-
fake_service_get_by_compute_host)
129-
self.stub_out(
130-
'nova.compute.cells_api.HostAPI.get_host_uptime',
131-
fake_get_host_uptime)
132-
133-
hypervisor_id = fake_hypervisor.id
134-
response = self._do_get('os-hypervisors/%s/uptime' % hypervisor_id)
135-
subs = {'hypervisor_id': str(hypervisor_id)}
136-
self._verify_response('hypervisors-uptime-resp', subs, response, 200)
137-
138-
13995
class HypervisorsSampleJson228Tests(HypervisorsSampleJsonTests):
14096
microversion = '2.28'
14197
scenarios = [('v2_28', {'api_major_version': 'v2.1'})]

nova/tests/unit/api/openstack/compute/test_hypervisors.py

Lines changed: 1 addition & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
from nova.api.openstack.compute import hypervisors \
2626
as hypervisors_v21
27-
from nova.cells import utils as cells_utils
2827
from nova import exception
2928
from nova import objects
3029
from nova import test
@@ -188,7 +187,7 @@ class HypervisorsTestV21(test.NoDBTestCase):
188187
# compute node primary key integer id or the uuid.
189188
expect_uuid_for_id = False
190189

191-
# copying the objects locally so the cells testcases can provide their own
190+
# TODO(stephenfin): These should just be defined here
192191
TEST_HYPERS_OBJ = copy.deepcopy(TEST_HYPERS_OBJ)
193192
TEST_SERVICES = copy.deepcopy(TEST_SERVICES)
194193
TEST_SERVERS = copy.deepcopy(TEST_SERVERS)
@@ -723,93 +722,6 @@ def test_statistics_non_admin(self):
723722
self.controller.statistics, req)
724723

725724

726-
_CELL_PATH = 'cell1'
727-
728-
729-
class CellHypervisorsTestV21(HypervisorsTestV21):
730-
TEST_HYPERS_OBJ = [cells_utils.ComputeNodeProxy(obj, _CELL_PATH)
731-
for obj in TEST_HYPERS_OBJ]
732-
TEST_SERVICES = [cells_utils.ServiceProxy(obj, _CELL_PATH)
733-
for obj in TEST_SERVICES]
734-
735-
TEST_SERVERS = [dict(server,
736-
host=cells_utils.cell_with_item(_CELL_PATH,
737-
server['host']))
738-
for server in TEST_SERVERS]
739-
740-
DETAIL_HYPERS_DICTS = copy.deepcopy(HypervisorsTestV21.DETAIL_HYPERS_DICTS)
741-
DETAIL_HYPERS_DICTS = [dict(hyp, id=cells_utils.cell_with_item(_CELL_PATH,
742-
hyp['id']),
743-
service=dict(hyp['service'],
744-
id=cells_utils.cell_with_item(
745-
_CELL_PATH,
746-
hyp['service']['id']),
747-
host=cells_utils.cell_with_item(
748-
_CELL_PATH,
749-
hyp['service']['host'])))
750-
for hyp in DETAIL_HYPERS_DICTS]
751-
752-
INDEX_HYPER_DICTS = copy.deepcopy(HypervisorsTestV21.INDEX_HYPER_DICTS)
753-
INDEX_HYPER_DICTS = [dict(hyp, id=cells_utils.cell_with_item(_CELL_PATH,
754-
hyp['id']))
755-
for hyp in INDEX_HYPER_DICTS]
756-
757-
# __deepcopy__ is added for copying an object locally in
758-
# _test_view_hypervisor_detail_cpuinfo_null
759-
cells_utils.ComputeNodeProxy.__deepcopy__ = (lambda self, memo:
760-
cells_utils.ComputeNodeProxy(copy.deepcopy(self._obj, memo),
761-
self._cell_path))
762-
763-
@classmethod
764-
def fake_compute_node_get_all(cls, context, limit=None, marker=None):
765-
return cls.TEST_HYPERS_OBJ
766-
767-
@classmethod
768-
def fake_compute_node_search_by_hypervisor(cls, context, hypervisor_re):
769-
return cls.TEST_HYPERS_OBJ
770-
771-
@classmethod
772-
def fake_compute_node_get(cls, context, compute_id):
773-
for hyper in cls.TEST_HYPERS_OBJ:
774-
if hyper.id == compute_id:
775-
return hyper
776-
raise exception.ComputeHostNotFound(host=compute_id)
777-
778-
@classmethod
779-
def fake_service_get_by_compute_host(cls, context, host):
780-
for service in cls.TEST_SERVICES:
781-
if service.host == host:
782-
return service
783-
784-
@classmethod
785-
def fake_instance_get_all_by_host(cls, context, host):
786-
results = []
787-
for inst in cls.TEST_SERVERS:
788-
if inst['host'] == host:
789-
results.append(inst)
790-
return results
791-
792-
def setUp(self):
793-
794-
self.flags(enable=True, cell_type='api', group='cells')
795-
796-
super(CellHypervisorsTestV21, self).setUp()
797-
798-
host_api = self.controller.host_api
799-
host_api.compute_node_get_all = mock.MagicMock(
800-
side_effect=self.fake_compute_node_get_all)
801-
host_api.service_get_by_compute_host = mock.MagicMock(
802-
side_effect=self.fake_service_get_by_compute_host)
803-
host_api.compute_node_search_by_hypervisor = mock.MagicMock(
804-
side_effect=self.fake_compute_node_search_by_hypervisor)
805-
host_api.compute_node_get = mock.MagicMock(
806-
side_effect=self.fake_compute_node_get)
807-
host_api.compute_node_statistics = mock.MagicMock(
808-
side_effect=fake_compute_node_statistics)
809-
host_api.instance_get_all_by_host = mock.MagicMock(
810-
side_effect=self.fake_instance_get_all_by_host)
811-
812-
813725
class HypervisorsTestV228(HypervisorsTestV21):
814726
api_version = '2.28'
815727

0 commit comments

Comments
 (0)