Remove conductor usage from consoleauth service
There's no reason for the consoleauth service to use the conductor API since it is allowed to use the db directly. Remove the single conductor API call and replace it with the equivalent db call. Fix bug 1190271. Change-Id: Id6f50873f792ac4393dc2063f599f0418598091b
This commit is contained in:
parent
2253bc41a2
commit
13a6574987
|
@ -24,7 +24,6 @@ from oslo.config import cfg
|
|||
|
||||
from nova.cells import rpcapi as cells_rpcapi
|
||||
from nova.compute import rpcapi as compute_rpcapi
|
||||
from nova import conductor
|
||||
from nova import manager
|
||||
from nova.openstack.common import jsonutils
|
||||
from nova.openstack.common import log as logging
|
||||
|
@ -56,7 +55,6 @@ class ConsoleAuthManager(manager.Manager):
|
|||
super(ConsoleAuthManager, self).__init__(service_name='consoleauth',
|
||||
*args, **kwargs)
|
||||
self.mc = memorycache.get_client()
|
||||
self.conductor_api = conductor.API()
|
||||
self.compute_rpcapi = compute_rpcapi.ComputeAPI()
|
||||
self.cells_rpcapi = cells_rpcapi.CellsAPI()
|
||||
|
||||
|
@ -100,8 +98,8 @@ class ConsoleAuthManager(manager.Manager):
|
|||
return self.cells_rpcapi.validate_console_port(context,
|
||||
instance_uuid, token['port'], token['console_type'])
|
||||
|
||||
instance = self.conductor_api.instance_get_by_uuid(context,
|
||||
instance_uuid)
|
||||
instance = self.db.instance_get_by_uuid(context, instance_uuid)
|
||||
|
||||
return self.compute_rpcapi.validate_console_port(context,
|
||||
instance,
|
||||
token['port'],
|
||||
|
|
|
@ -23,6 +23,7 @@ Tests for Consoleauth Code.
|
|||
import mox
|
||||
from nova.consoleauth import manager
|
||||
from nova import context
|
||||
from nova import db
|
||||
from nova.openstack.common import timeutils
|
||||
from nova import test
|
||||
|
||||
|
@ -34,6 +35,7 @@ class ConsoleauthTestCase(test.TestCase):
|
|||
super(ConsoleauthTestCase, self).setUp()
|
||||
self.manager = manager.ConsoleAuthManager()
|
||||
self.context = context.get_admin_context()
|
||||
self.instance = db.instance_create(self.context, {})
|
||||
|
||||
def test_tokens_expire(self):
|
||||
# Test that tokens expire correctly.
|
||||
|
@ -45,7 +47,7 @@ class ConsoleauthTestCase(test.TestCase):
|
|||
|
||||
self.manager.authorize_console(self.context, token, 'novnc',
|
||||
'127.0.0.1', '8080', 'host',
|
||||
'instance')
|
||||
self.instance['uuid'])
|
||||
self.assertTrue(self.manager.check_token(self.context, token))
|
||||
timeutils.advance_time_seconds(1)
|
||||
self.assertFalse(self.manager.check_token(self.context, token))
|
||||
|
@ -60,27 +62,27 @@ class ConsoleauthTestCase(test.TestCase):
|
|||
|
||||
def test_multiple_tokens_for_instance(self):
|
||||
tokens = [u"token" + str(i) for i in xrange(10)]
|
||||
instance = u"12345"
|
||||
|
||||
self._stub_validate_console_port(True)
|
||||
|
||||
for token in tokens:
|
||||
self.manager.authorize_console(self.context, token, 'novnc',
|
||||
'127.0.0.1', '8080', 'host',
|
||||
instance)
|
||||
self.instance['uuid'])
|
||||
|
||||
for token in tokens:
|
||||
self.assertTrue(self.manager.check_token(self.context, token))
|
||||
|
||||
def test_delete_tokens_for_instance(self):
|
||||
instance = u"12345"
|
||||
tokens = [u"token" + str(i) for i in xrange(10)]
|
||||
for token in tokens:
|
||||
self.manager.authorize_console(self.context, token, 'novnc',
|
||||
'127.0.0.1', '8080', 'host',
|
||||
instance)
|
||||
self.manager.delete_tokens_for_instance(self.context, instance)
|
||||
stored_tokens = self.manager._get_tokens_for_instance(instance)
|
||||
self.instance['uuid'])
|
||||
self.manager.delete_tokens_for_instance(self.context,
|
||||
self.instance['uuid'])
|
||||
stored_tokens = self.manager._get_tokens_for_instance(
|
||||
self.instance['uuid'])
|
||||
|
||||
self.assertEqual(len(stored_tokens), 0)
|
||||
|
||||
|
@ -94,7 +96,7 @@ class ConsoleauthTestCase(test.TestCase):
|
|||
|
||||
self.manager.authorize_console(self.context, token, 'novnc',
|
||||
'127.0.0.1', '8080', 'host',
|
||||
instance_uuid=u'instance')
|
||||
instance_uuid=self.instance['uuid'])
|
||||
self.assertFalse(self.manager.check_token(self.context, token))
|
||||
|
||||
def test_console_no_instance_uuid(self):
|
||||
|
|
Loading…
Reference in New Issue