Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pyeapi/api/__pycache__/ntp.cpython-39.pyc
Ðазад
a b�h] � @ s4 d Z ddlZddlmZ G dd� de�Zdd� ZdS )z�Module for managing the NTP configuration in EOS This module provides an API for configuring NTP resources using EOS and eAPI. Arguments: name (string): The interface port that specifies the NTP source. � N)�Entityc sr e Zd ZdZ� fdd�Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z dd� Zddd�Zdd� Z dd� Z� ZS )�Ntpz=The Ntp class implements global NTP router configuration c s t t| �j|i |�� d S )N)�superr �__init__)�self�args�kwargs�� __class__� �~/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pyeapi/api/ntp.pyr 2 s zNtp.__init__c C s8 | j }|sdS t� }|�| �|�� |�| �|�� |S )a Returns the current NTP configuration The Ntp resource returns the following: * source_interface (str): The interface port that specifies NTP server * servers (list): A list of the NTP servers that have been assigned to the node. Each entry in the list is a key/value pair of the name of the server as the key and None or 'prefer' as the value if the server is preferred. Returns: A Python dictionary object of key/value pairs that represents the current NTP configuration of the node:: { "source_interface": 'Loopback0', 'servers': [ { '1.1.1.1': None }, { '1.1.1.2': 'prefer' }, { '1.1.1.3': 'prefer' }, { '1.1.1.4': None }, ] } N)�config�dict�update�_parse_source_interface�_parse_servers)r r �responser r r �get5 s zNtp.getc C sH | j dkrt�d|tj�}nt�d|tj�}|r:|�d�nd }t|d�S )N�4.23z^ntp local-interface ([^\s]+)z^ntp source ([^\s]+)� )Zsource_interface)�version_number�re�search�M�groupr )r r �match�valuer r r r Z s zNtp._parse_source_interfacec C sV t �d|t j�}g }|D ]2}|d }|d dkr8|d nd }|�||i� qt|d�S )Nzntp server ([\S]+) ?(prefer)?r r �prefer)Zservers)r �findallr �appendr )r r �matchesr r �serverr r r r r b s zNtp._parse_serversc C s | � |�S )z�Instantiate the NTP by setting the source interface. Args: name (string): The interface port that specifies the NTP source. Returns: True if the operation succeeds, otherwise False. )�set_source_interface)r �namer r r �createk s z Ntp.createc C s2 | j dkr| jddd�}n| jddd�}| �|�S )z�Delete the NTP source entry from the node. Returns: True if the operation succeeds, otherwise False. r �ntp local-interfaceT��disable� ntp source�r �command_builder� configure�r �cmdr r r �deletev s z Ntp.deletec C s2 | j dkr| jddd�}n| jddd�}| �|�S )z�Default the NTP source entry from the node. Returns: True if the operation succeeds, otherwise False. r r% T)�defaultr( r) r, r r r r/ � s zNtp.defaultc C s2 | j dkr| jd|d�}n| jd|d�}| �|�S )z�Assign the NTP source on the node Args: name (string): The interface port that specifies the NTP source. Returns: True if the operation succeeds, otherwise False. r r% �r r( r) �r r# r- r r r r"