MCPcopy
hub / github.com/saltstack/salt / run_func

Method run_func

salt/master.py:2992–3031  ·  view source on GitHub ↗

Wrapper for running functions executed with AES encryption :param function func: The function to run :return: The result of the master function that was called

(self, func, load)

Source from the content-addressed store, hash-verified

2990 return self.masterapi.revoke_auth(load)
2991
2992 def run_func(self, func, load):
2993 """
2994 Wrapper for running functions executed with AES encryption
2995
2996 :param function func: The function to run
2997 :return: The result of the master function that was called
2998 """
2999 # Don't honor private functions
3000 if func.startswith("__"):
3001 # TODO: return some error? Seems odd to return {}
3002 return {}, {"fun": "send"}
3003 # Run the func
3004 if hasattr(self, func):
3005 try:
3006 start = time.time()
3007 ret = getattr(self, func)(load)
3008 log.trace(
3009 "Master function call %s took %s seconds", func, time.time() - start
3010 )
3011 except Exception: # pylint: disable=broad-except
3012 ret = ""
3013 log.error("Error in function %s:\n", func, exc_info=True)
3014 else:
3015 log.error(
3016 "Received function %s which is unavailable on the master, "
3017 "returning False",
3018 func,
3019 )
3020 return False, {"fun": "send"}
3021 # Don't encrypt the return value for the _return func
3022 # (we don't care about the return value, so why encrypt it?)
3023 if func == "_return":
3024 return ret, {"fun": "send"}
3025 if func == "_pillar" and "id" in load:
3026 if load.get("ver") != "2" and self.opts["pillar_version"] == 1:
3027 # Authorized to return old pillar proto
3028 return ret, {"fun": "send"}
3029 return ret, {"fun": "send_private", "key": "pillar", "tgt": load["id"]}
3030 # Encrypt the return
3031 return ret, {"fun": "send"}
3032
3033 def destroy(self):
3034 if self.masterapi is not None:

Callers 1

_handle_aesMethod · 0.45

Calls 4

timeMethod · 0.80
traceMethod · 0.80
errorMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected