Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pyeapi/api/__pycache__/system.cpython-39.pyc
Ðазад
a b�h} � @ s4 d Z ddlZddlmZ G dd� de�Zdd� ZdS )aa Module for working with the global system in EOS This module provides an API for working with the global system settings in EOS. It provides the following class implementations: * System -- Configures global system settings System Attributes: hostname (string): The hostname of the node as configured in the running-configuration. � N)�Entityc @ sN e Zd ZdZdd� Zdd� Zdd� Zdd � Zddd �Zddd�Z ddd�Z d S )�Systemz�The System class implements global config for the node Global configuration settings include those thaat identify the node and provide node level configuration such as hostname c C s4 t � }|�| �� � |�| �� � |�| �� � |S )z�Returns the system configuration abstraction The System resource returns the following: * hostname (str): The hostname value Returns: dict: Represents the node's system configuration )�dict�update�_parse_hostname�_parse_iprouting�_parse_banners)�self�resource� r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pyeapi/api/system.py�get9 s z System.getc C s. d}t �d| jt j�}|r$|�d�}t|d�S )z�Parses the global config and returns the hostname value Returns: dict: The configured value for hostname. The returned dict object is intended to be merged into the resource dict � localhostz^hostname ([^\s]+)$� )�hostname)�re�search�config�M�groupr )r �value�matchr r r r J s zSystem._parse_hostnamec C s d| j v}t|d�S )z�Parses the global config and returns the ip routing value Returns: dict: The configure value for ip routing. The returned dict object is intendd to be merged into the resource dict z no ip routing)Z iprouting)r r )r r r r r r W s zSystem._parse_iproutingc C sh d }}t �d| jt jt jB �}|D ]6}|d �� dkrB|d }q$|d �� dkr$|d }q$t||d�S )a| Parses the global config and returns the value for both motd and login banners. Returns: dict: The configure value for modtd and login banners. If the banner is not set it will return a value of None for that key. The returned dict object is intendd to be merged into the resource dict Nz*^banner\s+(login|motd)\s?$\n(.*?)$\nEOF$\nr Zmotdr �login)Zbanner_motdZbanner_login)r �findallr �DOTALLr �stripr )r Z motd_valueZlogin_value�matchesr r r r r a s � zSystem._parse_bannersNFc C s | j d|||d�}| �|�S )am Configures the global system hostname setting EosVersion: 4.13.7M Args: value (str): The hostname value default (bool): Controls use of the default keyword disable (bool): Controls the use of the no keyword Returns: bool: True if the commands are completed successfully r �r �default�disable��command_builder� configure�r r r r �cmdr r r �set_hostnamev s �zSystem.set_hostnamec C s( |du rd}| j d|||d�}| �|�S )a� Configures the state of global ip routing EosVersion: 4.13.7M Args: value(bool): True if ip routing should be enabled or False if ip routing should be disabled default (bool): Controls the use of the default keyword disable (bool): Controls the use of the no keyword Returns: bool: True if the commands completed successfully otherwise False FTz ip routingr r r# r r r � set_iprouting� s �zSystem.set_iproutingc C sb d| }|du s|du r4| j |d||d�}| �|�S |�d�sF|d }t||d�}| �|g�S dS )a� Configures system banners Args: banner_type(str): banner to be changed (likely login or motd) value(str): value to set for the banner default (bool): Controls the use of the default keyword disable (bool): Controls the use of the no keyword` Returns: bool: True if the commands completed successfully otherwise False z banner %sTNr � )r$ �input)r! r"