HEX
Server: Apache
System: Linux server.enlacediseno.com 4.18.0-553.62.1.el8_10.x86_64 #1 SMP Wed Jul 16 04:08:25 EDT 2025 x86_64
User: maor (1069)
PHP: 7.3.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //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"]