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
This commit is contained in:
Andrew Laski 2016-06-24 12:27:38 -04:00
parent 5d15918076
commit aeebd6614a
5 changed files with 16 additions and 12 deletions

View File

@ -13,7 +13,7 @@
"disabled_reason": null,
"report_count": 1,
"forced_down": false,
"version": 12
"version": 13
}
},
"event_type": "service.update",

View File

@ -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

View File

@ -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'

View File

@ -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'},
)

View File

@ -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',