%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/grains/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/grains/napalm.pyc

�
���^c@@sIdZddlmZmZmZddlZeje�Zddl	Z
ddlZ
dZdgZ
iaiaddgZd�Zdd�Zdd	�Zdd
�Zdd�Zdd�Zdd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Z dd�Z!dd�Z"dS(u�
NAPALM Grains
=============

:codeauthor: Mircea Ulinic <mircea@cloudflare.com>
:maturity:   new
:depends:    napalm
:platform:   unix

Dependencies
------------

- :mod:`NAPALM proxy module <salt.proxies.napalm>`

.. versionadded:: 2016.11.0
i(tabsolute_importtprint_functiontunicode_literalsNunapalmusecretuenable_passwordcC@stjjjttt�S(u_
    NAPALM library must be installed for this module to work and run in a (proxy) minion.
    (tsalttutilstnapalmtvirtualt__opts__t__virtualname__t__file__(((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pyt__virtual__4scC@srtsn|r1tjjjt�r1|d�aqn|rntjjjt�rntjjjtdi�aqnntS(uM
    Retrieves the grains from the network device if not cached already.
    unapalm.get_grainsu	get_facts(	tGRAINS_CACHERRRtis_proxyRt	is_miniontcalltDEVICE_CACHE(tproxy((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pyt_retrieve_grains_cache?scC@s{tsw|r@tjjjt�r@d|krt|d�aqtqw|rwtjjjt�rwtjjjt�aqwntS(uA
    Loads the network device details if not cached already.
    unapalm.get_device(RRRRRRR
t
get_device(R((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pyt_retrieve_device_cacheRscC@sMtd|�}|jdt�rI|jdi�rI|jd�j|�SdS(u?
    Retrieves the grain value from the cached dictionary.
    RuresultuoutN(RtgettFalse(tnameRtgrains((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pyt
_get_grainbs$cC@s"td|�}|j|j��S(u+
    Retrieves device-specific grains.
    R(RRtupper(RRtdevice((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pyt_get_device_grainkscC@sitdd|�d6S(u�
    Returns the Operating System name running on the network device.

    Example: junos, iosxr, eos, ios etc.

    CLI Example - select all network devices running JunOS:

    .. code-block:: bash

        salt -G 'os:junos' test.ping
    udriver_nameRuos(R(R((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pytgetoswscC@sitdd|�d6S(u�
    Returns the OS version.

    Example: 13.3R6.5, 6.0.2 etc.

    CLI Example - select all network devices running JunOS 13.3R6.5 and return the model:

    .. code-block:: bash

        salt -G 'os:junos and version:13.3R6.5' grains.get model

    Output:

    .. code-block:: yaml

        edge01.bjm01:
            MX2000
        edge01.sjc01:
            MX960
        edge01.mrs01:
            MX480
        edge01.muc01:
            MX240
    u
os_versionRuversion(R(R((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pytversion�scC@sitdd|�d6S(u
    Returns the network device chassis model.

    Example: MX480, ASR-9904-AC etc.

    CLI Example - select all Juniper MX480 routers and execute traceroute to 8.8.8.8:

    .. code-block:: bash

        salt -G 'model:MX480' net.traceroute 8.8.8.8
    umodelR(R(R((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pytmodel�scC@sitdd|�d6S(u�
    Returns the chassis serial number.

    Example: FOX1234W00F

    CLI Example - select all devices whose serial number begins with `FOX` and display the serial number value:

    .. code-block:: bash

        salt -G 'serial:FOX*' grains.get serial

    Output:

    .. code-block:: yaml

        edge01.icn01:
            FOXW00F001
        edge01.del01:
            FOXW00F002
        edge01.yyz01:
            FOXW00F003
        edge01.mrs01:
            FOXW00F004
    u
serial_numberRuserial(R(R((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pytserial�scC@sitdd|�d6S(u�
    Returns the network device vendor.

    Example: juniper, cisco, arista etc.

    CLI Example - select all devices produced by Cisco and shutdown:

    .. code-block:: bash

        salt -G 'vendor:cisco' net.cli "shut"
    uvendorR(R(R((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pytvendor�scC@sitdd|�d6S(u�
    Returns the uptime in seconds.

    CLI Example - select all devices started/restarted within the last hour:

    .. code-block:: bash

        salt -G 'uptime<3600' test.ping
    uuptimeR(R(R((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pytuptime�s
cC@sitdd|�d6S(uK
    Returns the complete interfaces list of the network device.

    Example: ['lc-0/0/0', 'pfe-0/0/0', 'xe-1/3/0', 'lo0', 'irb', 'demux0', 'fxp0']

    CLI Example - select all devices that have a certain interface, e.g.: xe-1/1/1:

    .. code-block:: bash

        salt -G 'interfaces:xe-1/1/1' test.ping

    Output:

    .. code-block:: yaml

        edge01.yyz01:
            True
        edge01.maa01:
            True
        edge01.syd01:
            True
        edge01.del01:
            True
        edge01.dus01:
            True
        edge01.kix01:
            True
    uinterface_listRu
interfaces(R(R((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pyt
interfaces�scC@s6|r2tjjjt�r2itdd|�d6SdS(uA
    Return the username.

    .. versionadded:: 2017.7.0

    CLI Example - select all devices using `foobar` as username for connection:

    .. code-block:: bash

        salt -G 'username:foobar' test.ping

    Output:

    .. code-block::yaml

        device1:
            True
        device2:
            True
    uusernameRN(RRRRRR(R((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pytusername	scC@sitdd|�d6S(u@
    Return the hostname as configured on the network device.

    CLI Example:

    .. code-block:: bash

        salt 'device*' grains.get hostname

    Output:

    .. code-block:: yaml

        device1:
            edge01.yyz01
        device2:
            edge01.bjm01
        device3:
            edge01.flw01
    uhostnameR(R(R((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pythostname$scC@s6|r2tjjjt�r2itdd|�d6SdS(u]
    This grain is set by the NAPALM grain module
    only when running in a proxy minion.
    When Salt is installed directly on the network device,
    thus running a regular minion, the ``host`` grain
    provides the physical hostname of the network device,
    as it would be on an ordinary minion server.
    When running in a proxy minion, ``host`` points to the
    value configured in the pillar: :mod:`NAPALM proxy module <salt.proxy.napalm>`.

    .. note::

        The diference between ``host`` and ``hostname`` is that
        ``host`` provides the physical location - either domain name or IP address,
        while ``hostname`` provides the hostname as configured on the device.
        They are not necessarily the same.

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt 'device*' grains.get host

    Output:

    .. code-block:: yaml

        device1:
            ip-172-31-13-136.us-east-2.compute.internal
        device2:
            ip-172-31-11-193.us-east-2.compute.internal
        device3:
            ip-172-31-2-181.us-east-2.compute.internal
    uhostnameRuhostN(RRRRRR(R((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pythost<s%cC@s�tjdt�sdStd|�}|r�|d}iigd6gd6d6}tjjj|d�}|r||dd<ntjjj|d�}|r�||dd<n|SdS(u�
    Return the DNS information of the host.
    This grain is a dictionary having two keys:

    - ``A``
    - ``AAAA``

    .. note::
        This grain is disabled by default, as the proxy startup may be slower
        when the lookup fails.
        The user can enable it using the ``napalm_host_dns_grain`` option (in
        the pillar or proxy configuration file):

        .. code-block:: yaml

            napalm_host_dns_grain: true

    .. versionadded:: 2017.7.0

    CLI Example:

    .. code-block:: bash

        salt 'device*' grains.get host_dns

    Output:

    .. code-block:: yaml

        device1:
            A:
                - 172.31.9.153
            AAAA:
                - fd52:188c:c068::1
        device2:
            A:
                - 172.31.46.249
            AAAA:
                - fdca:3b17:31ab::17
        device3:
            A:
                - 172.31.8.167
            AAAA:
                - fd0f:9fd6:5fab::1
    unapalm_host_dns_grainNRuhostuAuAAAAuhost_dns(RRRR%RRtdnstlookup(Rtdevice_hosttdevice_host_valuethost_dns_rettdns_atdns_aaaa((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pythost_dnsgs .
cC@sStdd|�pi}|rHtrHx!tD]}|j|d�q+Wni|d6S(u�
    Return the connection optional args.

    .. note::

        Sensible data will not be returned.

    .. versionadded:: 2017.7.0

    CLI Example - select all devices connecting via port 1234:

    .. code-block:: bash

        salt -G 'optional_args:port:1234' test.ping

    Output:

    .. code-block:: yaml

        device1:
            True
        device2:
            True
    u
optional_argsRN(Rt_FORBIDDEN_OPT_ARGStpoptNone(Rtopt_argstarg((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pyt
optional_args�s

(#t__doc__t
__future__RRRtloggingt	getLoggert__name__tlogtsalt.utils.dnsRtsalt.utils.napalmRt__proxyenabled__RRR.R
R0RRRRRRRRR R!R"R#R$R%R-R3(((s6/usr/lib/python2.7/site-packages/salt/grains/napalm.pyt<module>s8				
 +B

Zerion Mini Shell 1.0