Removed Mitaka times compatibility code from RPC callbacks

This code was needed for some Mitaka to Newton upgrade scenarios, but we
are now in Ocata to Pike, so killing the code is overdue.

Change-Id: Ida3fc4ce2d18c50e603b2b71dfb8f884845bf78a
This commit is contained in:
Ihar Hrachyshka
2017-06-09 10:36:46 -07:00
committed by Kevin Benton
parent 01cc2696b7
commit ea3028a1c0
2 changed files with 5 additions and 45 deletions

View File

@@ -236,29 +236,18 @@ class ResourcesPushRpcApi(object):
def _push(self, context, resource_type, resource_list, event_type):
"""Push an event and list of resources of the same type to agents."""
_validate_resource_type(resource_type)
compat_call = len(resource_list) == 1
for version in version_manager.get_resource_versions(resource_type):
cctxt = self._prepare_object_fanout_context(
resource_list[0], version,
rpc_version='1.0' if compat_call else '1.1')
resource_list[0], version, rpc_version='1.1')
dehydrated_resources = [
resource.obj_to_primitive(target_version=version)
for resource in resource_list]
if compat_call:
#TODO(mangelajo): remove in Ocata, backwards compatibility
# for agents expecting a single element as
# a single element instead of a list, this
# is only relevant to the QoSPolicy topic queue
cctxt.cast(context, 'push',
resource=dehydrated_resources[0],
event_type=event_type)
else:
cctxt.cast(context, 'push',
resource_list=dehydrated_resources,
event_type=event_type)
cctxt.cast(context, 'push',
resource_list=dehydrated_resources,
event_type=event_type)
class ResourcesPushRpcCallback(object):
@@ -278,10 +267,7 @@ class ResourcesPushRpcCallback(object):
@oslo_messaging.expected_exceptions(rpc_exc.CallbackNotFound)
def push(self, context, **kwargs):
"""Push receiver, will always receive resources of the same type."""
# TODO(mangelajo): accept single 'resource' parameter for backwards
# compatibility during Newton, remove in Ocata
resource_list = ([kwargs['resource']] if 'resource' in kwargs else
kwargs['resource_list'])
resource_list = kwargs['resource_list']
event_type = kwargs['event_type']
resource_objs = [

View File

@@ -300,18 +300,6 @@ class ResourcesPushRpcApiTestCase(ResourcesRpcBaseTestCase):
for resource in self.resource_objs2],
event_type=TEST_EVENT)
def test_push_mitaka_backwardscompat(self):
#TODO(mangelajo) remove in Ocata, since the 'resource' parameter
# is just for backwards compatibility with Mitaka
# agents.
self.rpc.push(
self.context, [self.resource_objs[0]], TEST_EVENT)
self.cctxt_mock.cast.assert_called_once_with(
self.context, 'push',
resource=self.resource_objs[0].obj_to_primitive(),
event_type=TEST_EVENT)
class ResourcesPushRpcCallbackTestCase(ResourcesRpcBaseTestCase):
"""Tests the agent-side of the RPC interface."""
@@ -331,17 +319,3 @@ class ResourcesPushRpcCallbackTestCase(ResourcesRpcBaseTestCase):
self.resource_objs[0].obj_name(),
self.resource_objs,
TEST_EVENT)
@mock.patch.object(resources_rpc.cons_registry, 'push')
def test_push_mitaka_backwardscompat(self, reg_push_mock):
#TODO(mangelajo) remove in Ocata, since the 'resource' parameter
# is just for backwards compatibility with Mitaka
# agents.
self.obj_registry.register(FakeResource)
self.callbacks.push(self.context,
resource=self.resource_objs[0].obj_to_primitive(),
event_type=TEST_EVENT)
reg_push_mock.assert_called_once_with(self.context,
self.resource_objs[0].obj_name(),
[self.resource_objs[0]],
TEST_EVENT)