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

Function _ssh_state

salt/client/ssh/wrapper/state.py:45–85  ·  view source on GitHub ↗

Function to run a state with the given chunk via salt-ssh

(chunks, st_kwargs, kwargs, pillar, test=False)

Source from the content-addressed store, hash-verified

43
44
45def _ssh_state(chunks, st_kwargs, kwargs, pillar, test=False):
46 """
47 Function to run a state with the given chunk via salt-ssh
48 """
49 file_refs = salt.client.ssh.state.lowstate_file_refs(
50 chunks,
51 _merge_extra_filerefs(
52 kwargs.get("extra_filerefs", ""),
53 __opts__.get("extra_filerefs", ""),
54 __context__.get("_cp_extra_filerefs", ""),
55 ),
56 )
57 # Create the tar containing the state pkg and relevant files.
58 trans_tar = salt.client.ssh.state.prep_trans_tar(
59 __context__["fileclient"],
60 chunks,
61 file_refs,
62 pillar,
63 st_kwargs["id_"],
64 )
65 trans_tar_sum = salt.utils.hashutils.get_hash(trans_tar, __opts__["hash_type"])
66 cmd = "state.pkg {}/salt_state.tgz test={} pkg_sum={} hash_type={}".format(
67 __opts__["thin_dir"], test, trans_tar_sum, __opts__["hash_type"]
68 )
69 single = salt.client.ssh.Single(
70 __opts__,
71 cmd,
72 fsclient=__context__["fileclient"],
73 minion_opts=__salt__.minion_opts,
74 **st_kwargs,
75 )
76 single.shell.send(trans_tar, "{}/salt_state.tgz".format(__opts__["thin_dir"]))
77 stdout, stderr, retcode = single.cmd_block()
78
79 # Clean up our tar
80 try:
81 os.remove(trans_tar)
82 except OSError:
83 pass
84
85 return {"local": salt.client.ssh.wrapper.parse_ret(stdout, stderr, retcode)}
86
87
88def _check_pillar(kwargs, pillar=None):

Callers 1

sls_idFunction · 0.85

Calls 6

cmd_blockMethod · 0.95
_merge_extra_filerefsFunction · 0.85
formatMethod · 0.80
getMethod · 0.45
sendMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected