Send a master control function back to the runner system
(self, load)
| 1216 | self.mminion = salt.minion.MasterMinion(self.opts, states=False, rend=False) |
| 1217 | |
| 1218 | def runner(self, load): |
| 1219 | """ |
| 1220 | Send a master control function back to the runner system |
| 1221 | """ |
| 1222 | # All runner opts pass through eauth |
| 1223 | auth_type, err_name, key = self._prep_auth_info(load) |
| 1224 | |
| 1225 | # Authenticate |
| 1226 | auth_check = self.loadauth.check_authentication(load, auth_type) |
| 1227 | error = auth_check.get("error") |
| 1228 | |
| 1229 | if error: |
| 1230 | # Authentication error occurred: do not continue. |
| 1231 | return {"error": error} |
| 1232 | |
| 1233 | # Authorize |
| 1234 | runner_check = self.ckminions.runner_check( |
| 1235 | auth_check.get("auth_list", []), load["fun"], load["kwarg"] |
| 1236 | ) |
| 1237 | username = auth_check.get("username") |
| 1238 | if not runner_check: |
| 1239 | return { |
| 1240 | "error": { |
| 1241 | "name": err_name, |
| 1242 | "message": ( |
| 1243 | 'Authentication failure of type "{}" occurred ' |
| 1244 | "for user {}.".format(auth_type, username) |
| 1245 | ), |
| 1246 | } |
| 1247 | } |
| 1248 | elif isinstance(runner_check, dict) and "error" in runner_check: |
| 1249 | # A dictionary with an error name/message was handled by ckminions.runner_check |
| 1250 | return runner_check |
| 1251 | |
| 1252 | # Authorized. Do the job! |
| 1253 | try: |
| 1254 | fun = load.pop("fun") |
| 1255 | with salt.runner.RunnerClient(self.opts) as runner_client: |
| 1256 | return runner_client.asynchronous(fun, load.get("kwarg", {}), username) |
| 1257 | except Exception as exc: # pylint: disable=broad-except |
| 1258 | log.exception("Exception occurred while introspecting %s", fun) |
| 1259 | return { |
| 1260 | "error": { |
| 1261 | "name": exc.__class__.__name__, |
| 1262 | "args": exc.args, |
| 1263 | "message": str(exc), |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | def wheel(self, load): |
| 1268 | """ |
nothing calls this directly
no test coverage detected