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/states/
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
Choose File :

Url:
Dir : //proc/self/root/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/powerpath.py

"""
Powerpath configuration support
===============================

Allows configuration of EMC Powerpath.  Currently
only addition/deletion of licenses is supported.

.. code-block:: yaml

    key:
      powerpath.license_present: []
"""


def license_present(name):
    """
    Ensures that the specified PowerPath license key is present
    on the host.

    name
        The license key to ensure is present
    """
    ret = {"name": name, "changes": {}, "result": False, "comment": ""}

    if not __salt__["powerpath.has_powerpath"]():
        ret["result"] = False
        ret["comment"] = "PowerPath is not installed."
        return ret

    licenses = [l["key"] for l in __salt__["powerpath.list_licenses"]()]

    if name in licenses:
        ret["result"] = True
        ret["comment"] = f"License key {name} already present"
        return ret

    if __opts__["test"]:
        ret["result"] = None
        ret["comment"] = f"License key {name} is set to be added"
        return ret

    data = __salt__["powerpath.add_license"](name)
    if data["result"]:
        ret["changes"] = {name: "added"}
        ret["result"] = True
        ret["comment"] = data["output"]
        return ret
    else:
        ret["result"] = False
        ret["comment"] = data["output"]
        return ret


def license_absent(name):
    """
    Ensures that the specified PowerPath license key is absent
    on the host.

    name
        The license key to ensure is absent
    """
    ret = {"name": name, "changes": {}, "result": False, "comment": ""}

    if not __salt__["powerpath.has_powerpath"]():
        ret["result"] = False
        ret["comment"] = "PowerPath is not installed."
        return ret

    licenses = [l["key"] for l in __salt__["powerpath.list_licenses"]()]

    if name not in licenses:
        ret["result"] = True
        ret["comment"] = f"License key {name} not present"
        return ret

    if __opts__["test"]:
        ret["result"] = None
        ret["comment"] = f"License key {name} is set to be removed"
        return ret

    data = __salt__["powerpath.remove_license"](name)
    if data["result"]:
        ret["changes"] = {name: "removed"}
        ret["result"] = True
        ret["comment"] = data["output"]
        return ret
    else:
        ret["result"] = False
        ret["comment"] = data["output"]
        return ret