%PDF- %PDF-
| Direktori : /proc/thread-self/root/proc/self/root/lib/python2.7/site-packages/salt/modules/ |
| Current File : //proc/thread-self/root/proc/self/root/lib/python2.7/site-packages/salt/modules/nxos_api.pyo |
�
���^c @@ s� d Z d d l m Z m Z m Z d d l Z d d l Z d d l m Z d d l m
Z
d d l m Z d g Z d Z
e j e � Z d � Z d
d � Z d
d � Z e d
� Z d d d d d d d � Z d S( u[
Execution module to manage Cisco Nexus Switches (NX-OS) over the NX-API
.. versionadded:: 2019.2.0
Execution module used to interface the interaction with a remote or local Nexus
switch whether we're running in a Proxy Minion or regular Minion (or regular
Minion running directly on the Nexus switch).
:codeauthor: Mircea Ulinic <ping@mirceaulinic.net>
:maturity: new
:platform: any
.. note::
To be able to use this module you need to enable to NX-API on your switch,
by executing ``feature nxapi`` in configuration mode.
Configuration example:
.. code-block:: bash
switch# conf t
switch(config)# feature nxapi
To check that NX-API is properly enabled, execute ``show nxapi``.
Output example:
.. code-block:: bash
switch# show nxapi
nxapi enabled
HTTPS Listen on port 443
.. note::
NX-API requires modern NXOS distributions, typically at least 7.0 depending
on the hardware. Due to reliability reasons it is recommended to run the
most recent version.
Check https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus7000/sw/programmability/guide/b_Cisco_Nexus_7000_Series_NX-OS_Programmability_Guide/b_Cisco_Nexus_7000_Series_NX-OS_Programmability_Guide_chapter_0101.html
for more details.
Usage
-----
This module can equally be used via the :mod:`nxos_api<salt.proxy.nxos_api>`
Proxy module or directly from an arbitrary (Proxy) Minion that is running on a
machine having access to the network device API. Given that there are no
external dependencies, this module can very well used when using the regular
Salt Minion directly installed on the switch.
When running outside of the :mod:`nxos_api Proxy<salt.proxy.nxos_api>`
(i.e., from another Proxy Minion type, or regular Minion), the NX-API connection
arguments can be either specified from the CLI when executing the command, or
in a configuration block under the ``nxos_api`` key in the configuration opts
(i.e., (Proxy) Minion configuration file), or Pillar. The module supports these
simultaneously. These fields are the exact same supported by the ``nxos_api``
Proxy Module:
transport: ``https``
Specifies the type of connection transport to use. Valid values for the
connection are ``http``, and ``https``.
host: ``localhost``
The IP address or DNS host name of the connection device.
username: ``admin``
The username to pass to the device to authenticate the NX-API connection.
password
The password to pass to the device to authenticate the NX-API connection.
port
The TCP port of the endpoint for the NX-API connection. If this keyword is
not specified, the default value is automatically determined by the
transport type (``80`` for ``http``, or ``443`` for ``https``).
timeout: ``60``
Time in seconds to wait for the device to respond. Default: 60 seconds.
verify: ``True``
Either a boolean, in which case it controls whether we verify the NX-API
TLS certificate, or a string, in which case it must be a path to a CA bundle
to use. Defaults to ``True``.
When there is no certificate configuration on the device and this option is
set as ``True`` (default), the commands will fail with the following error:
``SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)``.
In this case, you either need to configure a proper certificate on the
device (*recommended*), or bypass the checks setting this argument as ``False``
with all the security risks considered.
Check https://www.cisco.com/c/en/us/td/docs/switches/datacenter/nexus3000/sw/programmability/6_x/b_Cisco_Nexus_3000_Series_NX-OS_Programmability_Guide/b_Cisco_Nexus_3000_Series_NX-OS_Programmability_Guide_chapter_01.html
to see how to properly configure the certificate.
Example (when not running in a ``nxos_api`` Proxy Minion):
.. code-block:: yaml
nxos_api:
username: test
password: test
In case the ``username`` and ``password`` are the same on any device you are
targeting, the block above (besides other parameters specific to your
environment you might need) should suffice to be able to execute commands from
outside a ``nxos_api`` Proxy, e.g.:
.. code-block:: bash
salt-call --local nxos_api.show 'show lldp neighbors' raw_text
# The command above is available when running in a regular Minion where Salt is installed
salt '*' nxos_api.show 'show version' raw_text=False
.. note::
Remember that the above applies only when not running in a ``nxos_api`` Proxy
Minion. If you want to use the :mod:`nxos_api Proxy<salt.proxy.nxos_api>`,
please follow the documentation notes for a proper setup.
i ( t absolute_importt print_functiont unicode_literalsN( t six( t CommandExecutionError( t
SaltExceptionu *u nxos_apic C@ s t S( u\
This module does not have external dependencies, hence it is widely
available.
( t __virtualname__( ( ( s9 /usr/lib/python2.7/site-packages/salt/modules/nxos_api.pyt __virtual__� s u clic K@ s� t | t t f � s! | g } n t | d | | �} g } x� | D]� } | j d � } | r� | j d � } d | k r� d j d | d | d d � } t | � � q� d j d | � } t | � � n | j | d
� qC W| S( u)
Execute a list of CLI commands.
t methodu erroru commandu datau- The command "{cmd}" raised the error "{err}".t cmdt erru msgu Invalid command: "{cmd}".u result( t
isinstancet listt tuplet rpct gett formatR t append( t commandsR t kwargst
rpc_responsest
txt_responsest rpc_reponset errorR t msg( ( s9 /usr/lib/python2.7/site-packages/salt/modules/nxos_api.pyt _cli_command� s"