404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.135.218.63: ~ $
3

\�me
U�@s ddlZddlZddlZddlZddlZddlmZddlmZm	Z	ddl
mZmZm
Z
ddlmZeje�Zdddd	d
dgZdd
ddddddgZddddddddddddd d!d"d#d$d%d&d'd(d)d*gZd+d,�Zd-d.�Zd>d0d1�Zd2d3�Zd4d5�Zd6d7�ZGd8d9�d9ej�Zd?d:d;�Zd@d<d=�ZdS)A�N)�Optional)�subp�util)�ParserError�renderer�subnet_is_ipv6)�NetworkStatezpre-up�upzpost-up�downzpre-downz	post-downZ
bridge_ageingZbridge_bridgeprioZ	bridge_fdZ
bridge_gcinitZbridge_helloZ
bridge_maxageZbridge_maxwaitZ
bridge_stp�address�netmask�	broadcast�network�metric�gatewayZpointtopointZmedia�mtuZhostnameZ
leasehoursZ	leasetimeZvendorZclientZbootfile�serverZhwaddrZprovider�frameZnetnumZendpointZlocalZttlc
Cs�g}ddddddddd	d
g
}x�|j�D]t\}}|dkr8q&|dkrTd|d|df}|r&||kr&t|t�rtd
j|�}d|kr�|jdd�}|jdj||��q&Wt|�S)Nrrr
rrZpointopointrZscope�
dns_search�dns_nameserversz%s/%s�prefix� �_�-z    {0} {1})�items�
isinstance�list�join�replace�append�format�sorted)�iface�subnet�contentZ	valid_map�key�value�r'�/usr/lib/python3.6/eni.py�_iface_add_subnet@s.

r)c
	Cs"|dkrgSg}dddddddd	d
g	}ddd
g}ddi}|d
dkrN|jd�x�|j�D]�\}}t|t�rz||rvdnd}|sX||kr�qX|dkr�|r�||krXtjd|d||�qX||kr�x&|D]}	|jdj|j||�|	��q�WqXt|t��r�dj	|�}|jdj|j||�|��qXWt
|�S)Nr�controlZ	device_idZdriver�index�inet�mode�name�subnets�type�bridge_pathcost�bridge_portprioZbridge_waitport�mac_address�	hwaddress�bond�bridge�
infiniband�vlanZonZoffrzZNetwork config: ignoring %s device-level mtu:%s because ipv4 subnet-level mtu:%s provided.z    {0} {1}r)r5r6r7r8)rrr�bool�LOGZwarningr �getrrr!)
r"r+�ipv4_subnet_mtur$Z
ignore_mapZmultiline_keys�renamesr%r&�vr'r'r(�_iface_add_attrs^sN



r?FcCs�|d}|d}|dkrd}n|dkr0d|}nd|}|j�}|j||d��djf|�d	jf|�g}|r�|jd
�r�|jdjf|��|S)
Nr.r*�auto�hotplugzallow-z
# control-)�fullname�cverbz{cverb} {fullname}ziface {fullname} {inet} {mode}r3z    hwaddress {mac_address})rA)�copy�updater r;r)r"r+�render_hwaddressrBr*rCZsubst�linesr'r'r(�_iface_start_entry�s

rHcsrd}�x8|j�D�]*}|j�}|jd�r*q|jd�}|d}|dkr�|d}|jd�sdtjj||�}x�tj|�D]r�tj��}	�fdd	�|	D�}	xP|	D]H}
t	|
d
��}|j
�j�}WdQRXtjj|
�}
t||tjj
|
�|
�q�WqpWq|dk�rp|d}|jd��stjj||�}xXtj|�D]J�t	�d
��}|j
�j�}WdQRXtjj��}t||tjj
|�|��q Wq|dk�r�x8|dd�D](}||k�r�d
|i||<d||d<�q�Wq|dk�r&|dd�\}}}||k�r�d
|i||<nd||k�rtd||f��|||d<|||d<|}q|dk�r^|ddk�rH|d}n|d}|||d<q|tk�rz|d|||<q|tk�r�|||k�r�g|||<|||jdj|dd���q|jd��rzd||k�r�i||d<|dk�r0g||dd<xv|dd�D]}||ddj|��qWnH|dk�r<g||dd<x,|dd�D]}||ddj|��qXWq|jd��r�d||k�r�i||d<|tk�r�|jddd�}|d||d|<�q<|d k�rg||dd!<x,|dd�D]}||dd!j|��q�Wn�|d"k�rb|dj�d#k�rL|d||dd#<n|d||dd#<n�|d$k�r�d%||dk�r�i||dd%<|d||dd%|d<nH|d&k�r<d'||dk�r�i||dd'<|d||dd'|d<q|jd(�rd)||k�ri||d)<|jd(dd�}|d||d)|<qWx,|j�D] }d||k�rJd*||d<�qJWdS)+a}Parses the file contents, placing result into ifaces.

    '_source_path' is added to every dictionary entry to define which file
    the configration information came from.

    :param ifaces: interface dictionary
    :param contents: contents of interfaces file
    :param src_dir: directory interfaces file was located
    :param src_path: file path the `contents` was read
    N�#rrzsource-directory��/cs@g|]8}tjjtjj�|��rtjd|�dk	rtjj�|��qS)z^[a-zA-Z0-9_-]+$N)�os�path�isfiler�re�match)�.0rM)�
expanded_pathr'r(�
<listcomp>�sz*_parse_deb_config_data.<locals>.<listcomp>�r�sourcer@Z_source_pathTr"��familyz:Interface %s can only be defined once. Re-defined in '%s'.�methodr4Zether�zdns-�dnsz
dns-search�searchzdns-nameservers�nameserversZbridge_r6�Zbridge_portsZportsZ	bridge_hwZmacr1Zpathcostr2Zportpriozbond-r5F)�
splitlines�strip�
startswith�splitrLrMr�glob�listdir�open�read�abspath�_parse_deb_config_data�dirnamer�NET_CONFIG_OPTIONS�NET_CONFIG_COMMANDSr�NET_CONFIG_BRIDGE_OPTIONSr�lower�keys)�ifaces�contents�src_dir�src_pathZcurrif�lineraZoptionZparsed_src_dirZdir_contents�entry�fpZsrc_dataZ	abs_entryZnew_src_pathZabs_pathr"rWrX�valZdomainrZ
bridge_optionZbond_optionr')rRr(rg�s�














"







rgcCsi}t||ddd�t|�S)N)rprq)rg�_ifaces_to_net_config_data)Zeni_datarnr'r'r(�convert_eni_data7srwcsFi��x"|j�D�]\}}|jd�d}|�krj|dkr>d}nd}||gd��|<d|krj|d�|d<||d	d
�}|jd�r�d|d<nd
|d<|jd	�dkr�|d|d<x dD]}||kr�||||<q�Wd|k�rx8dD]0}||dkr�|d|r�|d||d|<q�W�|dj|�qWd�fdd�t��D�d�S)z�Return network config that represents the ifaces data provided.
    ifaces = _parse_deb_config_data(...)
    config = ifaces_to_net_config_data(ifaces)
    state = parse_net_config_data(config).�:r�lo�loopback�physical)r0r.r/r4r3rX)Z_orig_eni_namer0r@r*Zmanual�staticrrrr
rZr\r[Zdns_r/rJcsg|]}�|�qSr'r')rQ�d)�devsr'r(rSdsz._ifaces_to_net_config_data.<locals>.<listcomp>)�version�config)rrr
)r\r[)r�	partitionr;rr!)rnr.�dataZdevnameZdtyper#Zcopy_key�nr')r~r(rv>s2




rvc@sPeZdZdZddd�Zddd�Zdd	d
�Zddd�Zdee	e
dd
�dd�ZdS)�Rendererz@Renders network information in a /etc/network/interfaces format.NcCs6|si}|jdd�|_|jdd�|_|jdd�|_dS)N�eni_pathzetc/network/interfaces�
eni_header�
netrules_pathz(etc/udev/rules.d/70-persistent-net.rules)r;r�r�r�)�selfr�r'r'r(�__init__jszRenderer.__init__r]cCsPg}|d}|d}d}ddd�}d}|dd	krD|d
d	krDd}n|ddkr`|d
dkr`d}d}	x�dD]�}
|r||
dkr|qj|
dkr�|	d|||
||
f7}	qj|
|krj|
dk�rd||
kr�|	d7}	n |jd
�dkr�|	d7}	n|	d7}	d
|k�r$|	d||
|d
f7}	qj|	d||
||
f7}	qjW|j||	|�|j||	|�|S)a�When rendering routes for an iface, in some cases applying a route
        may result in the route command returning non-zero which produces
        some confusing output for users manually using ifup/ifdown[1].  To
        that end, we will optionally include an '|| true' postfix to each
        route line allowing users to work with ifup/ifdown without using
        --force option.

        We may at somepoint not want to emit this additional postfix, and
        add a 'strict' flag to this function.  When called with strict=True,
        then we will not append the postfix.

        1. http://askubuntu.com/questions/168033/
                 how-to-set-static-routes-in-ubuntu-server
        zpost-up route addzpre-down route delz || trueZgwr)rrr]rz0.0.0.0rz defaultz::rrz -A inet6 defaultrz%s %s %srxz	 -A inet6� z -hostz -netz %s/%sz %s %s)rrr)r;r)r��route�indentr$r	r
Zor_true�mappingZ
default_gwZ
route_line�kr'r'r(�
_render_routess<




zRenderer._render_routeFc
s6g}�jdi�}�jdd�}�jdd�}|r4d�d<|�rؐx�t|�D�]�\}}d}	|�d<|d�d<|jd	d
��d	<d}
t|�r�|
d7}
n
|jd
�}	|
�d<|ddks�|ddks�|ddkr�d�d<|dk	r�|r�dnd�d<nn|ddk�rd
�d<d�d<nN|ddk�r&d
�d<d�d<n.t|��rTd�d<|dk	�rT|�rLdnd�d<d�fdd�|D�k�rtd�d	<tt�||d�t�|�t�||	��}x*|jdg�D]}|j|j	|dd���q�W|j
|�qFWnZg}d �k�s�d!�k�r|j
d"jf���|j
d#jf���|jt�d$dd%��|j
|�|S)&Nr/z	accept-raZ	wakeonlan�gzethernet-wolr+r0r-r*r@r,�6rZdhcp4Zdhcp6zipv6_dhcpv6-statefulZdhcp�1�0�	accept_razipv6_dhcpv6-statelessZ
ipv6_slaacr|Tcsg|]}d�d|k�qS)zauto %sr.r')rQrr)r"r'r(rS�sz*Renderer._render_iface.<locals>.<listcomp>�alias)rFZroutesz    )r�zbond-masterzbond-slaveszauto {name}ziface {name} {inet} {mode}r)r+r<)r;�pop�	enumeraterrrHr)r?�extendr�rr )
r�r"rF�sectionsr/r�Zethernet_wolr+r#r<Zsubnet_inetrGr�r')r"r(�
_render_iface�sb





&
zRenderer._render_ifacec	s&dddddd�gd�}x(|j�D]}|jd�dkr tj|�}q W|j}|r`d	j|�|d
dd<|j}|r�d	j|�|d
dd
<ddddddd��g}|j|j|��xDt	|j��fdd�d�D](}|jd�dkr�q�|j|j||d��q�Wx |j
�D]}|j|j|��q�Wdjdd�|D��dS)z1Given state, emit etc/network/interfaces content.ryr{r,rzr@)r0r*)r.r0r,r/r.rr/rrrrJrY�rV�)rzr{r7r5r6r8cs�|d|dfS)Nr0r.r')r�)�orderr'r(�<lambda>sz-Renderer._render_interfaces.<locals>.<lambda>)r%)rFz

cSsg|]}dj|��qS)�
)r)rQ�sr'r'r(rS&sz/Renderer._render_interfaces.<locals>.<listcomp>r�)
Ziter_interfacesr;rD�deepcopyrrZdns_searchdomainsr�r�r!Ziter_routesrr�)	r��
network_staterFryr"r\Z
searchdomainsr�r�r')r�r(�_render_interfaces�s>zRenderer._render_interfaces)r��	templates�returncCs�tj||j�}tjtjj|��|jr,|jnd}tj	|||j
|��|jr�tj||j�}tjtjj|��tj	||j|�dd�dS)Nr]T)r$Z
preserve_mode)
r�target_pathr�rZ
ensure_dirrLrMrhr�Z
write_filer�r�Z_render_persistent_net)r�r�r��targetZfpeni�headerZnetrulesr'r'r(�render_network_state(szRenderer.render_network_state)N)r])F)F)NN)�__name__�
__module__�__qualname__�__doc__r�r�r�r�rr�dictr�r'r'r'r(r�gs
	
4
M
7
r�cCsFd}t||dd�d�}|sd}|jd�s0|d7}|j||d�}||S)Nzetc/network/interfaces)r�r�r�)r�r]r�)rF)r��endswithr�)r�r�rFr�rror'r'r(�network_state_to_eni=s

r�cCsTdddg}ddg}x |D]}tj|||d�sdSqWtj|d�}tjj|�sPdSd	S)
NZifqueryZifupZifdownz/sbinz	/usr/sbin)r[r�Fzetc/network/interfacesT)rZwhichr�rLrMrN)r�Zexpectedr[�pZenir'r'r(�	availableQs

r�)F)NF)N)rDrbZloggingrLrOZtypingrZ	cloudinitrrZ
cloudinit.netrrrZcloudinit.net.network_staterZ	getLoggerr�r:rjrkrir)r?rHrgrwrvr�r�r�r'r'r'r(�<module>sr
<
)W


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