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

Method runner

salt/master.py:3766–3829  ·  view source on GitHub ↗

Send a master control function back to the runner system

(self, clear_load)

Source from the content-addressed store, hash-verified

3764 self.channels = []
3765
3766 def runner(self, clear_load):
3767 """
3768 Send a master control function back to the runner system
3769 """
3770 # All runner ops pass through eauth
3771 auth_type, err_name, key, sensitive_load_keys = self._prep_auth_info(clear_load)
3772
3773 # Authenticate
3774 auth_check = self.loadauth.check_authentication(clear_load, auth_type, key=key)
3775 error = auth_check.get("error")
3776
3777 if error:
3778 # Authentication error occurred: do not continue.
3779 return {"error": error}
3780
3781 # Authorize
3782 username = auth_check.get("username")
3783 if auth_type != "user":
3784 runner_check = self.ckminions.runner_check(
3785 auth_check.get("auth_list", []),
3786 clear_load["fun"],
3787 clear_load.get("kwarg", {}),
3788 )
3789 if not runner_check:
3790 return {
3791 "error": {
3792 "name": err_name,
3793 "message": (
3794 'Authentication failure of type "{}" occurred for '
3795 "user {}.".format(auth_type, username)
3796 ),
3797 }
3798 }
3799 elif isinstance(runner_check, dict) and "error" in runner_check:
3800 # A dictionary with an error name/message was handled by ckminions.runner_check
3801 return runner_check
3802
3803 # No error occurred, consume sensitive settings from the clear_load if passed.
3804 for item in sensitive_load_keys:
3805 clear_load.pop(item, None)
3806 else:
3807 if "user" in clear_load:
3808 username = clear_load["user"]
3809 if salt.auth.AuthUser(username).is_sudo():
3810 username = self.opts.get("user", "root")
3811 else:
3812 username = salt.utils.user.get_user()
3813
3814 # Authorized. Do the job!
3815 try:
3816 fun = clear_load.pop("fun")
3817 runner_client = salt.runner.RunnerClient(self.opts)
3818 return runner_client.asynchronous(
3819 fun, clear_load.get("kwarg", {}), username, local=True
3820 )
3821 except Exception as exc: # pylint: disable=broad-except
3822 log.error("Exception occurred while introspecting %s: %s", fun, exc)
3823 return {

Calls 9

_prep_auth_infoMethod · 0.95
check_authenticationMethod · 0.80
runner_checkMethod · 0.80
formatMethod · 0.80
is_sudoMethod · 0.80
asynchronousMethod · 0.80
getMethod · 0.45
popMethod · 0.45
errorMethod · 0.45