%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core22/current/usr/share/subiquity/subiquitycore/__pycache__/
Upload File :
Create Path :
Current File : //snap/core22/current/usr/share/subiquity/subiquitycore/__pycache__/netplan.cpython-310.pyc

o

K��^_�@s�ddlZddlZddlZddlZddlZddlZe�d�Zdd�Zdd�Z	dd�Z
Gd	d
�d
�ZGdd�d�ZGd
d�d�Z
ddd�ZdS)�Nzsubiquitycore.netplancCs.|�di���D]\}}d|vrd|d<qdS)Nz
access-points�passwordz
<REDACTED>)�get�items)�iface_config�ap�	ap_config�r�-/usr/share/subiquity/subiquitycore/netplan.py�_sanitize_inteface_configs
��r
cCst�|�}t|�|S�N)�copy�deepcopyr
)rrrr	�sanitize_interface_configs
rcCs<t�|�}|�di��di���}|D]\}}t|�q|S)z0Return a copy of config with passwords redacted.�network�wifis)rr
rrr
)�config�
interfaces�ifacerrrr	�sanitize_configs


rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�Configz�A NetplanConfig represents the network config for a system.

    Call parse_netplan_config() with each piece of yaml config, and then
    call config_for_device to get the config that matches a particular
    network device, if any.
    cCsg|_g|_i|_dSr)�physical_devices�virtual_devicesr)�selfrrr	�__init__(s
zConfig.__init__c	
Cs�z
t�|�|_}Wntjy$}z
t�d|�WYd}~dSd}~ww|�d�}|dur5t�d�dS|�d�}|dkrFt�d|�dSdD]}|�|i���D]
\}}|j�	t
||��qRqHdD]}|�|i���D]
\}}|j�	t||��qmqcdS)	Nzcould not parse config: %srzno 'network' key in config�version�z$network has no/unexpected version %s)�	ethernetsr)�bonds�vlans)
�yaml�	safe_loadr�ReaderError�log�inforrr�append�_PhysicalDevicer�_VirtualDevice)	rr�err�phys_key�dev�
dev_config�virt_keyrrr	�parse_netplan_config-s0��


���zConfig.parse_netplan_configcs�|jr|jD]}|j|jkrt�|j�SqiSd�d}|jD]/}|�|�rOt�|j�}||vrK�fdd�||��D�}|rH|||<|S||=|Sq iS)N)�
macaddress�matchcsi|]\}}|�vr||�qSrr)�.0�k�v��allowed_matchesrr	�
<dictcomp>Ns�z,Config.config_for_device.<locals>.<dictcomp>)	�
is_virtualr�namerr
rr�matches_linkr)r�linkr)�	match_keyrr.rr2r	�config_for_deviceBs(
��

��
zConfig.config_for_devicec	Cspt|�D]1}zt|�}Wntyt�d|�Ynw|�|�|���Wd�n1s0wYqdS)Nzopening %s failed)�configs_in_root�open�OSErrorr"�	exceptionr,�read)r�root�path�fprrr	�load_from_rootWs����zConfig.load_from_rootN)�__name__�
__module__�__qualname__�__doc__rr,r:rCrrrr	r src@seZdZdd�Zdd�ZdS)r%cCsl|�d�}|dur||_d|_d|_n|�d�|_|�d�|_|�d�|_||_t�d|t|j�f�dS)Nr.r6r-�driver�config for %s = %s)r�
match_name�	match_mac�match_driverrr"�debugr)rr6rr.rrr	rbs

��z_PhysicalDevice.__init__cCsd|jdurt�|j|j�}nd}|jdur|j|jk}nd}|jdur*|j|jk}nd}|o1|o1|S)NT)rJ�fnmatchr6rK�hwaddrrLrH)rr8�matches_name�matches_mac�matches_driverrrr	r7qs


z_PhysicalDevice.matches_linkN)rDrErFrr7rrrr	r%asr%c@seZdZdd�ZdS)r&cCs(||_||_t�d|t|j�f�dS)NrI)r6rr"rMr)rr6rrrr	r�s
��z_VirtualDevice.__init__N)rDrErFrrrrr	r&�sr&Fcs�tj�|�stj�|�}d}dddd�}t|��g}|D]}|�t�tj�||d|���q�fdd�}|s?d	d
�|D���}t	||d�S)z�Return a list of all netplan configs under root.

    The list is ordered in increasing precedence.
    @param masked: if True, include config paths that are masked
                   by the same basename in a different directory.z*.yaml�0�1�2)�lib�etc�run�netplancs:tj�|�}|�d}|d|�tjj��}d||fS)z:returned key is basename + string-precidence based on dir.�Nz%s/%s)�osrA�basename�find�sep)rA�bname�bdir��rootlenrr	�mykey�szconfigs_in_root.<locals>.mykeycSsi|]	}tj�|�|�qSr)r[rAr\)r/�prrr	r4�sz#configs_in_root.<locals>.<dictcomp>)�key)
r[rA�isabs�abspath�len�extend�glob�join�values�sorted)r@�masked�wildcard�dirs�paths�drcrrar	r;�s r;)F)rrjrNr[�loggingr�	getLoggerr"r
rrrr%r&r;rrrr	�<module>s
	A 	

Zerion Mini Shell 1.0