HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/proxy/__pycache__/junos.cpython-310.pyc
o

�N�gz�@sdZddlZz4dZddlZddlZddlZddlZddlm	Z	m
Z
mZmZm
Z
mZmZmZddlmZddlmZWneyEdZYnwdgZiZe�e�ZGd	d
�d
�ZdZdd�Zd
d�Zdd�Zdd�Z dd�Z!dd�Z"dd�Z#dd�Z$dd�Z%dd�Z&dd �Z'd!d"�Z(d#d$�Z)dS)%a�
Interface with a Junos device via proxy-minion. To connect to a junos device via junos proxy, specify the host information in the pillar in '/srv/pillar/details.sls'

.. code-block:: yaml

    proxy:
      proxytype: junos
      host: <ip or dns name of host>
      username: <username>
      port: 830
      password: <secret>

In '/srv/pillar/top.sls' map the device details with the proxy name.

.. code-block:: yaml

    base:
      'vmx':
        - details

After storing the device information in the pillar, configure the proxy in '/etc/salt/proxy'

.. code-block:: yaml

    master: <ip or hostname of salt-master>

Run the salt proxy via the following command:

.. code-block:: bash

    salt-proxy --proxyid=vmx


�NT)�ConnectAuthError�ConnectClosedError�ConnectError�ConnectRefusedError�ConnectTimeoutError�
ProbeError�RpcError�RpcTimeoutError)�TimeoutExpiredError)�IOProcF�junosc@seZdZdZdZdd�ZdS)�RebootActivez�
    Class to get static variable, to indicate when a reboot/shutdown
    is being processed and the keep_alive should not probe the
    connection since it interferes with the shutdown process.
    FcKsdS�N�)�self�kwargsrr�D/opt/saltstack/salt/lib/python3.10/site-packages/salt/proxy/junos.py�__init__NszRebootActive.__init__N)�__name__�
__module__�__qualname__�__doc__�reboot_shutdownrrrrrr
Esr
cCstsdStS)z6
    Only return if all the modules are available
    )FzMMissing dependency: The junos proxy minion requires the 'jnpr' Python module.)�	HAS_JUNOS�__virtualname__rrrr�__virtual__VsrcCsd|d<t�d�d|ddi}gd�}d|d��vr(|d�d�|dd<|d��}|D]}||vr>|d|||<q0t�d	|�tjjdi|��td
<ztd
��Wn"t	t
ttt
fyz}zt�d|�dtd<WYd
}~d
Sd
}~wwd|vr�t|dd�}z|td
_Wnty�}zt�dt|��WYd
}~nd
}~wwt�d|�ztd
jtjjjjd�Wnty�}zt�d|�WYd
}~nd
}~wwztd
jtjjjjd�Wnty�}zt�d|�WYd
}~nd
}~wwdtd<d
S)z\
    Open the connection to the Junos device, login, and bind to the
    Resource class
    F�multiprocessingzOpening connection to junos�host�proxy)�user�username�password�passwd�portZgather_facts�modeZbaudZattemptsZ
auto_probeZssh_private_key_fileZ
ssh_config�	normalizeZ	huge_treer rzArgs: %s�connz2%s : not able to initiate connection to the device�initializedN�timeoutz"Not able to set timeout due to: %szRPC timeout set to %d seconds)Zcuz(Bind failed with Config class due to: %s)�swz$Bind failed with SW class due to: %sTr)�log�debug�keys�pop�jnprrZDevice�	thisproxy�openrrrrr�error�intr(�	Exception�str�bind�utilsZconfigZConfigr)ZSW)�opts�argsZ
optional_argsZ
proxy_keys�arg�exr(rrr�initdsb
����������r;cCst�dd�S)Nr'F)r/�getrrrrr'�sr'cCstdS)Nr&)r/rrrrr&�sr&cC�
dt_dS)NT�r
rrrrr�
reboot_active��
r?cCr=)NFr>rrrr�reboot_clear�r@rAcCstjSrr>rrrr�get_reboot_active�srBcCs<t�}t�td_|j}|stdid�|dd��|S)zk
    Validate and return the connection status with the remote device.

    .. versionadded:: 2018.3.0
    r&zevent.fire_masterzjunos/proxy/{}/stoprr)r&�pingr/�	connectedZ__salt__�format)r7�devZlocal_connectedrrr�alive�s�rGcCs�t�}|jdur
dSt|jd�rI|jjjdur|jjj��s,|jjjdurGt|jjt�rG|jjj�	�dkr@|jjj
��r@t|�St
�d�dSdSt|�S)z
    Ping?  Pong!
    NF�_session�z1skipped ping() call as proxy already getting dataT)r&Z_conn�hasattrrHZ
_transportZ	is_active�
isinstancer�_buffer�tellZ_q�empty�_rpc_file_listr*r+)rFrrrrC�s 
�� 
rCc
Cs�z|jjddd�WdSttfy+z|��WYdStttfy*YYdSwtyJ}zdt	|�vr?WYd}~dSWYd}~dSd}~ww)Nz	/dev/null�)�pathZdev_timeoutTFz,'NoneType' object has no attribute 'timeout')
ZrpcZ	file_listr	r�closerrr
�AttributeErrorr4)rFr:rrrrO�s ����rOcCsdS)z(
    Returns the name of this proxy
    rrrrrr�	proxytypesrTcCs`ttdj�}d|vrt|d�|d<d|vr.|dD]}t|d|d�|d|d<q|S)Nr&�version_infoZ
junos_info�object)�dictr/�facts)rX�rerrr�get_serialized_factss"rZcCs8t�d|d�z	td��WdStyYdSw)zz
    This is called when the proxy-minion is exiting to make sure the
    connection to the device is closed cleanly.
    zProxy module %s shutting down!!�idr&N)r*r+r/rRr3)r7rrr�shutdowns�r\)*r�loggingrZ
jnpr.junosr.Zjnpr.junos.utilsZjnpr.junos.utils.configZjnpr.junos.utils.swZjnpr.junos.exceptionrrrrrrrr	Zncclient.operations.errorsr
Z+ncclient.transport.third_party.junos.ioprocr�ImportErrorZ__proxyenabled__r/�	getLoggerrr*r
rrr;r'r&r?rArBrGrCrOrTrZr\rrrr�<module>s@%(
�
D"