From ec72bfa7897e79bdc5e437ca3d0dd9aeeaecc733 Mon Sep 17 00:00:00 2001 From: Lucas Alvares Gomes Date: Tue, 20 May 2014 11:52:34 +0100 Subject: [PATCH] Set the correct target versions for the RPC methods This patch sets the correct target versions for the RPC methods in the RPC API. This is a first step towards being able to enable rolling upgrades for Ironic. Partial-Bug: #1317300 Change-Id: I67ce731731c38e48b4f3180a423cbc18a3728903 --- ironic/conductor/rpcapi.py | 26 +++++++++++++------------- ironic/tests/conductor/test_rpcapi.py | 12 ++++++++++++ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/ironic/conductor/rpcapi.py b/ironic/conductor/rpcapi.py index 64aa79f807..d2b0f885e7 100644 --- a/ironic/conductor/rpcapi.py +++ b/ironic/conductor/rpcapi.py @@ -66,7 +66,7 @@ class ConductorAPI(object): self.topic = manager.MANAGER_TOPIC target = messaging.Target(topic=self.topic, - version=self.RPC_API_VERSION) + version='1.0') serializer = objects_base.IronicObjectSerializer() self.client = rpc.get_client(target, version_cap=self.RPC_API_VERSION, @@ -123,7 +123,7 @@ class ConductorAPI(object): :returns: updated node object, including all fields. """ - cctxt = self.client.prepare(topic=topic or self.topic) + cctxt = self.client.prepare(topic=topic or self.topic, version='1.1') return cctxt.call(context, 'update_node', node_obj=node_obj) def change_node_power_state(self, context, node_id, new_state, topic=None): @@ -138,7 +138,7 @@ class ConductorAPI(object): async task. """ - cctxt = self.client.prepare(topic=topic or self.topic) + cctxt = self.client.prepare(topic=topic or self.topic, version='1.6') return cctxt.call(context, 'change_node_power_state', node_id=node_id, new_state=new_state) @@ -159,7 +159,7 @@ class ConductorAPI(object): async task. """ - cctxt = self.client.prepare(topic=topic or self.topic) + cctxt = self.client.prepare(topic=topic or self.topic, version='1.12') return cctxt.call(context, 'vendor_passthru', node_id=node_id, driver_method=driver_method, info=info) @@ -178,7 +178,7 @@ class ConductorAPI(object): specified driver_method. """ - cctxt = self.client.prepare(topic=topic or self.topic) + cctxt = self.client.prepare(topic=topic or self.topic, version='1.14') return cctxt.call(context, 'driver_vendor_passthru', driver_name=driver_name, driver_method=driver_method, @@ -200,7 +200,7 @@ class ConductorAPI(object): undeployed state before this method is called. """ - cctxt = self.client.prepare(topic=topic or self.topic) + cctxt = self.client.prepare(topic=topic or self.topic, version='1.15') return cctxt.call(context, 'do_node_deploy', node_id=node_id, rebuild=rebuild) @@ -219,7 +219,7 @@ class ConductorAPI(object): deployed state before this method is called. """ - cctxt = self.client.prepare(topic=topic or self.topic) + cctxt = self.client.prepare(topic=topic or self.topic, version='1.6') return cctxt.call(context, 'do_node_tear_down', node_id=node_id) def validate_driver_interfaces(self, context, node_id, topic=None): @@ -232,7 +232,7 @@ class ConductorAPI(object): interface validation. """ - cctxt = self.client.prepare(topic=topic or self.topic) + cctxt = self.client.prepare(topic=topic or self.topic, version='1.5') return cctxt.call(context, 'validate_driver_interfaces', node_id=node_id) @@ -247,7 +247,7 @@ class ConductorAPI(object): :raises: NodeMaintenanceFailure. """ - cctxt = self.client.prepare(topic=topic or self.topic) + cctxt = self.client.prepare(topic=topic or self.topic, version='1.8') return cctxt.call(context, 'change_node_maintenance_mode', node_id=node_id, mode=mode) @@ -262,7 +262,7 @@ class ConductorAPI(object): :raises: NodeInWrongPowerState if the node is not powered off. """ - cctxt = self.client.prepare(topic=topic or self.topic) + cctxt = self.client.prepare(topic=topic or self.topic, version='1.9') return cctxt.call(context, 'destroy_node', node_id=node_id) def get_console_information(self, context, node_id, topic=None): @@ -275,7 +275,7 @@ class ConductorAPI(object): support console. :raises: InvalidParameterValue when the wrong driver info is specified. """ - cctxt = self.client.prepare(topic=topic or self.topic) + cctxt = self.client.prepare(topic=topic or self.topic, version='1.11') return cctxt.call(context, 'get_console_information', node_id=node_id) def set_console_mode(self, context, node_id, enabled, topic=None): @@ -292,7 +292,7 @@ class ConductorAPI(object): :raises: NoFreeConductorWorker when there is no free worker to start async task. """ - cctxt = self.client.prepare(topic=topic or self.topic) + cctxt = self.client.prepare(topic=topic or self.topic, version='1.11') return cctxt.call(context, 'set_console_mode', node_id=node_id, enabled=enabled) @@ -309,5 +309,5 @@ class ConductorAPI(object): :returns: updated port object, including all fields. """ - cctxt = self.client.prepare(topic=topic or self.topic) + cctxt = self.client.prepare(topic=topic or self.topic, version='1.13') return cctxt.call(context, 'update_port', port_obj=port_obj) diff --git a/ironic/tests/conductor/test_rpcapi.py b/ironic/tests/conductor/test_rpcapi.py index 550028676b..da1580e855 100644 --- a/ironic/tests/conductor/test_rpcapi.py +++ b/ironic/tests/conductor/test_rpcapi.py @@ -144,17 +144,20 @@ class RPCAPITestCase(base.DbTestCase): def test_update_node(self): self._test_rpcapi('update_node', 'call', + version='1.1', node_obj=self.fake_node) def test_change_node_power_state(self): self._test_rpcapi('change_node_power_state', 'call', + version='1.6', node_id=self.fake_node['uuid'], new_state=states.POWER_ON) def test_pass_vendor_info(self): self._test_rpcapi('vendor_passthru', 'call', + version='1.12', node_id=self.fake_node['uuid'], driver_method='test-driver-method', info={"test_info": "test_value"}) @@ -162,6 +165,7 @@ class RPCAPITestCase(base.DbTestCase): def test_driver_vendor_passthru(self): self._test_rpcapi('driver_vendor_passthru', 'call', + version='1.14', driver_name='test-driver-name', driver_method='test-driver-method', info={'test_key': 'test_value'}) @@ -169,38 +173,45 @@ class RPCAPITestCase(base.DbTestCase): def test_do_node_deploy(self): self._test_rpcapi('do_node_deploy', 'call', + version='1.15', node_id=self.fake_node['uuid'], rebuild=False) def test_do_node_tear_down(self): self._test_rpcapi('do_node_tear_down', 'call', + version='1.6', node_id=self.fake_node['uuid']) def test_validate_driver_interfaces(self): self._test_rpcapi('validate_driver_interfaces', 'call', + version='1.5', node_id=self.fake_node['uuid']) def test_change_node_maintenance_mode(self): self._test_rpcapi('change_node_maintenance_mode', 'call', + version='1.8', node_id=self.fake_node['uuid'], mode=True) def test_destroy_node(self): self._test_rpcapi('destroy_node', 'call', + version='1.9', node_id=self.fake_node['uuid']) def test_get_console_information(self): self._test_rpcapi('get_console_information', 'call', + version='1.11', node_id=self.fake_node['uuid']) def test_set_console_mode(self): self._test_rpcapi('set_console_mode', 'call', + version='1.11', node_id=self.fake_node['uuid'], enabled=True) @@ -208,4 +219,5 @@ class RPCAPITestCase(base.DbTestCase): fake_port = dbutils.get_test_port() self._test_rpcapi('update_port', 'call', + version='1.13', port_obj=fake_port)