404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.139.81.212: ~ $
3

\�me?�@s�ddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	m
Z
mZmZej
e�ZdZdZdgZGdd�de
j�ZGdd	�d	e�ZGd
d�de�ZGdd
�d
�Zdd�Zdd�Zddd�Zddd�Zdd�ZeZee
jffgZ dd�Z!dS)�N)�
atomic_helper�net�sources�subp�utilziid-dsopennebulaZnobodyz
context.shc@sFeZdZdZdd�Zdd�Zdd�Zdd	�Zed
d��Z	dd
d�Z
dS)�DataSourceOpenNebulaZ
OpenNebulacCs.tjj||||�d|_tjj|jd�|_dS)NZ
opennebula)r�
DataSource�__init__�seed�os�path�join�seed_dir)�selfZsys_cfg�distro�paths�r�*/usr/lib/python3.6/DataSourceOpenNebula.pyr	$szDataSourceOpenNebula.__init__cCstjj|�}d||j|jfS)Nz%s [seed=%s][dsmode=%s])rr�__str__r
�dsmode)r�rootrrrr)szDataSourceOpenNebula.__str__c
Cs�dti}d}d}t}d|jkr*|jjd�}|jg}|jt��x�|D]�}yLtjj	|j�rjt
||j|d�}n(|jd�r�t
jt
||jd�}tj||�}WnZtk
r�wDYnFtk
r�}z
|�WYdd}~Xn"tjk
r�tjd|�YnX|rD|}tjd|�PqDW|�sdS|d	}	tj|	|g�}	|j|jd
�|jjd�g�|_|jtjk�rZdS||_|jd�|_|	|_|jd
�|_dS)Nzinstance-id�	parseuser)�asuserz/dev)rrz%s was not mountablezfound datasource in %sF�metadataZDSMODErznetwork-interfaces�userdataT) �DEFAULT_IID�DEFAULT_PARSEUSERZds_cfg�getr�extend�find_candidate_devsrr�isdir�read_context_disk_dirr�
startswith�	functools�partialrZmount_cb�NonContextDiskDir�BrokenContextDiskDirZMountFailedError�LOG�warning�debugZ
mergemanydictZ_determine_dsmoderrZDSMODE_DISABLEDr
�networkrZuserdata_raw)
rZdefaults�resultsr
rZ
candidatesZcdevZpartially_applied_func�excZmdrrr�	_get_data-sT



zDataSourceOpenNebula._get_datacCs$|j|jkrd}nd}d||jfS)z/Return the subplatform metadata source details.zseed-dirzconfig-diskz%s (%s))rr
)rZsubplatform_typerrr�_get_subplatformjsz%DataSourceOpenNebula._get_subplatformcCs|jdk	r|jSdSdS)N)r*)rrrr�network_configrs
z#DataSourceOpenNebula.network_configFcCs.|dkr|jtjkrd}nd}tjj|||�S)NTF)rrZDSMODE_NETWORKr�get_hostname)rZfqdnZ
resolve_ipZ
metadata_onlyrrrr0ys
z!DataSourceOpenNebula.get_hostnameN)FFF)�__name__�
__module__�__qualname__Zdsnamer	rr-r.�propertyr/r0rrrrr s=rc@seZdZdS)r%N)r1r2r3rrrrr%�sr%c@seZdZdS)r&N)r1r2r3rrrrr&�sr&c@speZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zddd�Z
dd�ZdS)�OpenNebulaNetworkNcCs�||_|dkrt|�}tjdd�t|j�dd�d�D��|_i|_x8|j�D],\}}tj	d|�}|rL|j
d�|j|j�<qLWdS)NcSsg|]}|�qSrr)�.0�krrr�
<listcomp>�sz.OpenNebulaNetwork.__init__.<locals>.<listcomp>cSstj|d�S)N�)rZnatural_sort_key)r7rrr�<lambda>�sz,OpenNebulaNetwork.__init__.<locals>.<lambda>)�keyz
^(.+)_MAC$r9)�context�get_physical_nics_by_mac�collections�OrderedDict�sorted�items�ifaces�context_devname�re�match�group�lower)rr<rZsystem_nics_by_macr7�v�mrrrr	�szOpenNebulaNetwork.__init__cCs"djdd�|jd�dd�D��S)N�.cSsg|]}tt|d���qS)�)�str�int)r6�crrrr8�sz,OpenNebulaNetwork.mac2ip.<locals>.<listcomp>�:�)r
�split)r�macrrr�mac2ip�szOpenNebulaNetwork.mac2ipcCs\i}|j|dd�j�}|j|jjdd�j��|r:||d<|j|dd�j�}|rX||d<|S)N�dns�ZDNS�	addresses�
search_domain�search)�	get_fieldrQrr<r)r�dev�nameserversrTrWrrr�get_nameservers�sz!OpenNebulaNetwork.get_nameserverscCs|j|d�S)N�mtu)rY)rrZrrr�get_mtu�szOpenNebulaNetwork.get_mtucCs|j|d|j|��S)NZip)rYrS)rrZrRrrr�get_ip�szOpenNebulaNetwork.get_ipcCs<g}|j|d�}|r|j|�|j|d�}|r8|j|�|S)N�ip6�ip6_ula)rY�append)rrZ�
addresses6r`rarrr�get_ip6�s

zOpenNebulaNetwork.get_ip6cCs|j|dd�S)NZip6_prefix_lengthZ64)rY)rrZrrr�get_ip6_prefix�sz OpenNebulaNetwork.get_ip6_prefixcCs|j|d�S)N�gateway)rY)rrZrrr�get_gateway�szOpenNebulaNetwork.get_gatewaycCs|j|d|j|d��S)NZip6_gateway�gateway6)rY)rrZrrr�get_gateway6�szOpenNebulaNetwork.get_gateway6cCs|j|dd�S)N�maskz
255.255.255.0)rY)rrZrrr�get_mask�szOpenNebulaNetwork.get_maskcCs*|jjdj||f�j��}|dkr&|S|S)z�return the field name in context for device dev.

        context stores <dev>_<NAME> (example: eth0_DOMAIN).
        an empty string for value will return default.�_NrU)NrU)r<rr
�upper)rrZ�name�default�valrrrrY�s
zOpenNebulaNetwork.get_fieldcs<i}d|d<i|d<i}�x|jj�D�]\}}|j�}|jj||�}i}d|i|d<g|d<|j|�}ttj|��}|dj	|j
||�d|�|j|�}	|	r�|j|��|dj
�fdd	�|	D��|j|�}
|
r�|
|d
<|j|�}|r�||d<|j|�}|�r||d<|j|�}
|
�r$|
|d
<|||<q&W||d<|S)NrP�version�	ethernetsZ
macaddressrErV�/csg|]}|d��qS)rsr)r6�i)�prefix6rrr8�sz.OpenNebulaNetwork.gen_conf.<locals>.<listcomp>Zgateway4rhr[r])rBrArGrCrrkrLrZipv4_mask_to_net_prefixrbr_rdrerrgrir\r^)rZnetconfrrrRrZZc_devZdevconfrj�prefixrcrfrhr[r]r)rur�gen_conf�sB






zOpenNebulaNetwork.gen_conf)N)N)r1r2r3r	rSr\r^r_rdrergrirkrYrwrrrrr5�s


r5cCsHg}x>dD]6}tj|�}|j�x|D]}||kr&|j|�q&Wq
W|S)zE
    Return a list of devices that may contain the context disk.
    �
LABEL=CONTEXT�LABEL=CDROM�TYPE=iso9660)rxryrz)rZfind_devs_with�sortrb)Zcombined�f�devs�drrrrs


rcCs
dd|gS)NZsudoz-ur)�userrrr�switch_user_cmd)sr�cCs�t|t�r|g}n|dkr"ddg}|dkr.t}dd�tjdD�}|}|dkrV|}g}djd�}d	d
�}d|||�d|d||�d}	g}
|dk	r�||�}
|
j|�tj|
|	d
�\}}d}
i}i}d}|dd�}x�|jd�D]�}yT|jdd�\}}||k�r|||<n,||
k�r>||k�s6|j	|�|k�r>|||<Wq�t
k
�r�|dk�r^�|dk�rn|}n||k�r||}Yq�Xq�W|S)N�bashz-ecSsg|]}d|�qS)z${!%s*}r)r6�xrrrr8;sz&parse_shell_config.<locals>.<listcomp>rl�
�__v="";rUcSsdjdddj|�dddf�S)Nr�zprintf "%s\0" _start_zfor __v in %s; do� z%   printf "%s=%s\0" "$__v" "${!__v}";�donerU)r
)Zvlistrrr�
varprinterIsz&parse_shell_config.<locals>.varprinterz
unset IFS
z{
%s

:
} > /dev/null
)�data�
EPOCHREALTIME�EPOCHSECONDS�RANDOM�LINENO�SECONDS�SRANDOM�__vrr9��=Z_start_)r�rU)r�r�r�r�r�rlr�r����)�
isinstancerLr��stringZ
ascii_lettersr
rrrQr�
ValueError)�contentZkeylistr�rZswitch_user_cbZallvarsZ
keylist_inZsetupr�Zbcmd�cmd�outputZ_errorZexcludedZpreset�ret�target�liner;rprrr�parse_shell_config-sb
(






r�c'Cs�i}x.tD]&}tjj||�}tjj|�r
|||<q
W|sHtd|df��i}did�}d|k�r<|dk	r�ytj|�Wn4tk
r�}zt	dj
|d��|�WYdd}~XnXy(tjj|d�}	tj|	�}
t
|
|d�}Wndtjk
�r}zt	d	|�|�WYdd}~Xn2tk
�r8}ztd
|�|�WYdd}~XnXntd��|�sN|S||d<d}d
|k�rjd
}nd|k�rxd}|�r�|j|�j�}dd�|D�|dd<x*d!D]"}
|
|k�r�||
|dd<P�q�Wd|k�r�|d|d<nd|k�r�|d|d<d|k�rZ|jd|jd��}|dk�rZytj|d�|d<Wn tk
�rXtjd�YnXdd�|D�}|�r�t||�}|j�|d <|S)"z�
    read_context_disk_dir(source_dir):
    read source_dir and return a tuple with metadata dict and user-data
    string populated.  If not a valid dir, raise a NonContextDiskDir
    z%s: %szno files foundN)rrz
context.shz'configured user '{user}' does not exist)r)rzError processing context.sh: %szError reading context.sh: %szMissing context.shrZSSH_KEYZSSH_PUBLIC_KEYcSs$g|]}t|�r|jd�r|�qS)�#)�lenr")r6r�rrrr8�sz)read_context_disk_dir.<locals>.<listcomp>zpublic-keys�SET_HOSTNAME�HOSTNAME�	PUBLIC_IP�	IP_PUBLIC�ETH0_IPzlocal-hostnameZ	USER_DATArZUSERDATAZUSERDATA_ENCODINGZUSER_DATA_ENCODING�base64z"Failed base64 decoding of userdatacSsg|]}tjd|�r|�qS)z
^ETH\d+_IP.*$)rDrE)r6r7rrrr8�sznetwork-interfaces)r�r�r�r�r�)�CONTEXT_DISK_FILESrrr
�isfiler%�pwd�getpwnam�KeyErrorr&�formatrZ	load_filer�rZProcessExecutionError�IOErrorr�
splitlinesrZb64d�	TypeErrorr'r(r5rw)Z
source_dirrr�foundZaf�fnr<r+�err�Zssh_key_var�linesr7�encodingZipaddr_keysZonetrrrr!�s~












r!cs"tj�}t�fdd�|j�D��S)Ncs$g|]\}}�jj|�r||f�qSr)Z
networkingZis_physical)r6rI�n)rrrr8�sz,get_physical_nics_by_mac.<locals>.<listcomp>)rZget_interfaces_by_mac�dictrA)rr}r)rrr=�sr=cCstj|t�S)N)rZlist_from_depends�datasources)Zdependsrrr�get_datasource_list	sr�)NNNN)N)"r>r#Zloggingrr�rDr�Z	cloudinitrrrrrZ	getLoggerr1r'rrr�rr�	Exceptionr%r&r5rr�r�r!r=ZDataSourceOpenNebulaNetZDEP_FILESYSTEMr�r�rrrr�<module>s0
b
j
`

Filemanager

Name Type Size Permission Actions
DataSourceAkamai.cpython-36.opt-1.pyc File 8.18 KB 0644
DataSourceAkamai.cpython-36.pyc File 8.18 KB 0644
DataSourceAliYun.cpython-36.opt-1.pyc File 3.22 KB 0644
DataSourceAliYun.cpython-36.pyc File 3.22 KB 0644
DataSourceAltCloud.cpython-36.opt-1.pyc File 6.74 KB 0644
DataSourceAltCloud.cpython-36.pyc File 6.74 KB 0644
DataSourceAzure.cpython-36.opt-1.pyc File 47.95 KB 0644
DataSourceAzure.cpython-36.pyc File 47.95 KB 0644
DataSourceBigstep.cpython-36.opt-1.pyc File 1.84 KB 0644
DataSourceBigstep.cpython-36.pyc File 1.84 KB 0644
DataSourceCloudSigma.cpython-36.opt-1.pyc File 3.62 KB 0644
DataSourceCloudSigma.cpython-36.pyc File 3.62 KB 0644
DataSourceCloudStack.cpython-36.opt-1.pyc File 5.97 KB 0644
DataSourceCloudStack.cpython-36.pyc File 5.97 KB 0644
DataSourceConfigDrive.cpython-36.opt-1.pyc File 8.18 KB 0644
DataSourceConfigDrive.cpython-36.pyc File 8.18 KB 0644
DataSourceDigitalOcean.cpython-36.opt-1.pyc File 3.65 KB 0644
DataSourceDigitalOcean.cpython-36.pyc File 3.65 KB 0644
DataSourceEc2.cpython-36.opt-1.pyc File 23.49 KB 0644
DataSourceEc2.cpython-36.pyc File 23.49 KB 0644
DataSourceExoscale.cpython-36.opt-1.pyc File 5.92 KB 0644
DataSourceExoscale.cpython-36.pyc File 5.92 KB 0644
DataSourceGCE.cpython-36.opt-1.pyc File 9.83 KB 0644
DataSourceGCE.cpython-36.pyc File 9.93 KB 0644
DataSourceHetzner.cpython-36.opt-1.pyc File 3.78 KB 0644
DataSourceHetzner.cpython-36.pyc File 3.78 KB 0644
DataSourceIBMCloud.cpython-36.opt-1.pyc File 12.44 KB 0644
DataSourceIBMCloud.cpython-36.pyc File 12.44 KB 0644
DataSourceLXD.cpython-36.opt-1.pyc File 13.31 KB 0644
DataSourceLXD.cpython-36.pyc File 13.31 KB 0644
DataSourceMAAS.cpython-36.opt-1.pyc File 11.86 KB 0644
DataSourceMAAS.cpython-36.pyc File 11.86 KB 0644
DataSourceNWCS.cpython-36.opt-1.pyc File 3.77 KB 0644
DataSourceNWCS.cpython-36.pyc File 3.77 KB 0644
DataSourceNoCloud.cpython-36.opt-1.pyc File 7.97 KB 0644
DataSourceNoCloud.cpython-36.pyc File 7.97 KB 0644
DataSourceNone.cpython-36.opt-1.pyc File 1.47 KB 0644
DataSourceNone.cpython-36.pyc File 1.47 KB 0644
DataSourceOVF.cpython-36.opt-1.pyc File 9.15 KB 0644
DataSourceOVF.cpython-36.pyc File 9.15 KB 0644
DataSourceOpenNebula.cpython-36.opt-1.pyc File 11.75 KB 0644
DataSourceOpenNebula.cpython-36.pyc File 11.75 KB 0644
DataSourceOpenStack.cpython-36.opt-1.pyc File 7.91 KB 0644
DataSourceOpenStack.cpython-36.pyc File 7.91 KB 0644
DataSourceOracle.cpython-36.opt-1.pyc File 10.99 KB 0644
DataSourceOracle.cpython-36.pyc File 10.99 KB 0644
DataSourceRbxCloud.cpython-36.opt-1.pyc File 7.19 KB 0644
DataSourceRbxCloud.cpython-36.pyc File 7.19 KB 0644
DataSourceScaleway.cpython-36.opt-1.pyc File 10.84 KB 0644
DataSourceScaleway.cpython-36.pyc File 10.84 KB 0644
DataSourceSmartOS.cpython-36.opt-1.pyc File 24.51 KB 0644
DataSourceSmartOS.cpython-36.pyc File 24.51 KB 0644
DataSourceUpCloud.cpython-36.opt-1.pyc File 4.36 KB 0644
DataSourceUpCloud.cpython-36.pyc File 4.36 KB 0644
DataSourceVMware.cpython-36.opt-1.pyc File 23.66 KB 0644
DataSourceVMware.cpython-36.pyc File 23.66 KB 0644
DataSourceVultr.cpython-36.opt-1.pyc File 3.44 KB 0644
DataSourceVultr.cpython-36.pyc File 3.44 KB 0644
__init__.cpython-36.opt-1.pyc File 30.52 KB 0644
__init__.cpython-36.pyc File 30.52 KB 0644