From aeebd6614a30ac7c2eab85edbb55923639673a44 Mon Sep 17 00:00:00 2001 From: Andrew Laski Date: Fri, 24 Jun 2016 12:27:38 -0400 Subject: [PATCH] Update get_instance_diagnostics for instance objects Removes a longstanding TODO to update this method to handle instance objects. The method is not actually used anywhere so there are no upgrade concerns, but proper protocol is observed regardless. Change-Id: Ieaf538fa2dc5c4a15574cc6aacac26abbac3b5a2 --- doc/notification_samples/service-update.json | 2 +- nova/compute/manager.py | 2 +- nova/compute/rpcapi.py | 16 +++++++++------- nova/objects/service.py | 4 +++- nova/tests/unit/compute/test_rpcapi.py | 4 ++-- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/doc/notification_samples/service-update.json b/doc/notification_samples/service-update.json index fd7605e784ba..be297591ca38 100644 --- a/doc/notification_samples/service-update.json +++ b/doc/notification_samples/service-update.json @@ -13,7 +13,7 @@ "disabled_reason": null, "report_count": 1, "forced_down": false, - "version": 12 + "version": 13 } }, "event_type": "service.update", diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 4400312ba870..c5cc384b664d 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -481,7 +481,7 @@ class ComputeVirtAPI(virtapi.VirtAPI): class ComputeManager(manager.Manager): """Manages the running instances from creation to destruction.""" - target = messaging.Target(version='4.12') + target = messaging.Target(version='4.13') # How long to wait in seconds before re-issuing a shutdown # signal to an instance during power off. The overall diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py index 8f3fbfb10b07..bd451fd450a9 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -312,6 +312,7 @@ class ComputeAPI(object): can handle the version_cap being set to 4.11 * 4.12 - Remove migration_id from live_migration_force_complete + * 4.13 - Make get_instance_diagnostics send an instance object ''' VERSION_ALIASES = { @@ -554,13 +555,14 @@ class ComputeAPI(object): return cctxt.call(ctxt, 'get_diagnostics', instance=instance) def get_instance_diagnostics(self, ctxt, instance): - # TODO(danms): This needs to be fixed for objects - instance_p = jsonutils.to_primitive(instance) - kwargs = {'instance': instance_p} - version = '4.0' - cctxt = self.get_cell_client(ctxt).prepare( - server=_compute_host(None, instance), version=version) - return cctxt.call(ctxt, 'get_instance_diagnostics', **kwargs) + version = '4.13' + cell_client = self.get_cell_client(ctxt) + if not cell_client.can_send_version(version): + version = '4.0' + instance = objects_base.obj_to_primitive(instance) + cctxt = cell_client.prepare(server=_compute_host(None, instance), + version=version) + return cctxt.call(ctxt, 'get_instance_diagnostics', instance=instance) def get_vnc_console(self, ctxt, instance, console_type): version = '4.0' diff --git a/nova/objects/service.py b/nova/objects/service.py index 9897a9e4189f..0b0b4bd9a76d 100644 --- a/nova/objects/service.py +++ b/nova/objects/service.py @@ -30,7 +30,7 @@ LOG = logging.getLogger(__name__) # NOTE(danms): This is the global service version counter -SERVICE_VERSION = 12 +SERVICE_VERSION = 13 # NOTE(danms): This is our SERVICE_VERSION history. The idea is that any @@ -79,6 +79,8 @@ SERVICE_VERSION_HISTORY = ( # Version 12: The network APIs and compute manager support a NetworkRequest # object where the network_id value is 'auto' or 'none'. {'compute_rpc': '4.12'}, + # Version 13: Compute RPC version 4.13 + {'compute_rpc': '4.13'}, ) diff --git a/nova/tests/unit/compute/test_rpcapi.py b/nova/tests/unit/compute/test_rpcapi.py index 4536818c5813..da307c741ad8 100644 --- a/nova/tests/unit/compute/test_rpcapi.py +++ b/nova/tests/unit/compute/test_rpcapi.py @@ -251,10 +251,10 @@ class ComputeRpcAPITestCase(test.NoDBTestCase): instance=self.fake_instance_obj, version='4.0') def test_get_instance_diagnostics(self): - expected_args = {'instance': self.fake_instance} + expected_args = {'instance': self.fake_instance_obj} self._test_compute_api('get_instance_diagnostics', 'call', expected_args, instance=self.fake_instance_obj, - version='4.0') + version='4.13') def test_get_vnc_console(self): self._test_compute_api('get_vnc_console', 'call',