File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/junos.cpython-310.pyc
Back
o ;j�& � @ s d Z ddlZddlZddlZddlZddlZddlmZ ddlZddl Z ddlZ ddlZ ddl Z ddlZ ddlZ zddlmZ W n eyR ddlm mZ Y nw zSddlZddlm mZ ddlZddlZddlZddlmZ ddl m!Z!m"Z"m#Z#m$Z$ ddl%m&Z& ddl'm(Z( dd l)m*Z* dd l+m,Z, ddl-m.Z. ddl/m0Z0 d Z1W n ey� dZ1Y nw e�2e3�Z4dZ5dgZ6dd� Z7G dd� d�Z8dd� Z9dd� Z:dd� Z;e:dd� �Z<dd� Z=e9dRdd��Z>e9dSd d!��Z?e9d"d#� �Z@e9d$d%� �ZAe9d&d'� �ZBe9dSd(d)��ZCe9dSd*d+��ZDe9d,d-� �ZEe9dSd.d/��ZFe:d0d1� �ZGe9dSd2d3��ZHe:d4d5� �ZIe:d6d7� �ZJe:d8d9� �ZKe9dSd:d;��ZLe:d<d=� �ZMe: dTd>d?��ZNd@dA� ZOe9dBdC� �ZPdDdE� ZQdFdG� ZRe9dHdI� �ZSe9dJdK� �ZTdLdM� ZUe9dNdO� �ZVe9dUdPdQ��ZWdS )VaE Module to interact with Junos devices. :maturity: new :dependencies: junos-eznc, jxmlease .. note:: Those who wish to use junos-eznc (PyEZ) version >= 2.1.0, must use the latest salt code from github until the next release. Refer to :mod:`junos <salt.proxy.junos>` for information on connecting to junos proxy. � N��wraps)�etree)�Device)�ConnectClosedError� LockError�RpcTimeoutError�UnlockError)�CfgTable)� FactoryLoader)�OpTable)�Config)�SCP)�SWTF�junosc C s t rdtv rtS dS )z� We need the Junos adapter libraries for this module to work. We also need a proxymodule entry in __opts__ in the opts dictionary �proxy)Fz�The junos or dependent module could not be loaded: junos-eznc or jxmlease or yamlordereddictloader or proxy could not be loaded.)� HAS_JUNOS�__opts__�__virtualname__� r r �F/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/junos.py�__virtual__K s r c @ s( e Zd ZdZdd� Zdd� Zdd� ZdS ) �HandleFileCopyz� To figure out proper path either from proxy local file system or proxy cache or on master. If required, then only copy from master to proxy c K s || _ d | _d | _|| _d S �N)� _file_path�_cached_folder�_cached_file�_kwargs)�self�path�kwargsr r r �__init__d s zHandleFileCopy.__init__c C st | j �d�rytd | j �}|rZtd | j �}td |�}|�d�|krZtjj�� | _tjj� | jd��}td d |dd �| j ��}|�|� W d � | jS 1 sRw Y | jS tjj�� | _td | j | jfi | j �� | jdkrw| jS d S td | j �r�tjj�� | _tjj� | jd��}td d | j dd �| j ��}|�|� W d � | jS 1 s�w Y | jS d S )Nzsalt://zcp.is_cachedzcp.hash_filez file.get_hashZhsum�wzslsutil.rendererZjinja)r Zdefault_rendererzcp.get_template� zfile.file_existsr )r � startswith�__salt__�get�salt�utils�filesZmkstempr �fopenr �write)r Zlocal_cache_pathZmaster_hashZ proxy_hash�fpZtemplate_stringr r r � __enter__j sT �� ���� ��� ���zHandleFileCopy.__enter__c C sV | j d urtjj�| j � t�d| j � | jd ur)td | j� t�d| j� d S d S )NzDeleted cached file: %sz file.rmdirzDeleted cached folder: %s) r r'