Take the required arguments and publish the given command. Arguments: tgt: The tgt is a regex or a glob used to match up the ids on the minions. Salt works by always publishing every command to all of the minions and then t
(
self,
tgt,
fun,
arg=(),
tgt_type="glob",
ret="",
jid="",
timeout=None,
io_loop=None,
listen=True,
**kwargs,
)
| 2160 | return {"jid": payload["load"]["jid"], "minions": payload["load"]["minions"]} |
| 2161 | |
| 2162 | async def pub_async( |
| 2163 | self, |
| 2164 | tgt, |
| 2165 | fun, |
| 2166 | arg=(), |
| 2167 | tgt_type="glob", |
| 2168 | ret="", |
| 2169 | jid="", |
| 2170 | timeout=None, |
| 2171 | io_loop=None, |
| 2172 | listen=True, |
| 2173 | **kwargs, |
| 2174 | ): |
| 2175 | """ |
| 2176 | Take the required arguments and publish the given command. |
| 2177 | Arguments: |
| 2178 | tgt: |
| 2179 | The tgt is a regex or a glob used to match up the ids on |
| 2180 | the minions. Salt works by always publishing every command |
| 2181 | to all of the minions and then the minions determine if |
| 2182 | the command is for them based on the tgt value. |
| 2183 | fun: |
| 2184 | The function name to be called on the remote host(s), this |
| 2185 | must be a string in the format "<modulename>.<function name>" |
| 2186 | arg: |
| 2187 | The arg option needs to be a tuple of arguments to pass |
| 2188 | to the calling function, if left blank |
| 2189 | Returns: |
| 2190 | jid: |
| 2191 | A string, as returned by the publisher, which is the job |
| 2192 | id, this will inform the client where to get the job results |
| 2193 | minions: |
| 2194 | A set, the targets that the tgt passed should match. |
| 2195 | """ |
| 2196 | if timeout is None: |
| 2197 | timeout = self.opts.get("publish_timeout", 30) |
| 2198 | |
| 2199 | # Make sure the publisher is running by checking the unix socket |
| 2200 | if self.opts.get("ipc_mode", "") != "tcp" and not os.path.exists( |
| 2201 | os.path.join(self.opts["sock_dir"], "publish_pull.ipc") |
| 2202 | ): |
| 2203 | log.error( |
| 2204 | "Unable to connect to the salt master publisher at %s", |
| 2205 | self.opts["sock_dir"], |
| 2206 | ) |
| 2207 | raise SaltClientError |
| 2208 | |
| 2209 | payload_kwargs = self._prep_pub( |
| 2210 | tgt, fun, arg, tgt_type, ret, jid, timeout, **kwargs |
| 2211 | ) |
| 2212 | |
| 2213 | master_uri = ( |
| 2214 | "tcp://" |
| 2215 | + salt.utils.network.ip_bracket(self.opts["interface"]) |
| 2216 | + ":" |
| 2217 | + str(self.opts["ret_port"]) |
| 2218 | ) |
| 2219 |