Add V2 rpc api for consoleauth
Add support for the 2.0 consoleauth rpc API. This commit retains compatibility with the older 1.X API to allow continuous deployment without any downtime. UpgradeImpact - Deployments doing continuous deployment should follow this process to upgrade without any downtime with the consoleauth service: 1) Sync all consoleauth services to this commit, so that they handle both new and old messages. 2) Upgrade everything else to this commit so that all clients start sending the new messages. 3) Upgrade past this, where support for the old messages will be dropped. Part of blueprint rpc-major-version-updates-icehouse Change-Id: Iad71d3c2801f9355968e69bce3308b84f922b239
This commit is contained in:
parent
95b6724cac
commit
48dd520958
|
@ -59,6 +59,13 @@ class ConsoleAuthManager(manager.Manager):
|
|||
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
||||
self.cells_rpcapi = cells_rpcapi.CellsAPI()
|
||||
|
||||
def create_rpc_dispatcher(self, backdoor_port=None, additional_apis=None):
|
||||
if not additional_apis:
|
||||
additional_apis = []
|
||||
additional_apis.append(_ConsoleAuthManagerV2Proxy(self))
|
||||
return super(ConsoleAuthManager, self).create_rpc_dispatcher(
|
||||
backdoor_port, additional_apis)
|
||||
|
||||
def _get_tokens_for_instance(self, instance_uuid):
|
||||
tokens_str = self.mc.get(instance_uuid.encode('UTF-8'))
|
||||
if not tokens_str:
|
||||
|
@ -132,3 +139,25 @@ class ConsoleAuthManager(manager.Manager):
|
|||
# deprecated in favor of the method in the base API.
|
||||
def get_backdoor_port(self, context):
|
||||
return self.backdoor_port
|
||||
|
||||
|
||||
class _ConsoleAuthManagerV2Proxy(object):
|
||||
# Notes for changes since 1.X
|
||||
# - removed get_backdoor_port()
|
||||
# - instance_uuid required for authorize_console()
|
||||
|
||||
RPC_API_VERSION = '2.0'
|
||||
|
||||
def __init__(self, manager):
|
||||
self.manager = manager
|
||||
|
||||
def authorize_console(self, context, token, console_type, host, port,
|
||||
internal_access_path, instance_uuid):
|
||||
self.manager.authorize_console(context, token, console_type, host,
|
||||
port, internal_access_path, instance_uuid)
|
||||
|
||||
def check_token(self, context, token):
|
||||
self.manager.check_token(context, token)
|
||||
|
||||
def delete_tokens_for_instance(self, ctxt, instance_uuid):
|
||||
self.manager.delete_tokens_for_instance(ctxt, instance_uuid)
|
||||
|
|
|
@ -42,6 +42,8 @@ class ConsoleAuthAPI(rpcclient.RpcProxy):
|
|||
... Grizzly and Havana support message version 1.2. So, any changes
|
||||
to existing methods in 2.x after that point should be done such that
|
||||
they can handle the version_cap being set to 1.2.
|
||||
|
||||
2.0 - Major API rev for Icehouse
|
||||
'''
|
||||
|
||||
#
|
||||
|
@ -52,7 +54,7 @@ class ConsoleAuthAPI(rpcclient.RpcProxy):
|
|||
# about rpc API versioning, see the docs in
|
||||
# openstack/common/rpc/dispatcher.py.
|
||||
#
|
||||
BASE_RPC_API_VERSION = '1.0'
|
||||
BASE_RPC_API_VERSION = '2.0'
|
||||
|
||||
VERSION_ALIASES = {
|
||||
'grizzly': '1.2',
|
||||
|
@ -69,11 +71,10 @@ class ConsoleAuthAPI(rpcclient.RpcProxy):
|
|||
self.client = self.get_client()
|
||||
|
||||
def authorize_console(self, ctxt, token, console_type, host, port,
|
||||
internal_access_path, instance_uuid=None):
|
||||
internal_access_path, instance_uuid):
|
||||
# The remote side doesn't return anything, but we want to block
|
||||
# until it completes.
|
||||
cctxt = self.client.prepare(version='1.2')
|
||||
return cctxt.call(ctxt,
|
||||
return self.client.call(ctxt,
|
||||
'authorize_console',
|
||||
token=token, console_type=console_type,
|
||||
host=host, port=port,
|
||||
|
@ -84,7 +85,6 @@ class ConsoleAuthAPI(rpcclient.RpcProxy):
|
|||
return self.client.call(ctxt, 'check_token', token=token)
|
||||
|
||||
def delete_tokens_for_instance(self, ctxt, instance_uuid):
|
||||
cctxt = self.client.prepare(version='1.2')
|
||||
return cctxt.cast(ctxt,
|
||||
return self.client.cast(ctxt,
|
||||
'delete_tokens_for_instance',
|
||||
instance_uuid=instance_uuid)
|
||||
|
|
|
@ -7439,7 +7439,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||
rpc_msg2 = {'method': 'authorize_console',
|
||||
'namespace': None,
|
||||
'args': fake_connect_info,
|
||||
'version': '1.2'}
|
||||
'version': '2.0'}
|
||||
|
||||
rpc.call(self.context, 'compute.%s' % fake_instance['host'],
|
||||
rpc_msg1, None).AndReturn(fake_connect_info2)
|
||||
|
@ -7486,7 +7486,7 @@ class ComputeAPITestCase(BaseTestCase):
|
|||
rpc_msg2 = {'method': 'authorize_console',
|
||||
'namespace': None,
|
||||
'args': fake_connect_info,
|
||||
'version': '1.2'}
|
||||
'version': '2.0'}
|
||||
|
||||
rpc.call(self.context, 'compute.%s' % fake_instance['host'],
|
||||
rpc_msg1, None).AndReturn(fake_connect_info2)
|
||||
|
|
|
@ -67,8 +67,7 @@ class ConsoleAuthRpcAPITestCase(test.NoDBTestCase):
|
|||
def test_authorize_console(self):
|
||||
self._test_consoleauth_api('authorize_console', token='token',
|
||||
console_type='ctype', host='h', port='p',
|
||||
internal_access_path='iap', instance_uuid="instance",
|
||||
version="1.2")
|
||||
internal_access_path='iap', instance_uuid="instance")
|
||||
|
||||
def test_check_token(self):
|
||||
self._test_consoleauth_api('check_token', token='t')
|
||||
|
@ -76,5 +75,4 @@ class ConsoleAuthRpcAPITestCase(test.NoDBTestCase):
|
|||
def test_delete_tokens_for_instnace(self):
|
||||
self._test_consoleauth_api('delete_tokens_for_instance',
|
||||
_do_cast=True,
|
||||
instance_uuid="instance",
|
||||
version='1.2')
|
||||
instance_uuid="instance")
|
||||
|
|
Loading…
Reference in New Issue