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

Method wheel

salt/daemons/masterapi.py:1267–1331  ·  view source on GitHub ↗

Send a master control function back to the wheel system

(self, load)

Source from the content-addressed store, hash-verified

1265 }
1266
1267 def wheel(self, load):
1268 """
1269 Send a master control function back to the wheel system
1270 """
1271 # All wheel ops pass through eauth
1272 auth_type, err_name, key = self._prep_auth_info(load)
1273
1274 # Authenticate
1275 auth_check = self.loadauth.check_authentication(
1276 load, auth_type, key=key, show_username=True
1277 )
1278 error = auth_check.get("error")
1279
1280 if error:
1281 # Authentication error occurred: do not continue.
1282 return {"error": error}
1283
1284 # Authorize
1285 username = auth_check.get("username")
1286 if auth_type != "user":
1287 wheel_check = self.ckminions.wheel_check(
1288 auth_check.get("auth_list", []), load["fun"], load["kwarg"]
1289 )
1290 if not wheel_check:
1291 return {
1292 "error": {
1293 "name": err_name,
1294 "message": (
1295 'Authentication failure of type "{}" occurred for '
1296 "user {}.".format(auth_type, username)
1297 ),
1298 }
1299 }
1300 elif isinstance(wheel_check, dict) and "error" in wheel_check:
1301 # A dictionary with an error name/message was handled by ckminions.wheel_check
1302 return wheel_check
1303
1304 # Authenticated. Do the job.
1305 jid = salt.utils.jid.gen_jid(self.opts)
1306 fun = load.pop("fun")
1307 tag = salt.utils.event.tagify(jid, prefix="wheel")
1308 data = {
1309 "fun": f"wheel.{fun}",
1310 "jid": jid,
1311 "tag": tag,
1312 "user": username,
1313 }
1314 try:
1315 self.event.fire_event(data, salt.utils.event.tagify([jid, "new"], "wheel"))
1316 with salt.wheel.WheelClient(self.opts) as wheel_client:
1317 ret = wheel_client.call_func(fun, **load)
1318 data["return"] = ret
1319 data["success"] = True
1320 self.event.fire_event(data, salt.utils.event.tagify([jid, "ret"], "wheel"))
1321 return {"tag": tag, "data": data}
1322 except Exception as exc: # pylint: disable=broad-except
1323 log.exception("Exception occurred while introspecting %s", fun)
1324 data["return"] = "Exception occurred in wheel {}: {}: {}".format(

Callers

nothing calls this directly

Calls 8

_prep_auth_infoMethod · 0.95
check_authenticationMethod · 0.80
wheel_checkMethod · 0.80
formatMethod · 0.80
call_funcMethod · 0.80
getMethod · 0.45
popMethod · 0.45
fire_eventMethod · 0.45

Tested by

no test coverage detected