Remove unnecesssary nova constructor calls in each manager API call path
auth.authenticate() creates a nova client object. This nova client object is never reused introducing a 40msec penalty for each API call. The heat-api-cfn module authenticates incoming requests. In a properly secured environment (one where RPC is secured), the auth.authenticate() calls serve no purpose. Change-Id: I847af259f521a32a7bf3fda0ce3f72735f762a0c Signed-off-by: Steven Dake <sdake@redhat.com>
This commit is contained in:
parent
e32feeb448
commit
28b4d3e37c
@ -70,8 +70,10 @@ def authenticate(con, service_type='orchestration', service_name='heat'):
|
||||
"""
|
||||
|
||||
if con.password is not None:
|
||||
nova = client.Client(con.username, con.password,
|
||||
con.tenant, con.auth_url,
|
||||
nova = client.Client(username=con.username,
|
||||
api_key=con.password,
|
||||
project_id=con.tenant,
|
||||
auth_url=con.auth_url,
|
||||
service_type=service_type,
|
||||
service_name=service_name)
|
||||
nova.authenticate()
|
||||
|
@ -69,8 +69,6 @@ class EngineManager(manager.Manager):
|
||||
arg1 -> RPC context.
|
||||
arg2 -> Name of the stack to look up.
|
||||
"""
|
||||
auth.authenticate(context)
|
||||
|
||||
s = db_api.stack_get_by_name(context, stack_name)
|
||||
if s:
|
||||
stack = parser.Stack.load(context, s.id)
|
||||
@ -101,8 +99,6 @@ class EngineManager(manager.Manager):
|
||||
arg2 -> Name of the stack you want to see, or None to see all
|
||||
arg3 -> Dict of http request parameters passed in from API side.
|
||||
"""
|
||||
auth.authenticate(context)
|
||||
|
||||
if stack_identity is not None:
|
||||
stacks = [self._get_stack(context, stack_identity)]
|
||||
else:
|
||||
@ -128,8 +124,6 @@ class EngineManager(manager.Manager):
|
||||
"""
|
||||
logger.info('template is %s' % template)
|
||||
|
||||
auth.authenticate(context)
|
||||
|
||||
if db_api.stack_get_by_name(None, stack_name):
|
||||
raise AttributeError('Stack already exists with that name')
|
||||
|
||||
@ -165,8 +159,6 @@ class EngineManager(manager.Manager):
|
||||
"""
|
||||
logger.info('template is %s' % template)
|
||||
|
||||
auth.authenticate(context)
|
||||
|
||||
# Get the database representation of the existing stack
|
||||
db_stack = self._get_stack(context, stack_identity)
|
||||
|
||||
@ -199,8 +191,6 @@ class EngineManager(manager.Manager):
|
||||
arg3 -> Template of stack you want to create.
|
||||
arg4 -> Params passed from API.
|
||||
"""
|
||||
auth.authenticate(context)
|
||||
|
||||
logger.info('validate_template')
|
||||
if template is None:
|
||||
msg = _("No Template provided.")
|
||||
@ -238,7 +228,6 @@ class EngineManager(manager.Manager):
|
||||
arg2 -> Name of the stack you want to see.
|
||||
arg3 -> Dict of http request parameters passed in from API side.
|
||||
"""
|
||||
auth.authenticate(context)
|
||||
s = self._get_stack(context, stack_identity)
|
||||
if s:
|
||||
return s.raw_template.template
|
||||
@ -251,9 +240,6 @@ class EngineManager(manager.Manager):
|
||||
arg2 -> Name of the stack you want to delete.
|
||||
arg3 -> Params passed from API.
|
||||
"""
|
||||
|
||||
auth.authenticate(context)
|
||||
|
||||
st = self._get_stack(context, stack_identity)
|
||||
|
||||
logger.info('deleting stack %s' % st.name)
|
||||
@ -269,9 +255,6 @@ class EngineManager(manager.Manager):
|
||||
arg2 -> Name of the stack you want to get events for.
|
||||
arg3 -> Params passed from API.
|
||||
"""
|
||||
|
||||
auth.authenticate(context)
|
||||
|
||||
if stack_identity is not None:
|
||||
st = self._get_stack(context, stack_identity)
|
||||
|
||||
@ -282,9 +265,6 @@ class EngineManager(manager.Manager):
|
||||
return {'events': [api.format_event(context, e) for e in events]}
|
||||
|
||||
def event_create(self, context, event):
|
||||
|
||||
auth.authenticate(context)
|
||||
|
||||
stack_name = event['stack']
|
||||
resource_name = event['resource']
|
||||
stack = db_api.stack_get_by_name(context, stack_name)
|
||||
@ -312,8 +292,6 @@ class EngineManager(manager.Manager):
|
||||
return [msg, None]
|
||||
|
||||
def describe_stack_resource(self, context, stack_identity, resource_name):
|
||||
auth.authenticate(context)
|
||||
|
||||
s = self._get_stack(context, stack_identity)
|
||||
|
||||
stack = parser.Stack.load(context, s.id)
|
||||
@ -328,8 +306,6 @@ class EngineManager(manager.Manager):
|
||||
|
||||
def describe_stack_resources(self, context, stack_identity,
|
||||
physical_resource_id, logical_resource_id):
|
||||
auth.authenticate(context)
|
||||
|
||||
if stack_identity is not None:
|
||||
s = self._get_stack(context, stack_identity)
|
||||
else:
|
||||
@ -355,8 +331,6 @@ class EngineManager(manager.Manager):
|
||||
name_match(resource)]
|
||||
|
||||
def list_stack_resources(self, context, stack_identity):
|
||||
auth.authenticate(context)
|
||||
|
||||
s = self._get_stack(context, stack_identity)
|
||||
|
||||
stack = parser.Stack.load(context, s.id)
|
||||
|
@ -48,7 +48,6 @@ def create_context(mocks, user='stacks_test_user',
|
||||
mocks.StubOutWithMock(ctx, 'tenant')
|
||||
ctx.username = user
|
||||
ctx.tenant = tenant
|
||||
mocks.StubOutWithMock(auth, 'authenticate')
|
||||
return ctx
|
||||
|
||||
|
||||
@ -133,7 +132,6 @@ class stackManagerCreateUpdateDeleteTest(unittest.TestCase):
|
||||
self.username = 'stack_manager_create_test_user'
|
||||
self.tenant = 'stack_manager_create_test_tenant'
|
||||
self.ctx = create_context(self.m, self.username, self.tenant)
|
||||
auth.authenticate(self.ctx).AndReturn(True)
|
||||
|
||||
self.man = manager.EngineManager()
|
||||
|
||||
@ -360,7 +358,6 @@ class stackManagerTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.m = mox.Mox()
|
||||
self.ctx = create_context(self.m, self.username, self.tenant)
|
||||
auth.authenticate(self.ctx).AndReturn(True)
|
||||
setup_mocks(self.m, self.stack)
|
||||
self.m.ReplayAll()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user