Execute the runner function and return the return data and output in a dict
(self, fun, *arg, **kwargs)
| 166 | return ret |
| 167 | |
| 168 | def run_run_plus(self, fun, *arg, **kwargs): |
| 169 | """ |
| 170 | Execute the runner function and return the return data and output in a dict |
| 171 | """ |
| 172 | output = kwargs.pop("_output", None) |
| 173 | opts_overrides = kwargs.pop("opts_overrides", None) |
| 174 | ret = {"fun": fun} |
| 175 | |
| 176 | # Late import |
| 177 | import salt.config |
| 178 | import salt.output |
| 179 | import salt.runner |
| 180 | |
| 181 | opts = salt.config.client_config(self.get_config_file_path("master")) |
| 182 | if opts_overrides: |
| 183 | opts.update(opts_overrides) |
| 184 | |
| 185 | opts_arg = list(arg) |
| 186 | if kwargs: |
| 187 | opts_arg.append({"__kwarg__": True}) |
| 188 | opts_arg[-1].update(kwargs) |
| 189 | |
| 190 | opts.update({"doc": False, "fun": fun, "arg": opts_arg}) |
| 191 | with RedirectStdStreams(): |
| 192 | runner = salt.runner.Runner(opts) |
| 193 | ret["return"] = runner.run() |
| 194 | try: |
| 195 | ret["jid"] = runner.jid |
| 196 | except AttributeError: |
| 197 | ret["jid"] = None |
| 198 | |
| 199 | # Compile output |
| 200 | # TODO: Support outputters other than nested |
| 201 | opts["color"] = False |
| 202 | opts["output_file"] = io.StringIO() |
| 203 | try: |
| 204 | salt.output.display_output(ret["return"], opts=opts, out=output) |
| 205 | out = opts["output_file"].getvalue() |
| 206 | if output is None: |
| 207 | out = out.splitlines() |
| 208 | elif output == "json": |
| 209 | out = json.loads(out) |
| 210 | ret["out"] = out |
| 211 | finally: |
| 212 | opts["output_file"].close() |
| 213 | log.debug( |
| 214 | "Result of run_run_plus for fun '%s' with arg '%s': %s", fun, opts_arg, ret |
| 215 | ) |
| 216 | return ret |
| 217 | |
| 218 | def run_key(self, arg_str, catch_stderr=False, with_retcode=False, config_dir=None): |
| 219 | """ |