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/utils/
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/utils/idem.py

"""
Idem Support
============

This util provides access to an idem-ready hub

.. versionadded:: 3002
"""

import logging

try:
    import pop.hub

    HAS_POP = True, None
except ImportError as e:
    HAS_POP = False, str(e)

log = logging.getLogger(__name__)

__virtualname__ = "idem"


def __virtual__():
    if not HAS_POP[0]:
        return HAS_POP
    return __virtualname__


def hub():
    """
    Create a hub with idem ready to go and completely loaded
    """
    if "idem.hub" not in __context__:
        log.debug("Creating the POP hub")
        hub = pop.hub.Hub()

        log.debug("Initializing the loop")
        hub.pop.loop.create()

        log.debug("Loading subs onto hub")
        hub.pop.sub.add(dyne_name="config")
        # We aren't collecting grains at all but some exec modules depend on the sub being on the hub
        hub.pop.sub.add(dyne_name="grains")
        hub.pop.sub.add(dyne_name="idem")

        log.debug("Reading idem config options")
        hub.config.integrate.load(["acct", "idem"], "idem", parse_cli=False, logs=False)

        __context__["idem.hub"] = hub

    return __context__["idem.hub"]