Add user_creds_id to _create_stack RPC interface
Adds the ability to pass the parent user_creds_id into nested stacks when creating them via RPC, so we can maintain the current behavior in StackResource, where the parent user_creds record is used by all nested stacks. Change-Id: Ifed93860db68a7d23b0c05bd9ec83619e109e386 blueprint: decouple-nested
This commit is contained in:
parent
febe92a44d
commit
076a86e343
|
@ -160,20 +160,22 @@ class EngineClient(object):
|
|||
args)
|
||||
|
||||
def _create_stack(self, ctxt, stack_name, template, params, files, args,
|
||||
owner_id=None, nested_depth=0):
|
||||
owner_id=None, nested_depth=0, user_creds_id=None):
|
||||
"""
|
||||
Internal create_stack interface for engine-to-engine communication via
|
||||
RPC. Allows some additional options which should not be exposed to
|
||||
users via the API:
|
||||
:param owner_id: parent stack ID for nested stacks
|
||||
:param nested_depth: nested depth for nested stacks
|
||||
:param user_creds_id: user_creds record for nested stack
|
||||
"""
|
||||
return self.call(ctxt,
|
||||
self.make_msg('create_stack', stack_name=stack_name,
|
||||
template=template,
|
||||
params=params, files=files, args=args,
|
||||
owner_id=owner_id,
|
||||
nested_depth=nested_depth))
|
||||
nested_depth=nested_depth,
|
||||
user_creds_id=user_creds_id))
|
||||
|
||||
def update_stack(self, ctxt, stack_identity, template, params,
|
||||
files, args):
|
||||
|
|
|
@ -513,7 +513,8 @@ class CfnStackControllerTest(common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': engine_args,
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndReturn(engine_resp)
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
@ -561,7 +562,8 @@ class CfnStackControllerTest(common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': engine_args,
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndReturn(engine_resp)
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
@ -609,7 +611,8 @@ class CfnStackControllerTest(common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': engine_args,
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndReturn(engine_resp)
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
@ -657,7 +660,8 @@ class CfnStackControllerTest(common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': engine_args,
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndReturn(engine_resp)
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
@ -705,7 +709,8 @@ class CfnStackControllerTest(common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': engine_args,
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndReturn(engine_resp)
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
@ -791,7 +796,8 @@ class CfnStackControllerTest(common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': engine_args,
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndRaise(AttributeError())
|
||||
|
||||
policy.Enforcer.enforce(dummy_req.context, 'CreateStack'
|
||||
|
@ -805,7 +811,8 @@ class CfnStackControllerTest(common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': engine_args,
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndRaise(heat_exception.UnknownUserParameter(key='test'))
|
||||
|
||||
policy.Enforcer.enforce(dummy_req.context, 'CreateStack'
|
||||
|
@ -819,7 +826,8 @@ class CfnStackControllerTest(common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': engine_args,
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndRaise(heat_exception.UserParameterMissing(key='test'))
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
@ -860,7 +868,8 @@ class CfnStackControllerTest(common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': engine_args,
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndRaise(heat_exception.StackExists(stack_name='test'))
|
||||
|
||||
self.m.ReplayAll()
|
||||
|
@ -895,7 +904,8 @@ class CfnStackControllerTest(common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': engine_args,
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndRaise(heat_exception.StackValidationFailed(
|
||||
message='Something went wrong'))
|
||||
|
||||
|
|
|
@ -714,7 +714,8 @@ class StackControllerTest(ControllerTest, common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': {'timeout_mins': 30},
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndReturn(dict(identity))
|
||||
self.m.ReplayAll()
|
||||
|
||||
|
@ -772,7 +773,8 @@ class StackControllerTest(ControllerTest, common.HeatTestCase):
|
|||
'args': {'timeout_mins': 30,
|
||||
'adopt_stack_data': str(adopt_data)},
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndReturn(dict(identity))
|
||||
self.m.ReplayAll()
|
||||
|
||||
|
@ -833,7 +835,8 @@ class StackControllerTest(ControllerTest, common.HeatTestCase):
|
|||
'files': {'my.yaml': 'This is the file contents.'},
|
||||
'args': {'timeout_mins': 30},
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndReturn(dict(identity))
|
||||
self.m.ReplayAll()
|
||||
|
||||
|
@ -872,7 +875,8 @@ class StackControllerTest(ControllerTest, common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': {'timeout_mins': 30},
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndRaise(to_remote_error(AttributeError()))
|
||||
rpc_client.EngineClient.call(
|
||||
req.context,
|
||||
|
@ -884,7 +888,8 @@ class StackControllerTest(ControllerTest, common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': {'timeout_mins': 30},
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndRaise(to_remote_error(unknown_parameter))
|
||||
rpc_client.EngineClient.call(
|
||||
req.context,
|
||||
|
@ -896,7 +901,8 @@ class StackControllerTest(ControllerTest, common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': {'timeout_mins': 30},
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndRaise(to_remote_error(missing_parameter))
|
||||
self.m.ReplayAll()
|
||||
resp = request_with_middleware(fault.FaultWrapper,
|
||||
|
@ -945,7 +951,8 @@ class StackControllerTest(ControllerTest, common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': {'timeout_mins': 30},
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndRaise(to_remote_error(error))
|
||||
self.m.ReplayAll()
|
||||
|
||||
|
@ -1000,7 +1007,8 @@ class StackControllerTest(ControllerTest, common.HeatTestCase):
|
|||
'files': {},
|
||||
'args': {'timeout_mins': 30},
|
||||
'owner_id': None,
|
||||
'nested_depth': 0})
|
||||
'nested_depth': 0,
|
||||
'user_creds_id': None})
|
||||
).AndRaise(to_remote_error(error))
|
||||
self.m.ReplayAll()
|
||||
|
||||
|
|
|
@ -119,6 +119,7 @@ class EngineRpcAPITestCase(testtools.TestCase):
|
|||
call_kwargs = copy.deepcopy(kwargs)
|
||||
call_kwargs['owner_id'] = None
|
||||
call_kwargs['nested_depth'] = 0
|
||||
call_kwargs['user_creds_id'] = None
|
||||
expected_message = self.rpcapi.make_msg('create_stack', **call_kwargs)
|
||||
kwargs['expected_message'] = expected_message
|
||||
self._test_engine_api('create_stack', 'call', **kwargs)
|
||||
|
|
Loading…
Reference in New Issue