404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.119.103.130: ~ $
3

\�me�0�@s�ddlZddlmZddlmZddlmZmZddlm	Z	ddl
mZeje
�ZGdd�d�ZGd	d
�d
e	j�Zd
dd�ZdS)�N)�OrderedDict)�Optional)�subp�util)�renderer)�NetworkStatec@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�	CfgParserc	Cstggggggid��|_dS)N)�Match�Link�Network�DHCPv4�DHCPv6�Address�Route)r�	conf_dict)�self�r�/usr/lib/python3.6/networkd.py�__init__szCfgParser.__init__cCsdx^|jj�D]P}||kr|j|j|dt|��ttj|j|��|j|<|j|j�qWdS)N�=)r�keys�append�str�list�dict�fromkeys�sort)r�sec�key�val�krrr�update_section s
zCfgParser.update_sectioncCs�x�|jj�D]|}||kr||j|kr4g|j||<|j||j|dt|��ttj|j||��|j||<|j||j�qWdS)z�
        For each route section we use rid as a key, this allows us to isolate
        this route from others on subsequent calls.
        rN)rrrrrrrr)rr�ridrrr rrr�update_route_section(s  zCfgParser.update_route_sectioncCs�d}x�t|jj��D]�\}}|s"q|dkrbx�t|�D](}|d|d7}||d7}|d7}q4Wq|dkr�x�t|�D]>}|d|d7}x(t||�D]}||d7}|d7}q�WqtWq|d|d7}xt|�D]}||d7}q�W|d7}qW|S)N�r�[z]
�
r)�sortedr�items)r�contentsr �v�e�nrrr�get_final_conf8s(zCfgParser.get_final_confN)�__name__�
__module__�__qualname__rr!r#r-rrrrrs
rc@s�eZdZdZddd�Zed�dd�Zed�dd	�Zed�d
d�Zed�dd
�Z	ed�dd�Z
eed�dd�Zed�dd�Z
dd�Zdeeedd�dd�Zeed�dd�ZdS)�Rendererz�
    Renders network information in /etc/systemd/network

    This Renderer is currently experimental and doesn't support all the
    use cases supported by the other renderers yet.
    NcCs(|si}|jdd�|_|jdd�|_dS)N�resolve_conf_fnz/etc/systemd/resolved.conf�network_conf_dirz/etc/systemd/network/)�getr2r3)r�configrrrrYs
zRenderer.__init__)�cfgcCsXd}dddd�}|sdSx6|j�D]*\}}||kr"||r"|j||||�q"W|dS)Nr	�NameZDriverZ
MACAddress)�nameZdriverZmac_addressr8)r(r!)r�ifacer6rZ
match_dictr r*rrr�generate_match_sectioncszRenderer.generate_match_sectioncCs2d}|sdSd|kr.|dr.|j|d|d�dS)Nr
ZmtuZMTUBytes)r!)rr9r6rrrr�generate_link_sectionts
zRenderer.generate_link_sectionc	Cstd}dddd�}d}d|kr,dt|d�}xB|j�D]6\}}||krHq6|d	krX||7}|j|||||�q6Wd
S)zy
        Parse a route and use rid as a key in order to isolate the route from
        others in the route dict.
        r�GatewayZDestinationZMetric)�gateway�networkZmetricr$�prefix�/r>N)rr(r#)	rr"�confr6rZ
route_cfg_mapr?r r*rrr�parse_routes}szRenderer.parse_routescCs�d}d}d}�xj|jdg�D�]X}|d}|dks:|dkrV|dkrHd}qx|d	krxd
}n"|dkrx|dkrld	}n|dkrxd
}d|kr�|dr�x,|dD] }|jd
|��||�|d}q�Wd|krddddd�}	x�|j�D]�\}
}|
dk�rd|k�r|dt|d�7}|jd|	|
|�q�|
dk�rH|jdd|��|	|
|�|d}q�|
dk�sZ|
dkr�|j||	|
dj|��q�WqW|j|d|�|d!k�r�t|jdd�t��r�|j|d |d�|S)"N�norrZsubnets�typeZdhcp4�dhcpZipv4�ipv6�yesZdhcp6Zroutes�r��addressrr<�DNS�Domains)rJr=�dns_nameservers�
dns_searchr?r@r=r�arMrN� ZDHCPz	accept-rar$ZIPv6AcceptRA)rFrG)	r4rBr(rr!r#�join�
isinstance�bool)rr9r6rErr"r+�t�iZsubnet_cfg_mapr r*rrr�
parse_subnets�sP



 zRenderer.parse_subnetsc
Cs�x�d
D]�}||krqt||�j�}ytj|�}|r8dnd}Wn,tk
rj|dkrftjd|�d}YnX|dkrzd}nd}|j|d	|�qWdS)N�dhcp4domain�dhcp6domainrGrC�routezInvalid dhcp4domain value - %srr
�
UseDomains)rWrX)r�casefoldrZtranslate_bool�
ValueError�LOGZwarningr!)r�dr6�item�retZsectionrrr�dhcp_domain�s


zRenderer.dhcp_domain)r6�nsc	Cs�d}dddd�}|jd�}|r:|jdkr:|j|jd�}n|rN|jdkrNdSx<|j�D]0\}}||krX||rX|j||d	j||��qXWdS)
NrrLrK)�search�nameserversZ	addresses�dnsrI)rcrd�rP)r4�versionZdns_searchdomainsrMr(r!rQ)	rr9r6rbrZdns_cfg_maprer r*rrr�	parse_dns�s
zRenderer.parse_dnsc	Cs�ddddd�}|dkr,|jddd	d
dd��d
|�d�|kr�|dd|��gkr�|d
|�d�}x4|j�D](\}}||krh|jd|��|||�qhWdS)Nzuse-dnszuse-domainszuse-hostnamezuse-ntp)ZUseDNSrZZUseHostnameZUseNTP�4z
send-hostnameZhostnamezroute-metriczuse-mtuz
use-routes)ZSendHostnameZHostnameZRouteMetricZUseMTUZ	UseRoutesrEz
-overridesrGZipvZDHCPv)�updater(r!)	rr6�devicerErgZdhcp_config_mapsZdhcp_overridesr r*rrr�parse_dhcp_overrides�s$
zRenderer.parse_dhcp_overridescCs>d}tjd|�|d|d}tj||�tj|||�dS)Nzsystemd-networkz Setting Networking Config for %sz10-cloud-init-z.network)r]�debugrZ
write_fileZchownbyname)r�linkrAZnwk_dirZnet_fn_ownerZnet_fnrrr�create_network_files
zRenderer.create_network_file)�
network_state�	templates�returncCsT|j}|rtj|�|}tj|�|j|�}x"|j�D]\}}|j|||�q6WdS)N)r3rZtarget_pathrZ
ensure_dir�_render_contentr(ro)rrprq�targetZnetwork_dir�ret_dictr r*rrr�render_network_states

zRenderer.render_network_state)rbrrcCszi}�xn|j�D�]`}t�}|j||�}|j||�|j||�}|j|||�d}x,|j�D] }|jd|��||�|d}q\W|jdk�r`|d}	x6|j	dj
�D]$\}
}d|kr�|jd�|	kr�|
}	Pq�W|	|j	dk�r`|j	d|	}|j||�xhdD]`}
d
|
�d�|k�rJd|jd
|
�d
�i�k�rJ|	�d|
�d|
�d�}t
|��|j||||
��q�W|j||j�i�qW|S)Nr�crIrfr8Z	ethernetszset-nameri�6rEZdomainzuse-domainsz
-overridesz has both dhcpzdomain and dhcpz*-overrides.use-domains configured. Use one)rirx)Ziter_interfacesrr:r;rVrhZiter_routesrBrgr5r(r4ra�RuntimeErrorrlrjr-)rrbrur9r6rnrEr"rYr8Zdev_nameZdev_cfgrkrgZ	exceptionrrrrs(s<

zRenderer._render_content)N)NN)r.r/r0�__doc__rrr:r;rBrVrarrhrlrorrrvrsrrrrr1Qs

	6
r1cCs6ddg}ddg}x |D]}tj|||d�sdSqWdS)NZipZ	systemctlz	/usr/sbinz/bin)rcrtFT)rZwhich)rtZexpectedrc�prrr�	availablecs
r|)N)Zlogging�collectionsrZtypingrZ	cloudinitrrZ
cloudinit.netrZcloudinit.net.network_staterZ	getLoggerr.r]rr1r|rrrr�<module>s
?

Filemanager

Name Type Size Permission Actions
__init__.cpython-36.opt-1.pyc File 33.43 KB 0644
__init__.cpython-36.pyc File 33.43 KB 0644
activators.cpython-36.opt-1.pyc File 9.52 KB 0644
activators.cpython-36.pyc File 9.52 KB 0644
bsd.cpython-36.opt-1.pyc File 5.74 KB 0644
bsd.cpython-36.pyc File 5.74 KB 0644
cmdline.cpython-36.opt-1.pyc File 7.2 KB 0644
cmdline.cpython-36.pyc File 7.2 KB 0644
dhcp.cpython-36.opt-1.pyc File 15.98 KB 0644
dhcp.cpython-36.pyc File 15.98 KB 0644
eni.cpython-36.opt-1.pyc File 12.89 KB 0644
eni.cpython-36.pyc File 12.89 KB 0644
ephemeral.cpython-36.opt-1.pyc File 10.51 KB 0644
ephemeral.cpython-36.pyc File 10.51 KB 0644
freebsd.cpython-36.opt-1.pyc File 2.54 KB 0644
freebsd.cpython-36.pyc File 2.54 KB 0644
netbsd.cpython-36.opt-1.pyc File 1.69 KB 0644
netbsd.cpython-36.pyc File 1.69 KB 0644
netplan.cpython-36.opt-1.pyc File 11.91 KB 0644
netplan.cpython-36.pyc File 11.91 KB 0644
network_manager.cpython-36.opt-1.pyc File 12.83 KB 0644
network_manager.cpython-36.pyc File 12.83 KB 0644
network_state.cpython-36.opt-1.pyc File 27.57 KB 0644
network_state.cpython-36.pyc File 27.57 KB 0644
networkd.cpython-36.opt-1.pyc File 8.21 KB 0644
networkd.cpython-36.pyc File 8.21 KB 0644
openbsd.cpython-36.opt-1.pyc File 2.18 KB 0644
openbsd.cpython-36.pyc File 2.18 KB 0644
renderer.cpython-36.opt-1.pyc File 1.82 KB 0644
renderer.cpython-36.pyc File 1.82 KB 0644
renderers.cpython-36.opt-1.pyc File 1.53 KB 0644
renderers.cpython-36.pyc File 1.53 KB 0644
sysconfig.cpython-36.opt-1.pyc File 23.07 KB 0644
sysconfig.cpython-36.pyc File 23.07 KB 0644
udev.cpython-36.opt-1.pyc File 1.22 KB 0644
udev.cpython-36.pyc File 1.31 KB 0644