MCPcopy
hub / github.com/saltstack/salt / run_run_plus

Method run_run_plus

tests/support/case.py:168–216  ·  view source on GitHub ↗

Execute the runner function and return the return data and output in a dict

(self, fun, *arg, **kwargs)

Source from the content-addressed store, hash-verified

166 return ret
167
168 def run_run_plus(self, fun, *arg, **kwargs):
169 """
170 Execute the runner function and return the return data and output in a dict
171 """
172 output = kwargs.pop("_output", None)
173 opts_overrides = kwargs.pop("opts_overrides", None)
174 ret = {"fun": fun}
175
176 # Late import
177 import salt.config
178 import salt.output
179 import salt.runner
180
181 opts = salt.config.client_config(self.get_config_file_path("master"))
182 if opts_overrides:
183 opts.update(opts_overrides)
184
185 opts_arg = list(arg)
186 if kwargs:
187 opts_arg.append({"__kwarg__": True})
188 opts_arg[-1].update(kwargs)
189
190 opts.update({"doc": False, "fun": fun, "arg": opts_arg})
191 with RedirectStdStreams():
192 runner = salt.runner.Runner(opts)
193 ret["return"] = runner.run()
194 try:
195 ret["jid"] = runner.jid
196 except AttributeError:
197 ret["jid"] = None
198
199 # Compile output
200 # TODO: Support outputters other than nested
201 opts["color"] = False
202 opts["output_file"] = io.StringIO()
203 try:
204 salt.output.display_output(ret["return"], opts=opts, out=output)
205 out = opts["output_file"].getvalue()
206 if output is None:
207 out = out.splitlines()
208 elif output == "json":
209 out = json.loads(out)
210 ret["out"] = out
211 finally:
212 opts["output_file"].close()
213 log.debug(
214 "Result of run_run_plus for fun '%s' with arg '%s': %s", fun, opts_arg, ret
215 )
216 return ret
217
218 def run_key(self, arg_str, catch_stderr=False, with_retcode=False, config_dir=None):
219 """

Callers 15

test_salt_cmdMethod · 0.80
test_salt_cmd_invalidMethod · 0.80
test_upMethod · 0.80
test_downMethod · 0.80
tearDownMethod · 0.80
test_dir_listMethod · 0.80
test_empty_dir_listMethod · 0.80
test_envsMethod · 0.80
gen_cacheMethod · 0.80

Calls 10

runMethod · 0.95
RedirectStdStreamsClass · 0.90
debugMethod · 0.80
listFunction · 0.50
popMethod · 0.45
get_config_file_pathMethod · 0.45
updateMethod · 0.45
appendMethod · 0.45
loadsMethod · 0.45
closeMethod · 0.45

Tested by 15

test_salt_cmdMethod · 0.64
test_salt_cmd_invalidMethod · 0.64
test_upMethod · 0.64
test_downMethod · 0.64
tearDownMethod · 0.64
test_dir_listMethod · 0.64
test_empty_dir_listMethod · 0.64
test_envsMethod · 0.64
gen_cacheMethod · 0.64