%PDF- %PDF-
Mini Shell

Mini Shell

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

U

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|krd|d<qdS)Nz
access-pointsZpasswordz
<REDACTED>)�get�items)�iface_configZapZ	ap_config�r�-/usr/share/subiquity/subiquitycore/netplan.py�_sanitize_inteface_configsrcCst�|�}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)�configZ
interfacesZifacerrrr�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__(szConfig.__init__c	
Cs�zt�|�|_}Wn6tjk
rJ}zt�d|�WY�dSd}~XYnX|�d�}|dkrlt�d�dS|�d�}|dkr�t�d|�dSdD]0}|�|i���D]\}}|j�	t
||��q�q�dD]0}|�|i���D]\}}|j�	t||��q�q�dS)	Nzcould not parse config: %srzno 'network' key in config�version�z$network has no/unexpected version %s)Z	ethernetsr
)ZbondsZvlans)
�yamlZ	safe_loadrZReaderError�log�inforrr�append�_PhysicalDevicer�_VirtualDevice)	rr�errZphys_key�devZ
dev_configZvirt_keyrrr�parse_netplan_config-s&


zConfig.parse_netplan_configcs�|jr0|jD] }|j|jkrt�|j�Sqnhd�d}|jD]X}|�|�r>t�|j�}||kr��fdd�||��D�}|r�|||<n||=|Sq>iS)N)�
macaddress�matchcsi|]\}}|�kr||�qSrr)�.0�k�v�Zallowed_matchesrr�
<dictcomp>Ns�z,Config.config_for_device.<locals>.<dictcomp>)	Z
is_virtualr�namer	r
rr�matches_linkr)r�linkrZ	match_keyrr!rr%r�config_for_deviceBs 




zConfig.config_for_devicec
Cs^t|�D]P}zt|�}Wn tk
r8t�d|�YnX|�|�|���W5QRXqdS)Nzopening %s failed)�configs_in_root�open�OSErrorrZ	exceptionr�read)r�root�path�fprrr�load_from_rootWszConfig.load_from_rootN)�__name__�
__module__�__qualname__�__doc__rrr*r2rrrrr s
rc@seZdZdd�Zdd�ZdS)rcCsl|�d�}|dkr&||_d|_d|_n$|�d�|_|�d�|_|�d�|_||_t�d|t|j�f�dS)Nr!r'r �driver�config for %s = %s)r�
match_name�	match_mac�match_driverrr�debugr)rr'rr!rrrrbs
��z_PhysicalDevice.__init__cCsd|jdk	rt�|j|j�}nd}|jdk	r8|j|jk}nd}|jdk	rT|j|jk}nd}|ob|ob|S)NT)r9�fnmatchr'r:Zhwaddrr;r7)rr)Zmatches_nameZmatches_macZmatches_driverrrrr(qs


z_PhysicalDevice.matches_linkN)r3r4r5rr(rrrrrasrc@seZdZdd�ZdS)rcCs(||_||_t�d|t|j�f�dS)Nr8)r'rrr<r)rr'rrrrr�s��z_VirtualDevice.__init__N)r3r4r5rrrrrr�srFcs�tj�|�stj�|�}d}dddd�}t|��g}|D]"}|�t�tj�||d|���q8�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�runZnetplancs:tj�|�}|�d}|d|�tjj��}d||fS)z:returned key is basename + string-precidence based on dir.�Nz%s/%s)�osr0�basename�find�sep)r0ZbnameZbdir�Zrootlenrr�mykey�szconfigs_in_root.<locals>.mykeycSsi|]}tj�|�|�qSr)rEr0rF)r"�prrrr&�s
z#configs_in_root.<locals>.<dictcomp>)�key)
rEr0�isabs�abspath�len�extend�glob�join�values�sorted)r/ZmaskedZwildcard�dirs�paths�drJrrIrr+�s r+)F)r	rQr=rEZloggingrZ	getLoggerrrrrrrrr+rrrr�<module>s
	A 	

Zerion Mini Shell 1.0