PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
Dir : /proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/ |
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 IP: 209.182.202.254 |
Dir : //proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/powerpath.py |
""" powerpath support. Assumes RedHat """ import os import re POLICY_MAP_DICT = { "Adaptive": "ad", "CLAROpt": "co", "LeastBlocks": "lb", "LeastIos": "li", "REquest": "re", "RoundRobin": "rr", "StreamIo": "si", "SymmOpt": "so", } POLICY_RE = re.compile(".*policy=([^;]+)") def has_powerpath(): if os.path.exists("/sbin/emcpreg"): return True return False def __virtual__(): """ Provide this only on Linux systems until proven to work elsewhere. """ try: kernel_grain = __grains__["kernel"] except Exception: # pylint: disable=broad-except return ( False, "The powerpath execution module cannot be loaded: unable to detect kernel" " grain.", ) if not has_powerpath(): return ( False, "The powerpath execution module cannot be loaded: the emcpreg binary is not" " available.", ) if kernel_grain == "Linux": return "powerpath" return ( False, "The powerpath execution module cannot be loaded: only available on Linux.", ) def list_licenses(): """ returns a list of applied powerpath license keys """ KEY_PATTERN = re.compile("Key (.*)") keys = [] out = __salt__["cmd.run"]("/sbin/emcpreg -list") for line in out.splitlines(): match = KEY_PATTERN.match(line) if not match: continue keys.append({"key": match.group(1)}) return keys def add_license(key): """ Add a license """ result = {"result": False, "retcode": -1, "output": ""} if not has_powerpath(): result["output"] = "PowerPath is not installed" return result cmd = f"/sbin/emcpreg -add {key}" ret = __salt__["cmd.run_all"](cmd, python_shell=True) result["retcode"] = ret["retcode"] if ret["retcode"] != 0: result["output"] = ret["stderr"] else: result["output"] = ret["stdout"] result["result"] = True return result def remove_license(key): """ Remove a license """ result = {"result": False, "retcode": -1, "output": ""} if not has_powerpath(): result["output"] = "PowerPath is not installed" return result cmd = f"/sbin/emcpreg -remove {key}" ret = __salt__["cmd.run_all"](cmd, python_shell=True) result["retcode"] = ret["retcode"] if ret["retcode"] != 0: result["output"] = ret["stderr"] else: result["output"] = ret["stdout"] result["result"] = True return result