%PDF- %PDF-
Mini Shell

Mini Shell

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

o

K��^�B�@s�ddlZddlmZddlZddlZddlZddlmZmZddl	Z	ddl
mZmZddl
mZgd�ZddgZe�d	�Zd
d�ZGdd
�d
ej�ZGdd�dej�Ze	jdd�Gdd�d��Ze	jdd�Gdd�d��Ze	jdd�Gdd�d��Ze	jdd�Gdd�d��Ze	jdd�Gdd�d��Ze	jdd�Gdd�d��Ze	jdd�Gdd�d��ZGd d!�d!�ZGd"d#�d#e �Z!Gd$d%�d%e �Z"dS)&�N)�pgettext)�AF_INET�AF_INET6)�List�Optional)�netplan)�lo�bridge�tun�tap�dummy�sit�canz???�vlan�bondzsubiquitycore.models.networkcCst�|�jS�N)�	ipaddress�ip_interface�version)�ip�r�4/usr/share/subiquity/subiquitycore/models/network.py�addr_version$src@sZeZdZedd�Zedd�Zedd�Zedd�Zedd�Zedd�Z	edd�Z
dd	�Zd
S)�NetDevAction�Infoz	Edit Wifiz	Edit IPv4z	Edit IPv6z	Edit bondzAdd a VLAN tag�DeletecCstt|�j|j�Sr)r�type�__name__�value��selfrrr�str2szNetDevAction.strN)r�
__module__�__qualname__r�INFO�	EDIT_WLAN�	EDIT_IPV4�	EDIT_IPV6�	EDIT_BOND�ADD_VLAN�DELETEr!rrrrr(s






rc@s,eZdZe��Ze��Ze��Ze��ZdS)�	DHCPStateN)	rr"r#�enum�auto�PENDING�	TIMED_OUT�RECONFIGURE�
CONFIGUREDrrrrr+6s
r+T)�auto_attribsc@s.eZdZUeed<eeed<eeed<dS)�
DHCPStatus�enabled�state�	addressesN)	rr"r#�bool�__annotations__rr+rr!rrrrr3=�
r3c@s`eZdZUe�e�Zeee	d<dZ
eee	d<e�e�Zeee	d<e�e�Z
eee	d<dS)�StaticConfigr6N�gateway�nameservers�
searchdomains)rr"r#�attr�Factory�listr6rr!r8r;rr<r=rrrrr:Ds

r:c@seZdZUeed<eed<dS)�
VLANConfig�id�linkN)rr"r#�intr8r!rrrrrALs
rAc@s&eZdZUeeed<eeed<dS)�
WLANConfig�ssid�pskN)rr"r#rr!r8rrrrrERs
rEc@s.eZdZUeed<eeed<eeed<dS)�
WLANStatus�config�
scan_state�
visible_ssidsN)rr"r#rEr8rr!rrrrrrHXr9rHc@sJeZdZUeeed<eed<dZeeed<dZeeed<dd�Z	dS)�
BondConfig�
interfaces�modeN�xmit_hash_policy�	lacp_ratecCsD|j}d|ji}|tjvr|j|d<|tjvr|j|d<|j|d�S)NrNztransmit-hash-policy�	lacp-rate)rM�
parameters)rN�BondParameters�supports_xmit_hash_policyrO�supports_lacp_raterPrM)r rN�paramsrrr�	to_configfs�



�zBondConfig.to_config)
rr"r#rr!r8rOrrPrWrrrrrL_s
rLc@s�eZdZUdZeed<eed<eed<eeed<eed<eeed<eeed<eeed	<eeed
<eed<eed<eeed
<ee	ed<ee
ed<eed<eed<eed<eed<e
eed<dS)�
NetDevInfoz@All the information about a NetworkDev that the view code needs.�namer�is_connected�bond_master�is_used�disabled_reason�hwaddr�vendor�model�
is_virtual�
has_configrr�wlan�dhcp4�dhcp6�static4�static6�enabled_actionsN)rr"r#�__doc__r!r8r7rrArLrHr3r:rrrrrrrXus*
rXc@s2eZdZgd�Zhd�Zgd�ZdhZddgZdS)rS)z
balance-rrz
active-backup�balance-xor�	broadcast�802.3ad�balance-tlbzbalance-alb>rlrmrj)�layer2zlayer2+3zlayer3+4zencap2+3zencap3+4rl�slow�fastN)rr"r#�modesrT�xmit_hash_policiesrU�
lacp_ratesrrrrrS�s
	��rSc@s�eZdZdd�Zdefdd�Zdd�Zdd	�Zd
d�Zdd
�Z	e
dd��Zejdd��Zdd�Z
e
dd��Zdd�Ze
dd��Ze
dd��Ze
dd��Ze
dd��Ze
dd ��Zd!Ze
d"d#��Zd!Zd!Ze
d$d#��Ze
d%d#��Ze
d&d#��Zd'd(�Zd)S)*�
NetworkDevcCs:||_||_||_i|_d|_d|_i|_ddd�|_dS)N���)�_model�_namerrI�infor]�dhcp_events�_dhcp_state)r r`rY�typrrr�__init__�s�zNetworkDev.__init__�returnc	s��jdkrt�jj�}nd}d}�j��D]}|jdkrq�j|j�dg�vr,|j}nq�jdkrP�jdurP�jd}t	�jd|d|�d�|�d�d	�}nd}�jd
kri�jdurit
�jd�jdd
�}nd}�jdkr��j\}}tt
||d��jjd�jjdd�}	nd}	���}
ggd�}�jdur��j�dg�D]}|t|��|�q��j�di�}
ni}
i}i}dD]9}t��|��j||
|d�||<�jdur߈j�dt|��}nd}t||||
�dg�|
�dg�d�||<q�td.id�j�d�j�d|�d
|�d|�d|�d|	�d|d�d |d!�d"|d�d#|d!�d$�j�d%�j�d&�fd'd(�tD��d)t�jd)d��d*t�jd*d��d+t�jd+d��d,�j�d-�jdu��S)/N�ethTrrMrRrNzxmit-hash-policyrQ)rMrNrOrPrrBrC)rBrCrc)rFrGrJrK)rIrJrKrur6r<)r4r5r6r;�search)r6r;r<r=rYrrZr[rdrvrerwrfrgr\r]rhcsg|]	}��|�r|�qSr)�supports_action)�.0�actionrrr�
<listcomp>s��z*NetworkDev.netdev_info.<locals>.<listcomp>r^r_r`rarbr)rr7rzrZrx�get_all_netdevsrYrI�getrLrA�configured_ssidrHrErc�dhcp_addressesr�appendr3�dhcp_enabledr|r!r:rXr\r]r�getattrra)r rZr[�dev2rVrrrFrGrcr��configured_addresseses�addr�ns�
dhcp_statuses�static_configs�vr;rrr�netdev_info�s�

�
�




�


�


���������	�
���
�
������
�zNetworkDev.netdev_infocCsjggd�}|jdur3|jj��D]"}|jtkrd}n	|jtkr"d}nq|jdkr2||�t|j	��q|S)Nrurvrw�dhcp)
rzr6�values�familyrr�sourcer�r!�address)r �r�ar�rrrr�s




�zNetworkDev.dhcp_addressescCs$|jdurdS|j�dj|d�d�S)NF�dhcp{v}�r�)rIr��format�r rrrrr�&s
zNetworkDev.dhcp_enabledcCs$|j�dj|d�d�s
dS|j|S)Nr�r�F)rIr�r�r|r�rrr�
dhcp_state,s
zNetworkDev.dhcp_statecCs||j|<dSr)r|)r rr5rrr�set_dhcp_state1szNetworkDev.set_dhcp_statecCs|jSr)ryrrrrrY4szNetworkDev.namecCs�||jkr=|jr=||jjvrtdj|j|d���||jj|<|jdur=t|j|j|j�}||jj|j<d|_	|j|_d|_||_
dS)Nz#renaming {old_name} over {new_name})�old_name�new_name)rYrarx�devices_by_name�RuntimeErrorr�rzrtrrIry)r r��dead_devicerrrrY8s��

cCst|d|j�S)N�
_supports_)r�rY)r r�rrrr�KszNetworkDev.supports_actioncCs4|j�di���D]\}}|�d�}||fSdS)N�
access-points�password)NN)rIr��items)r rF�settingsrGrrrr�Ns
zNetworkDev.configured_ssidcCsF|j�di�}|��|duri||<|dur!|||d<dSdSdS)Nr�r�)rI�
setdefault�clear)r rFrG�apsrrr�set_ssid_pskUs�zNetworkDev.set_ssid_pskcCs|jdur	|jjSdSr)rz�ifindexrrrrr�]s
zNetworkDev.ifindexcCs
|jtvSr)r�"NETDEV_ALLOWED_VIRTUAL_IFACE_TYPESrrrrrads
zNetworkDev.is_virtualcCs8|j��D]}|jdkr|j|j�dg�vrdSqdS)NrrMTF�rxr�rrYrIr��r �devrrr�
is_bond_slavehs
�zNetworkDev.is_bond_slavecCsZ|j��D]%}|jdkr|j|j�dg�vrdS|jdkr*|j|j�d�kr*dSqdS)NrrMTrrCFr�r�rrrr\ps

�zNetworkDev.is_usedcCsdd�t|jj���D�S)NcSs g|]\}}|jdkr|j�qS)�global)�scoper)r��_r�rrrr�}s
�z9NetworkDev.actual_global_ip_addresses.<locals>.<listcomp>)�sortedrzr6r�rrrr�actual_global_ip_addresses{sz%NetworkDev.actual_global_ip_addressesTcC�
|jdkS)Nrc�rrrrr�<lambda>��
zNetworkDev.<lambda>cCr��Nrr�rrrrr��r�cCs|jdko|jS)Nr)rr�rrrrr��scCs|jo|jSr)rar\rrrrr��scCs~|j�dj|d�d�|j�dj|d�d�g}|j�dg�D]
}t|�|kr,|�|�q|r6||jd<dS|j�dd�dS)Nr�r�z
gateway{v}r6)rI�popr�r�rr�)r r�addrsrrrr�remove_ip_networks_for_version�s
�z)NetworkDev.remove_ip_networks_for_versionN)rr"r#r~rXr�r�r�r�r��propertyrY�setterr�r�r�r�rar�r\r��_supports_INFO�_supports_EDIT_WLAN�_supports_EDIT_IPV4�_supports_EDIT_IPV6�_supports_EDIT_BOND�_supports_ADD_VLAN�_supports_DELETEr�rrrrrt�sJ
R








��rtc@sreZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
ddd�Zdd�Zdd�Z
dd�Zdd�ZdS)�NetworkModel� cCsi|_d|_||_dS)NF)r��has_network�project)r r�rrrr~�s
zNetworkModel.__init__cCst��|_|j�|�dSr)r�ConfigrI�load_from_root)r �netplan_rootrrr�parse_netplan_configs�s
z"NetworkModel.parse_netplan_configscCs�t�d||j|j�|jtvrt�d�dS|j}|jdkr d}|r.|jtvr.t�d�dS|j�|j�}|durF|j	durA	|S||_	|S|j
�|�}|rW|sWt�d�dSt||j|j�}||_	||_
t�d||jt
�|j
��||j|j<|S)Nznew_link %s %s %szignoring based on typercFzignoring based on is_virtualz&ignoring virtual device with no configznew_link %s %s with config %s)�log�debugrYr�NETDEV_IGNORED_IFACE_TYPESrar�r�r�rzrI�config_for_devicertr�sanitize_interface_config)r r�rCrar�rIrrr�new_link�s<




��

�zNetworkModel.new_linkcCs*|j��D]
\}}|j|kr|SqdSr)r�r�r��r r�rYr�rrr�update_link�s

��zNetworkModel.update_linkcCsX|j��D]$\}}|j|kr)d|_|jr!|jdur|j|=|S|j|=|SqdSr)r�r�r�rzrarIr�rrr�del_link�s

���zNetworkModel.del_linkcCs4dj||d�}t||d�}|j|<||d�|_|S)Nz{name}.{tag})rY�tagr)rCrB)r�rtr�rI)r �device_namer�rYr�rrr�new_vlan�s�zNetworkModel.new_vlancCs$t||d�}|j|<|��|_|Sr�)rtr�rWrI)r rY�bond_configr�rrr�new_bond�s
zNetworkModel.new_bondFcCs.dd�t|j���D�}|sdd�|D�}|S)NcSsg|]\}}|�qSrr)r��kr�rrrr��sz0NetworkModel.get_all_netdevs.<locals>.<listcomp>cSsg|]	}|jdur|�qSr)rI)r�r�rrrr��s)r�r�r�)r �include_deleted�devsrrrr��szNetworkModel.get_all_netdevscCs
|j|Sr)r�)r rYrrr�get_netdev_by_name�s
zNetworkModel.get_netdev_by_namecCs d�d�|j�tj|dd�g�S)N�
z,# This is the network config written by '{}'F)�default_flow_style)�joinr�r��yaml�dump)r rIrrr�stringify_config�s��zNetworkModel.stringify_configcCs^dddii}ddddd�}|��D]}||j}|d�|i�}|js&|jr,|j||j<q|S)	N�networkr��	ethernets�bonds�wifis�vlans)r�rrcr)r�rr�rIr\rY)r rI�type_to_keyr��key�configsrrr�
render_config�s ���
�zNetworkModel.render_configcCs$dd|�|���d�ddd�d�iS)N�write_filesz$etc/netplan/00-installer-config.yaml)�path�contentz@etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfgznetwork: {config: disabled}
)�etc_netplan_installer�nonet)r�r�rrrr�renders����zNetworkModel.renderN)F)rr"r#rir~r�r�r�r�r�r�r�r�r�r�r�rrrrr��s&	
r�)#r,�gettextrr�loggingr��socketrrr>�typingrr�
subiquitycorerr�r��	getLoggerr�r�Enumrr+�sr3r:rArErHrLrXrS�objectrtr�rrrr�<module>sB







&a

Zerion Mini Shell 1.0