MCPcopy Create free account
hub / github.com/saltstack/salt / run

Method run

salt/netapi/__init__.py:173–211  ·  view source on GitHub ↗

Execute the specified function in the specified client by passing the lowstate

(self, low)

Source from the content-addressed store, hash-verified

171 )
172
173 def run(self, low):
174 """
175 Execute the specified function in the specified client by passing the
176 lowstate
177 """
178 # Eauth currently requires a running daemon and commands run through
179 # this method require eauth so perform a quick check to raise a
180 # more meaningful error.
181 if not self._is_master_running():
182 raise salt.exceptions.SaltDaemonNotRunning("Salt Master is not available.")
183
184 if low.get("client") not in CLIENTS:
185 raise salt.exceptions.SaltInvocationError(
186 "Invalid client specified: '{}'".format(low.get("client"))
187 )
188
189 if low.get("client") not in self.opts.get("netapi_enable_clients"):
190 raise salt.exceptions.SaltInvocationError(
191 "Client disabled: '{}'. Add to 'netapi_enable_clients' master config option to enable.".format(
192 low.get("client")
193 )
194 )
195
196 if not ("token" in low or "eauth" in low):
197 raise salt.exceptions.EauthAuthenticationError(
198 "No authentication credentials given"
199 )
200
201 if low.get("raw_shell") and not self.opts.get("netapi_allow_raw_shell"):
202 raise salt.exceptions.EauthAuthenticationError(
203 "Raw shell option not allowed."
204 )
205
206 if low["client"] == "ssh":
207 self._authorize_ssh(low)
208
209 l_fun = getattr(self, low["client"])
210 f_call = salt.utils.args.format_call(l_fun, low)
211 return l_fun(*f_call.get("args", ()), **f_call.get("kwargs", {}))
212
213 def local_async(self, *args, **kwargs):
214 """

Callers 5

on_messageMethod · 0.95
run_chunkFunction · 0.45
_exec_lowstate_chunksMethod · 0.45

Calls 4

_is_master_runningMethod · 0.95
_authorize_sshMethod · 0.95
formatMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected