Simplifying a few data_flow methods
Change-Id: I604620f2dc4d6f45dfaa1ea1d13adcd7aaef0f15
This commit is contained in:
parent
92787df902
commit
58d1beaa02
@ -436,10 +436,10 @@ class DefaultEngine(base.Engine):
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
data_flow.add_openstack_data_to_context(wf_ex.context)
|
data_flow.add_openstack_data_to_context(wf_ex)
|
||||||
data_flow.add_execution_to_context(wf_ex, wf_ex.context)
|
data_flow.add_execution_to_context(wf_ex)
|
||||||
data_flow.add_environment_to_context(wf_ex, wf_ex.context)
|
data_flow.add_environment_to_context(wf_ex)
|
||||||
data_flow.add_workflow_variables_to_context(wf_spec, wf_ex.context)
|
data_flow.add_workflow_variables_to_context(wf_ex, wf_spec)
|
||||||
|
|
||||||
return wf_ex
|
return wf_ex
|
||||||
|
|
||||||
|
@ -225,9 +225,8 @@ def evaluate_workflow_output(wf_spec, context):
|
|||||||
return ProxyAwareDict(output or context).to_builtin_dict()
|
return ProxyAwareDict(output or context).to_builtin_dict()
|
||||||
|
|
||||||
|
|
||||||
def add_openstack_data_to_context(context):
|
def add_openstack_data_to_context(wf_ex):
|
||||||
if context is None:
|
wf_ex.context = wf_ex.context or {}
|
||||||
context = {}
|
|
||||||
|
|
||||||
if CONF.pecan.auth_enable:
|
if CONF.pecan.auth_enable:
|
||||||
exec_ctx = auth_ctx.ctx()
|
exec_ctx = auth_ctx.ctx()
|
||||||
@ -235,45 +234,36 @@ def add_openstack_data_to_context(context):
|
|||||||
LOG.debug('Data flow security context: %s' % exec_ctx)
|
LOG.debug('Data flow security context: %s' % exec_ctx)
|
||||||
|
|
||||||
if exec_ctx:
|
if exec_ctx:
|
||||||
context.update({'openstack': exec_ctx.to_dict()})
|
wf_ex.context.update({'openstack': exec_ctx.to_dict()})
|
||||||
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
|
||||||
def add_execution_to_context(wf_ex, context):
|
def add_execution_to_context(wf_ex):
|
||||||
if context is None:
|
wf_ex.context = wf_ex.context or {}
|
||||||
context = {}
|
|
||||||
|
|
||||||
context['__execution'] = {
|
wf_ex.context['__execution'] = {
|
||||||
'id': wf_ex.id,
|
'id': wf_ex.id,
|
||||||
'spec': wf_ex.spec,
|
'spec': wf_ex.spec,
|
||||||
'params': wf_ex.params,
|
'params': wf_ex.params,
|
||||||
'input': wf_ex.input
|
'input': wf_ex.input
|
||||||
}
|
}
|
||||||
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
def add_environment_to_context(wf_ex):
|
||||||
def add_environment_to_context(wf_ex, context):
|
wf_ex.context = wf_ex.context or {}
|
||||||
if context is None:
|
|
||||||
context = {}
|
|
||||||
|
|
||||||
# If env variables are provided, add an evaluated copy into the context.
|
# If env variables are provided, add an evaluated copy into the context.
|
||||||
if 'env' in wf_ex.params:
|
if 'env' in wf_ex.params:
|
||||||
env = copy.deepcopy(wf_ex.params['env'])
|
env = copy.deepcopy(wf_ex.params['env'])
|
||||||
# An env variable can be an expression of other env variables.
|
# An env variable can be an expression of other env variables.
|
||||||
context['__env'] = expr.evaluate_recursively(env, {'__env': env})
|
wf_ex.context['__env'] = expr.evaluate_recursively(env, {'__env': env})
|
||||||
|
|
||||||
return context
|
|
||||||
|
|
||||||
|
|
||||||
def add_workflow_variables_to_context(wf_spec, context):
|
def add_workflow_variables_to_context(wf_ex, wf_spec):
|
||||||
if context is None:
|
wf_ex.context = wf_ex.context or {}
|
||||||
context = {}
|
|
||||||
|
|
||||||
return utils.merge_dicts(
|
return utils.merge_dicts(
|
||||||
context,
|
wf_ex.context,
|
||||||
expr.evaluate_recursively(wf_spec.get_vars(), context)
|
expr.evaluate_recursively(wf_spec.get_vars(), wf_ex.context)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user