File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/netmiko_mod.cpython-310.pyc
Back
o ;jhN � @ s� d Z ddlZddlZddlmZ ddlmZ zddlm Z m Z dZW n ey- dZY nw dgZ d Ze�e�Zd d� Zdd � Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Z d"dd�Zd d!� ZdS )#a$ Netmiko Execution Module ======================== .. versionadded:: 2019.2.0 Execution module to interface the connection with a remote network device. It is flexible enough to execute the commands both when running under a Netmiko Proxy Minion, as well as running under a Regular Minion by specifying the connection arguments, i.e., ``device_type``, ``ip``, ``username``, ``password`` etc. :codeauthor: Mircea Ulinic <ping@mirceaulinic.net> & Kirk Byers <ktbyers@twb-tech.com> :maturity: new :depends: netmiko :platform: unix Dependencies ------------ The ``netmiko`` proxy modules requires Netmiko to be installed: ``pip install netmiko``. Usage ----- This module can equally be used via the :mod:`netmiko <salt.proxy.netmiko_px>` Proxy module (check documentation), or directly from an arbitrary (Proxy) Minion that is running on a server (computer) having access to the network device, and has the ``netmiko`` library installed. When running outside of the :mod:`netmiko Proxy <salt.proxy.netmiko_px>` (i.e., from another Proxy Minion type, or regular Minion), the netmiko connection arguments can be either specified from the CLI when executing the command, or in a configuration block under the ``netmiko`` 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 ``netmiko`` Proxy Module: - ``device_type`` - Class selection based on device type. Supported options: - ``a10``: A10 Networks - ``accedian``: Accedian Networks - ``alcatel_aos``: Alcatel AOS - ``alcatel_sros``: Alcatel SROS - ``apresia_aeos``: Apresia AEOS - ``arista_eos``: Arista EOS - ``aruba_os``: Aruba - ``avaya_ers``: Avaya ERS - ``avaya_vsp``: Avaya VSP - ``brocade_fastiron``: Brocade Fastiron - ``brocade_netiron``: Brocade Netiron - ``brocade_nos``: Brocade NOS - ``brocade_vdx``: Brocade NOS - ``brocade_vyos``: VyOS - ``checkpoint_gaia``: Check Point GAiA - ``calix_b6``: Calix B6 - ``ciena_saos``: Ciena SAOS - ``cisco_asa``: Cisco SA - ``cisco_ios``: Cisco IOS - ``cisco_nxos``: Cisco NX-oS - ``cisco_s300``: Cisco S300 - ``cisco_tp``: Cisco TpTcCe - ``cisco_wlc``: Cisco WLC - ``cisco_xe``: Cisco IOS - ``cisco_xr``: Cisco XR - ``coriant``: Coriant - ``dell_force10``: Dell Force10 - ``dell_os10``: Dell OS10 - ``dell_powerconnect``: Dell PowerConnect - ``eltex``: Eltex - ``enterasys``: Enterasys - ``extreme``: Extreme - ``extreme_wing``: Extreme Wing - ``f5_ltm``: F5 LTM - ``fortinet``: Fortinet - ``generic_termserver``: TerminalServer - ``hp_comware``: HP Comware - ``hp_procurve``: HP Procurve - ``huawei``: Huawei - ``huawei_vrpv8``: Huawei VRPV8 - ``juniper``: Juniper Junos - ``juniper_junos``: Juniper Junos - ``linux``: Linux - ``mellanox``: Mellanox - ``mrv_optiswitch``: MrvOptiswitch - ``netapp_cdot``: NetAppcDot - ``netscaler``: Netscaler - ``ovs_linux``: OvsLinux - ``paloalto_panos``: PaloAlto Panos - ``pluribus``: Pluribus - ``quanta_mesh``: Quanta Mesh - ``ruckus_fastiron``: Ruckus Fastiron - ``ubiquiti_edge``: Ubiquiti Edge - ``ubiquiti_edgeswitch``: Ubiquiti Edge - ``vyatta_vyos``: VyOS - ``vyos``: VyOS - ``brocade_fastiron_telnet``: Brocade Fastiron over Telnet - ``brocade_netiron_telnet``: Brocade Netiron over Telnet - ``cisco_ios_telnet``: Cisco IOS over Telnet - ``apresia_aeos_telnet``: Apresia AEOS over Telnet - ``arista_eos_telnet``: Arista EOS over Telnet - ``hp_procurve_telnet``: HP Procurve over Telnet - ``hp_comware_telnet``: HP Comware over Telnet - ``juniper_junos_telnet``: Juniper Junos over Telnet - ``calix_b6_telnet``: Calix B6 over Telnet - ``dell_powerconnect_telnet``: Dell PowerConnect over Telnet - ``generic_termserver_telnet``: TerminalServer over Telnet - ``extreme_telnet``: Extreme Networks over Telnet - ``ruckus_fastiron_telnet``: Ruckus Fastiron over Telnet - ``cisco_ios_serial``: Cisco IOS over serial port - ``ip`` - IP address of target device (not required if ``host`` is provided) - ``host`` - Hostname of target device (not required if ``ip`` is provided) - ``username`` - Username to authenticate against target device, if required - ``password`` - Password to authenticate against target device, if required - ``secret`` - The enable password if target device requires one - ``port`` - The destination port used to connect to the target device - ``global_delay_factor`` - Multiplication factor affecting Netmiko delays (default: ``1``) - ``use_keys`` - Connect to target device using SSH keys (default: ``False``) - ``key_file`` - Filename path of the SSH key file to use - ``allow_agent`` - Enable use of SSH key-agent - ``ssh_strict`` - Automatically reject unknown SSH host keys (default: ``False``, which means unknown SSH host keys will be accepted) - ``system_host_keys`` - Load host keys from the user's "known_hosts" file (default: ``False``) - ``alt_host_keys`` - If ``True``, host keys will be loaded from the file specified in ``alt_key_file`` (default: ``False``) - ``alt_key_file`` - SSH host key file to use (if ``alt_host_keys=True``) - ``ssh_config_file`` - File name of OpenSSH configuration file - ``timeout`` - Connection timeout, in seconds (default: ``90``) - ``session_timeout`` - Set a timeout for parallel requests, in seconds (default: ``60``) - ``keepalive`` - Send SSH keepalive packets at a specific interval, in seconds. Currently defaults to ``0``, for backwards compatibility (it will not attempt to keep the connection alive using the KEEPALIVE packets). - ``default_enter`` - Character(s) to send to correspond to enter key (default: ``\n``) - ``response_return`` - Character(s) to use in normalized return data to represent enter key (default: ``\n``) Example (when not running in a ``netmiko`` Proxy Minion): .. code-block:: yaml netmiko: 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 ``netmiko`` Proxy, e.g.: .. code-block:: bash salt '*' netmiko.send_command 'show version' host=router1.example.com device_type=juniper salt '*' netmiko.send_config https://bit.ly/2sgljCB host=sw2.example.com device_type=cisco_ios .. note:: Remember that the above applies only when not running in a ``netmiko`` Proxy Minion. If you want to use the :mod:`<salt.proxy.netmiko_px>`, please follow the documentation notes for a proper setup. � N)�CommandExecutionError)�clean_kwargs)�BaseConnection�ConnectHandlerTF�*�netmikoc C s, t sdS tjj�� rtd d dkrdS tS )zB Execution module available only if Netmiko is installed. )FzFThe netmiko execution module requires netmiko library to be installed.�proxyZ proxytypeZ deltaproxy)FzUnsupported proxy minion type.)�HAS_NETMIKO�salt�utils�platformZis_proxyZ__opts__�__virtualname__� r r �L/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/netmiko_mod.py�__virtual__� s �r c K s� i }i }t d di �}|�| � td tj�\}}}}|�d�}|�� D ]\}} ||vr5| dur4| ||<