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/grains/
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/grains/junos.py

"""
Grains for junos.
NOTE this is a little complicated--junos can only be accessed
via salt-proxy-minion. Thus, some grains make sense to get them
from the minion (PYTHONPATH), but others don't (ip_interfaces)
"""

import logging

import salt.utils.platform

__proxyenabled__ = ["junos"]
__virtualname__ = "junos"

# Get looging started
log = logging.getLogger(__name__)


def __virtual__():
    if "proxy" not in __opts__:
        return False
    else:
        return __virtualname__


def _remove_complex_types(dictionary):
    """
    junos-eznc is now returning some complex types that
    are not serializable by msgpack.  Kill those.
    """
    for k, v in dictionary.items():
        if isinstance(v, dict):
            dictionary[k] = _remove_complex_types(v)
        elif hasattr(v, "to_eng_string"):
            dictionary[k] = v.to_eng_string()

    return dictionary


def defaults():
    if salt.utils.platform.is_proxy():
        return {"os": "proxy", "kernel": "unknown", "osrelease": "proxy"}
    else:
        return {
            "os": "junos",
            "kernel": "junos",
            "osrelease": "junos FIXME",
        }


def facts(proxy=None):
    if proxy is None or proxy["junos.initialized"]() is False:
        return {}

    ret_value = proxy["junos.get_serialized_facts"]()
    if salt.utils.platform.is_proxy():
        ret = {"junos_facts": ret_value}
    else:
        ret = {"junos_facts": ret_value, "osrelease": ret_value["version"]}

    return ret


def os_family():
    return {"os_family": "junos"}