Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pyeapi/__pycache__/client.cpython-39.pyc
Ðазад
a b�h�� � @ s, d Z ddlmZ ddlZddlZzddlmZ ddlmZ W n* e yf ddlmZ ddlmZ Y n0 ddlmZm Z mZ ddlmZmZ dd lmZ dd lmZmZ ddlmZ dd gZeeeeed�ZdZG dd� de�Ze� Zdd� Zdd� Zdd� Zdd� Zd%dd �ZG d!d"� d"e �Z!d#d$� Z"dS )&a Python Client for eAPI This module provides the client for eAPI. It provides the primary functions for building applications that work with Arista EOS eAPI-enabled nodes. The first function is to provide a client for sending and receiving eAPI request and response objects on a per node basis. The second function provides a library for building API enabled data models for configuring EOS nodes. This library allows for creating connections to EOS eAPI enabled nodes using the connect or connect_to function. Both functions will return an instance of a Node object that can be used to send and receive eAPI commands. The Node object can autoload API modules for a structured object oriented approach to configuring the EOS node with native Python objects. Example: >>> import pyeapi >>> conn = pyeapi.connect(host='10.1.1.1', transport='http') >>> conn.execute(['show version']) {u'jsonrpc': u'2.0', u'result': [{u'memTotal': 2028008, u'version': u'4.14.5F', u'internalVersion': u'4.14.5F-2209869.4145F', u'serialNumber': u'', u'systemMacAddress': u'00:0c:29:f5:d2:7d', u'bootupTimestamp': 1421765066.11, u'memFree': 213212, u'modelName': u'vEOS', u'architecture': u'i386', u'internalBuildId': u'f590eed4-1e66-43c6-8943-cee0390fbafe', u'hardwareRevision': u''}], u'id': u'4312565648'} >>> node = pyeapi.connect_to('veos01') >>> node.enable('show version') {u'jsonrpc': u'2.0', u'result': [{u'memTotal': 2028008, u'version': u'4.14.5F', u'internalVersion': u'4.14.5F-2209869.4145F', u'serialNumber': u'', u'systemMacAddress': u'00:0c:29:f5:d2:7d', u'bootupTimestamp': 1421765066.11, u'memFree': 213212, u'modelName': u'vEOS', u'architecture': u'i386', u'internalBuildId': u'f590eed4-1e66-43c6-8943-cee0390fbafe', u'hardwareRevision': u''}], u'id': u'4312565648'} Additionally the node object can automatically load API modules to work with the resources in the configuration. The API autoloader supports automatic loading of modules in pyeapi.api as well as provides the ability to build custom API modules to be loaded from a different namespace. Example: >>> import pyeapi >>> node = pyeapi.connect_to('veos01') >>> node.api('vlans').get(1) {'state': 'active', 'name': 'default', 'vlan_id': 1, 'trunk_groups': []} The API autoloader loads API modules by their filename. The following objects are provide in this module for creating clients to interface with eAPI. Node -- Creates an instance of a node object that represents a single EOS device. Each EOS device to be managed should have a Node instance Config -- A subclass of ConfigParser.SafeConfigParser that handles the configuration file. The configuration file is an INI style file that contains the settings for nodes used by the connect_to function. � )�uuid4N)�ConfigParser)�Error)�SafeConfigParser)�load_module� make_iterable�debug)�HttpEapiConnection�HttpsEapiConnection)�HttpsEapiCertConnection)�SocketEapiConnection�HttpLocalEapiConnection)�CommandErrorz~/.eapi.confz/mnt/flash/eapi.conf)�socketZ http_local�http�httpsZhttps_certsr c @ sf e Zd ZdZddd�Zedd� �Zdd� Zd d � Zdd� Z d d� Z dd� Zdd� Zdd� Z dd� ZdS )�Configa� Conifguration instance for managing the eapi.conf file. This class provides an instance for handling the configuration file. It should normally need to be instantiated. A single config object is instantiated by the module for working with the config. Attributes: filename (str): The full path to the loaded filename Args: filename(str): The full path to the filename to be loaded when the object is instantiated. Nc C s$ t �| � || _t� | _| �� d S �N)r �__init__�filename�dict�tags�autoload��selfr � r �}/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pyeapi/client.pyr � s zConfig.__init__c s dd� � � fdd�| � � D �S )zG Returns all of the loaded connections names as a list c S s t | ��dd�S )N�connection:� )�str�replace)�xr r r �<lambda>� � z$Config.connections.<locals>.<lambda>c s g | ]}� |��qS r r )�.0�name��connr r � <listcomp>� r# z&Config.connections.<locals>.<listcomp>)�sections�r r r&