Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/pyroute2/ndb/objects/__pycache__/route.cpython-39.pyc
Ðазад
a ]�h�p � @ sz d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl m Z mZ ddlm Z mZ ddlmZmZmZ ddlmZ dd lmZ d dlmZ d dlmZ d d lmZ dd� e�� D �dd� Zdd� e�� D �dd� ZdZ d Z!dZ"dd� Z#dd� Z$dCdd�Z%e�� �&dd��&dd��&dd��'dd d!d"d#d$d%d&d'd(d)��(d*d+d,��(d*d-d,�Z)e�� �&dd.��&d/d��'dd/��(d0d1d1��(d*d2d,�Z*ej+�� �&dd.��'d��(d0d1d1�Z,ej-�� �&dd.��'d��(d0d1d1�Z.d0e)gd3e*gd4e,gd5e.ggd0egd3egd4ej+gd5ej-ggee$gid6�Z/G d7d8� d8e�Z0G d9d:� d:e�Z1G d;d<� d<�Z2G d=d>� d>e2e�Z3G d?d@� d@e2e4�Z5G dAdB� dBe2e�Z6dS )Da� .. testsetup:: from pyroute2 import NDB from pyroute2 import config config.mock_iproute = True ndb = NDB() .. testsetup:: tables from pyroute2 import NDB from pyroute2 import config config.mock_iproute = True ndb = NDB() ndb.routes.create( dst='1.1.1.1/32', gateway='127.0.0.10', oif=1, table=101 ).commit() ndb.routes.create( dst='1.1.1.2/32', gateway='127.0.0.10', oif=1, table=5001 ).commit() ndb.routes.create( dst='1.1.1.3/32', gateway='127.0.0.10', oif=1, table=5002 ).commit() .. testsetup:: metrics from pyroute2 import NDB from pyroute2 import config config.mock_iproute = True ndb = NDB() ndb.routes.create( dst='10.0.0.0/24', gateway='127.0.0.10' ).commit() Simple routes ============= Ordinary routes management is really simple: .. testcode:: # create a route ndb.routes.create( dst='10.0.0.0/24', gateway='192.168.122.1' ).commit() # retrieve a route and change it with ndb.routes['10.0.0.0/24'] as route: route.set(gateway='192.168.122.10') # remove a route with ndb.routes['10.0.0.0/24'] as route: route.remove() Multiple routing tables ======================= But Linux systems have more than one routing table: .. doctest:: tables >>> set((x.table for x in ndb.routes.summary())) {101, 5001, 5002, 254, 255} The main routing table is 254. All the routes people mostly work with are in that table. To address routes in other routing tables, you can use dict specs: .. testcode:: ndb.routes.create( dst='10.0.0.0/24', gateway='192.168.122.1', table=101 ).commit() with ndb.routes[{'table': 101, 'dst': '10.0.0.0/24'}] as route: route.set('gateway', '192.168.122.10') route.set('priority', 500) with ndb.routes[{'table': 101, 'dst': '10.0.0.0/24'}] as route: route.remove() Route metrics ============= `route['metrics']` attribute provides a dictionary-like object that reflects route metrics like hop limit, mtu etc: .. testcode:: metrics # set up all metrics from a dictionary with ndb.routes['10.0.0.0/24'] as route: route.set('metrics', {'mtu': 1500, 'hoplimit': 20}) # fix individual metrics with ndb.routes['10.0.0.0/24']['metrics'] as metrics: metrics.set('mtu', 1500) metrics.set('hoplimit', 20) MPLS routes =========== See here: :ref:`mpls` � N)�OrderedDict)�partial)�AF_INET� inet_pton)�AF_MPLS� basestring)�LWTUNNEL_ENCAP_MPLS�nh�rtmsg�� MPLSTarget)�RouteFieldFilter� )� check_auth)�RTNL_Object)�Recordc C s g | ]}d |d �qS )z main.f_%sr � ��.0�xr r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/pyroute2/ndb/objects/route.py� <listcomp>� � r ���c C s g | ]}d |d �qS )znh.f_%sr r r r r r r � r � � c C s� d| j g}|g}| jd D ]2}|�d|| j f � |�|�|�pJ|�|�� qdd�|� }d| }| �||��� D ]}|d d S tt � � �S )Nz f_target = %s�routes� f_%s = %szWHERE %s� AND z SELECT f_route_id FROM routes %sr )�plch�indices�append�get�get_attr�join�executeZfetchall�str�uuid�uuid4) �schema�target�event�keys�values�key�specZs_req�route_idr r r �get_route_id� s r1 c C sv d }g }|� dd�}|dkr0|d �ddg� n�|� d�dkr�|d dkr�|d dkr�|d tkr�|d d }z&t| |||d r�tt�� �nd � W nH ty� } z0| j�d|f � | j�d |f � W Y d }~n d }~0 0 |d d d �s@d|d<