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

Method run

salt/runner.py:251–383  ·  view source on GitHub ↗

Execute the runner sequence

(self, full_return=False)

Source from the content-addressed store, hash-verified

249
250 # TODO: move to mixin whenever we want a salt-wheel cli
251 def run(self, full_return=False):
252 """
253 Execute the runner sequence
254 """
255 import salt.minion
256
257 ret = {}
258 if self.opts.get("doc", False):
259 self.print_docs()
260 else:
261 low = {"fun": self.opts["fun"]}
262 try:
263 # Allocate a jid
264 async_pub = self._gen_async_pub(jid=self.opts.get("jid"))
265 self.jid = async_pub["jid"]
266
267 fun_args = salt.utils.args.parse_input(
268 self.opts["arg"], no_parse=self.opts.get("no_parse", [])
269 )
270
271 verify_fun(self.functions, low["fun"])
272 args, kwargs = salt.minion.load_args_and_kwargs(
273 self.functions[low["fun"]], fun_args
274 )
275 low["arg"] = args
276 low["kwarg"] = kwargs
277
278 if self.opts.get("eauth"):
279 if "token" in self.opts:
280 try:
281 with salt.utils.files.fopen(
282 os.path.join(self.opts["cachedir"], ".root_key"), "r"
283 ) as fp_:
284 low["key"] = salt.utils.stringutils.to_unicode(
285 fp_.readline()
286 )
287 except OSError:
288 low["token"] = self.opts["token"]
289
290 # If using eauth and a token hasn't already been loaded into
291 # low, prompt the user to enter auth credentials
292 if "token" not in low and "key" not in low and self.opts["eauth"]:
293 # This is expensive. Don't do it unless we need to.
294 import salt.auth
295
296 resolver = salt.auth.Resolver(self.opts)
297 res = resolver.cli(self.opts["eauth"])
298 if self.opts["mktoken"] and res:
299 tok = resolver.token_cli(self.opts["eauth"], res)
300 if tok:
301 low["token"] = tok.get("token", "")
302 if not res:
303 log.error("Authentication failed")
304 return ret
305 low.update(res)
306 low["eauth"] = self.opts["eauth"]
307 else:
308 user = salt.utils.user.get_specific_user()

Callers 4

cmdFunction · 0.95
runMethod · 0.95
minion_runnerMethod · 0.95
run_run_plusMethod · 0.95

Calls 15

print_docsMethod · 0.95
cliMethod · 0.95
token_cliMethod · 0.95
verify_funFunction · 0.90
display_outputFunction · 0.90
_gen_async_pubMethod · 0.80
asynchronousMethod · 0.80
warningMethod · 0.80
_proc_functionMethod · 0.80
get_docsMethod · 0.80
formatMethod · 0.80
debugMethod · 0.80

Tested by

no test coverage detected