MCPcopy Index your code
hub / github.com/saltstack/salt / run

Method run

salt/cli/run.py:13–57  ·  view source on GitHub ↗

Execute salt-run

(self)

Source from the content-addressed store, hash-verified

11 """
12
13 def run(self):
14 """
15 Execute salt-run
16 """
17 import salt.runner
18
19 self.parse_args()
20
21 profiling_enabled = self.options.profiling_enabled
22
23 runner = salt.runner.Runner(self.config)
24 if self.options.doc:
25 runner.print_docs()
26 self.exit(salt.defaults.exitcodes.EX_OK)
27
28 # Run this here so SystemExit isn't raised anywhere else when
29 # someone tries to use the runners via the python API
30 try:
31 if check_user(self.config["user"]):
32 pr = salt.utils.profile.activate_profile(profiling_enabled)
33 try:
34 ret = runner.run(full_return=True)
35 # In older versions ret['data']['retcode'] was used
36 # for signaling the return code. This has been
37 # changed for the orchestrate runner, but external
38 # runners might still use it. For this reason, we
39 # also check ret['data']['retcode'] if
40 # ret['retcode'] is not available.
41 if (
42 isinstance(ret, dict)
43 and "return" in ret
44 and "retcode" not in ret
45 ):
46 ret = ret["return"]
47 if isinstance(ret, dict) and "retcode" in ret:
48 self.exit(ret["retcode"])
49 elif isinstance(ret, dict) and "retcode" in ret.get("data", {}):
50 self.exit(ret["data"]["retcode"])
51 finally:
52 salt.utils.profile.output_profile(
53 pr, stats_path=self.options.profiling_path, stop=True
54 )
55
56 except SaltClientError as exc:
57 raise SystemExit(str(exc))

Callers 1

salt_runFunction · 0.95

Calls 6

print_docsMethod · 0.95
runMethod · 0.95
check_userFunction · 0.90
exitMethod · 0.80
parse_argsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected