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/layman.py

"""
Management of Gentoo Overlays using layman
==========================================

A state module to manage Gentoo package overlays via layman

.. code-block:: yaml

    sunrise:
        layman.present
"""


def __virtual__():
    """
    Only load if the layman module is available in __salt__
    """
    if "layman.add" in __salt__:
        return "layman"
    return (False, "layman module could not be loaded")


def present(name):
    """
    Verify that the overlay is present

    name
        The name of the overlay to add
    """
    ret = {"changes": {}, "comment": "", "name": name, "result": True}

    # Overlay already present
    if name in __salt__["layman.list_local"]():
        ret["comment"] = f"Overlay {name} already present"
    elif __opts__["test"]:
        ret["comment"] = f"Overlay {name} is set to be added"
        ret["result"] = None
        return ret
    else:
        # Does the overlay exist?
        if name not in __salt__["layman.list_all"]():
            ret["comment"] = f"Overlay {name} not found"
            ret["result"] = False
        else:
            # Attempt to add the overlay
            changes = __salt__["layman.add"](name)

            # The overlay failed to add
            if len(changes) < 1:
                ret["comment"] = f"Overlay {name} failed to add"
                ret["result"] = False
            # Success
            else:
                ret["changes"]["added"] = changes
                ret["comment"] = f"Overlay {name} added."

    return ret


def absent(name):
    """
    Verify that the overlay is absent

    name
        The name of the overlay to delete
    """
    ret = {"changes": {}, "comment": "", "name": name, "result": True}

    # Overlay is already absent
    if name not in __salt__["layman.list_local"]():
        ret["comment"] = f"Overlay {name} already absent"
    elif __opts__["test"]:
        ret["comment"] = f"Overlay {name} is set to be deleted"
        ret["result"] = None
        return ret
    else:
        # Attempt to delete the overlay
        changes = __salt__["layman.delete"](name)

        # The overlay failed to delete
        if len(changes) < 1:
            ret["comment"] = f"Overlay {name} failed to delete"
            ret["result"] = False
        # Success
        else:
            ret["changes"]["deleted"] = changes
            ret["comment"] = f"Overlay {name} deleted."

    return ret