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/modules/
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/modules/netaddress.py

"""
Module for getting information about network addresses.

.. versionadded:: 2016.3.0

:depends: netaddr
"""

__virtualname__ = "netaddress"

try:
    import netaddr

    HAS_NETADDR = True
except ImportError as e:
    HAS_NETADDR = False


def __virtual__():
    """
    Only load if netaddr library exist.
    """
    if not HAS_NETADDR:
        return (
            False,
            "The netaddress execution module cannot be loaded: "
            "netaddr python library is not installed.",
        )
    return __virtualname__


def list_cidr_ips(cidr):
    """
    Get a list of IP addresses from a CIDR.

    CLI Example:

    .. code-block:: bash

        salt myminion netaddress.list_cidr_ips 192.168.0.0/20
    """
    ips = netaddr.IPNetwork(cidr)
    return [str(ip) for ip in list(ips)]


def list_cidr_ips_ipv6(cidr):
    """
    Get a list of IPv6 addresses from a CIDR.

    CLI Example:

    .. code-block:: bash

        salt myminion netaddress.list_cidr_ips_ipv6 192.168.0.0/20
    """
    ips = netaddr.IPNetwork(cidr)
    return [str(ip.ipv6()) for ip in list(ips)]


def cidr_netmask(cidr):
    """
    Get the netmask address associated with a CIDR address.

    CLI Example:

    .. code-block:: bash

        salt myminion netaddress.cidr_netmask 192.168.0.0/20
    """
    ips = netaddr.IPNetwork(cidr)
    return str(ips.netmask)


def cidr_broadcast(cidr):
    """
    Get the broadcast address associated with a CIDR address.

    CLI Example:

    .. code-block:: bash

        salt myminion netaddress.cidr_netmask 192.168.0.0/20
    """
    ips = netaddr.IPNetwork(cidr)
    return str(ips.broadcast)