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

Method cmd

salt/client/__init__.py:2480–2508  ·  view source on GitHub ↗

Call an execution module with the given arguments and keyword arguments .. code-block:: python caller.cmd('test.arg', 'Foo', 'Bar', baz='Baz') caller.cmd('event.send', 'myco/myevent/something', data={'foo': 'Foo'}, with_env=['GIT_COMMIT'],

(self, fun, *args, **kwargs)

Source from the content-addressed store, hash-verified

2478 self.sminion = salt.minion.SProxyMinion(self.opts)
2479
2480 def cmd(self, fun, *args, **kwargs):
2481 """
2482 Call an execution module with the given arguments and keyword arguments
2483
2484 .. code-block:: python
2485
2486 caller.cmd('test.arg', 'Foo', 'Bar', baz='Baz')
2487
2488 caller.cmd('event.send', 'myco/myevent/something',
2489 data={'foo': 'Foo'}, with_env=['GIT_COMMIT'], with_grains=True)
2490 """
2491 func = self.sminion.functions[fun]
2492 data = {"arg": args, "fun": fun}
2493 data.update(kwargs)
2494 executors = getattr(self.sminion, "module_executors", []) or self.opts.get(
2495 "module_executors", ["direct_call"]
2496 )
2497 if isinstance(executors, str):
2498 executors = [executors]
2499 for name in executors:
2500 fname = f"{name}.execute"
2501 if fname not in self.sminion.executors:
2502 raise SaltInvocationError(f"Executor '{name}' is not available")
2503 return_data = self.sminion.executors[fname](
2504 self.opts, data, func, args, kwargs
2505 )
2506 if return_data is not None:
2507 break
2508 return return_data

Callers

nothing calls this directly

Calls 3

SaltInvocationErrorClass · 0.90
updateMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected