Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pyeapi/api/__pycache__/switchports.cpython-39.pyc
Ðазад
a b�h#A � @ s@ d Z ddlZddlmZ ddlmZ G dd� de�Zdd� ZdS ) z�Module for working with logical layer 2 switchports in EOS This module provides an API for working with logical layer 2 interfaces (switchports) in EOS. Switchports are interfaces built on top of physical Ethernet and bundled Port-Channel interfaces. � N)�EntityCollection)� make_iterablec @ s� e Zd ZdZdd� Zdd� Zdd� Zdd � Zd d� Zdd � Z dd� Z dd� Zdd� Zdd� Z d&dd�Zd'dd�Zd(dd�Zd)dd�Zd*d d!�Zd"d#� Zd$d%� ZdS )+�Switchportsa� The Switchports class provides a configuration resource for swichports Logical layer 2 interfaces built on top of physical Ethernet and bundled Port-Channel interfaces can be configured and managed with an instance of Switchports. The Switchports class is a resource collection and supports get and getall methods. The Switchports class is derived from the BaseResource class c C sx | � d| �}d|v rdS t|d�}|�| �|�� |�| �|�� |�| �|�� |�| �|�� |�| �|�� |S )a� Returns a dictionary object that represents a switchport The Switchport resource returns the following: * name (str): The name of the interface * mode (str): The switchport mode value * access_vlan (str): The switchport access vlan value * trunk_native_vlan (str): The switchport trunk native vlan vlaue * trunk_allowed_vlans (str): The trunk allowed vlans value * trunk_groups (list): The list of trunk groups configured Args: name (string): The interface identifier to get. Note: Switchports are only supported on Ethernet and Port-Channel interfaces Returns: dict: A Python dictionary object of key/value pairs that represent the switchport configuration for the interface specified If the specified argument is not a switchport then None is returned �interface %szno switchport N)�name)Z get_block�dict�update�_parse_mode�_parse_access_vlan�_parse_trunk_native_vlan�_parse_trunk_allowed_vlans�_parse_trunk_groups)�selfr �config�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/switchports.py�get9 s zSwitchports.getc C s t �d|t j�}t|�d�d�S )aY Scans the specified config and parses the switchport mode value Args: config (str): The interface configuration block to scan Returns: dict: A Python dict object with the value of switchport mode. The dict returned is intended to be merged into the resource dict zswitchport mode (\w+)� )�mode��re�search�Mr �group�r r �valuer r r r [ s zSwitchports._parse_modec C s t �d|t j�}t|d�S )a Scans the specified config and parses the trunk group values Args: config (str): The interface configuraiton blcok Returns: A dict object with the trunk group values that can be merged into the resource dict zswitchport trunk group ([^\s]+))�trunk_groups)r �findallr r )r r �valuesr r r r i s zSwitchports._parse_trunk_groupsc C s t �d|�}t|�d�d�S )a\ Scans the specified config and parse the access-vlan value Args: config (str): The interface configuration block to scan Returns: dict: A Python dict object with the value of switchport access value. The dict returned is intended to be merged into the resource dict zswitchport access vlan (\d+)r )Zaccess_vlan�r r r r r r r r r v s zSwitchports._parse_access_vlanc C s t �d|�}t|�d�d�S )an Scans the specified config and parse the trunk native vlan value Args: config (str): The interface configuration block to scan Returns: dict: A Python dict object with the value of switchport trunk native vlan value. The dict returned is intended to be merged into the resource dict z"switchport trunk native vlan (\d+)r )Ztrunk_native_vlanr �r r �matchr r r r � s z$Switchports._parse_trunk_native_vlanc C s t �d|t j�}t|�d�d�S )ar Scans the specified config and parse the trunk allowed vlans value Args: config (str): The interface configuration block to scan Returns: dict: A Python dict object with the value of switchport trunk allowed vlans value. The dict returned is intended to be merged into the resource dict z#switchport trunk allowed vlan (.+)$r )Ztrunk_allowed_vlansr r! r r r r � s z&Switchports._parse_trunk_allowed_vlansc C s@ t �dt j�}t� }|�| j�D ]}| �|�}|r |||<