MCPcopy Create free account
hub / github.com/StackStorm/st2 / _create_graph

Function _create_graph

st2common/st2common/util/param.py:90–117  ·  view source on GitHub ↗

Creates a generic directed graph for depencency tree and fills it with basic context variables

(action_context, config)

Source from the content-addressed store, hash-verified

88
89
90def _create_graph(action_context, config):
91 """
92 Creates a generic directed graph for depencency tree and fills it with basic context variables
93 """
94 G = nx.DiGraph()
95 system_keyvalue_context = {
96 SYSTEM_SCOPE: KeyValueLookup(scope=FULL_SYSTEM_SCOPE, context=action_context)
97 }
98
99 # If both 'user' and 'api_user' are specified, this prioritize 'api_user'
100 user = action_context["user"] if "user" in action_context else None
101 user = action_context["api_user"] if "api_user" in action_context else user
102
103 if not user:
104 # When no user is not specified, this selects system-user's scope by default.
105 user = cfg.CONF.system_user.user
106 LOG.info(
107 "Unable to retrieve user / api_user value from action_context. Falling back "
108 "to and using system_user (%s)." % (user)
109 )
110
111 system_keyvalue_context[USER_SCOPE] = UserKeyValueLookup(
112 scope=FULL_USER_SCOPE, user=user, context=action_context
113 )
114 G.add_node(DATASTORE_PARENT_SCOPE, value=system_keyvalue_context)
115 G.add_node(ACTION_CONTEXT_KV_PREFIX, value=action_context)
116 G.add_node(PACK_CONFIG_CONTEXT_KV_PREFIX, value=config)
117 return G
118
119
120def _process(G, name, value):

Callers 2

render_live_paramsFunction · 0.85
render_final_paramsFunction · 0.85

Calls 2

KeyValueLookupClass · 0.90
UserKeyValueLookupClass · 0.90

Tested by

no test coverage detected