HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/__pycache__/nxos_api.cpython-310.pyc
o

�N�g��@s\dZddlZddlZddlZddlmZddlmZe�	e
�Zgd�Zdd�Z
dd	d
�ZdS)z*
Util functions for the NXOS API modules.
�N)�
SaltException)�clean_kwargs)�	transport�host�username�password�port�timeout�verify�rpc_versioncKs�tdi|��}i}|��D]\}}|tvr|||<q
d|vr"d|d<d|vr*d|d<d|vr:|ddkr6dnd|d<|�d	d
�}t|t�rJ||d<n||d<d
|vrVd|d
<d|vr^d|d<|S)z�
    Prepare the connection with the remote network device, and clean up the key
    value pairs, removing the args used for the connection init.
    rZ	localhostr�httpsr�http�Pi�r
TZ
verify_sslZ	ca_bundlerz2.0r	�<N�)r�items�RPC_INIT_KWARGS�get�
isinstance�bool)Znxos_api_kwargsZinit_kwargsZkargZwargr
rr�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/utils/nxos_api.py�_prepare_connections*�

r�clic	Kstdi|��}t�d�t�|�dj|d|d|dd�}ddi}g}t|ttf�s/|g}t|�D]\}}|�|d	||d
d�|d
d��q3d
|di}	t	j
jj|fd|	t
�|�|ddd�|��}
d|
vrnt|
d��|
d}t|t�rz|g}t|�D]
\}}|||d<q~|S)a
    Execute an arbitrary RPC request via the Nexus API.

    commands
        The commands to be executed.

    method: ``cli``
        The type of the response, i.e., raw text (``cli_ascii``) or structured
        document (``cli``). Defaults to ``cli`` (structured data).

    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``.
    zThese are the init args:z{transport}://{host}:{port}/insrrr)rrrzcontent-typezapplication/json-rpcr�)�cmd�version)Zjsonrpc�method�params�idZhttp_request_timeoutr	�POSTT�json)r�opts�dataZheader_dict�decodeZdecode_type�error�dict�commandNr)r�logr$�formatr�list�tuple�	enumerate�append�salt�utilsr
�queryr �dumpsrr%)Zcommandsr�kwargsZ	init_args�url�headers�payload�indexr&r!�responseZ
response_listrrr�rpc7sN%

������

r7)r)�__doc__r �loggingZsalt.utils.httpr-Zsalt.exceptionsrZsalt.utils.argsr�	getLogger�__name__r'rrr7rrrr�<module>s