404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.222.120.124: ~ $
3

\�me�2�@sdZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZeje
�ZGdd�de	j�ZGdd�de�Zd#d
d�Zdd
�Zdd�Zd$dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�de�Zee	jffee	je	jfffZdd �Z d!d"�Z!dS)%zZCloud-Init DataSource for OVF

This module provides a cloud-init datasource for OVF data.
�N)�minidom)�safeyaml�sources�subp�utilc@sLeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	e
dd��ZdS)�
DataSourceOVFZOVFcCsFtjj||||�d|_tjj|jd�|_d|_i|_	d|_
d|_dS)NZovf�/�file://)rr	)r�
DataSource�__init__�seed�os�path�join�seed_dir�environment�cfg�supported_seed_starts�_network_config)�self�sys_cfg�distro�paths�r�#/usr/lib/python3.6/DataSourceOVF.pyrszDataSourceOVF.__init__cCstjj|�}d||jfS)Nz%s [seed=%s])rr
�__str__r)r�rootrrrr'szDataSourceOVF.__str__cCs�g}i}d}d}ddi}t|jj�\}}|r^tjj|jj|�}t|�\}}}	||_|j|�npdt	fdt
fg}
d}x|
D]\}}|�}|rxPqxW|r�t|d�\}}}	||_d|kr�|dr�|d|_|j|�t|�dkr�d	Sd
|ko�|d
�rp|d
}
d	}x"|j
D]}|
j|��r|}P�qW|�s8tjd|
|�d	Stj|
dd�\}}}tjd
|
�tj||g�}|j|
�tj||g�}dj|�|_||_||_||_|	|_dS)N�zinstance-idz	iid-dsovfzcom.vmware.guestInfoZisoTznetwork-configrF�seedfromz Seed from %s not supported by %s)ZtimeoutzUsing seeded cache data from %s�,)�get_ovf_envrrr
rr�read_ovf_environmentr�append�transport_vmware_guestinfo�transport_iso9660r�lenr�
startswith�LOG�debugrZread_seededZ
mergemanydictr�metadataZuserdata_rawZvendordata_rawr)r�found�md�udZvdZdefaultsZseedfile�contentsrrZnp�nameZ	transfuncrZ	seedfound�protoZmd_seedrrr�	_get_data+s^



zDataSourceOVF._get_datacCs
d|jS)Nzovf (%s))r)rrrr�_get_subplatformmszDataSourceOVF._get_subplatformcCs0d|jkrgS|jd}t|t�r&|S|gSdS)Nzpublic-keys)r)�
isinstance�list)rZpksrrr�get_public_ssh_keysps


z!DataSourceOVF.get_public_ssh_keyscCs|jS)N)r)rrrr�get_config_obj|szDataSourceOVF.get_config_objcCs|jS)N)r)rrrr�network_configszDataSourceOVF.network_configN)�__name__�
__module__�__qualname__Zdsnamerrr0r1r4r5�propertyr6rrrrrs	Brc@seZdZdd�ZdS)�DataSourceOVFNetcCs,tj||||�tjj|jd�|_d|_dS)Nzovf-net�http://�https://)r<r=)rrr
rrrr)rrrrrrrr�szDataSourceOVFNet.__init__N)r7r8r9rrrrrr;�sr;FcCst|�}i}i}d}dg}ddddg}dg}x�|j�D]�\}	}
|	dkrJd}	|	|kr\|
||	<q6|	|krn|
||	<q6|	|kr�|r�y$tj|
j��}t|�jd�||	<Wq�tk
r�tj	d	�Yq�Xq6|	d
kr6ytj|
j��}Wq6tk
r�|
j�}Yq6Xq6W|||fS)NZpasswordrzlocal-hostnamezpublic-keyszinstance-idznetwork-configZhostnameZnetworkz%Ignore network-config in wrong formatz	user-data)
�get_properties�items�base64Z	b64decode�encode�safeload_yaml_or_dict�get�	Exceptionr'r()r-Zread_network�propsr+rr,Z	cfg_propsZmd_propsZ
network_propsZprop�valr6rrrr!�s4

r!cCsfd}x\|D]T}tjj||�}tjj|�r
ytj|�}||fStk
r\tjtd|�Yq
Xq
WdS)	N�ovf-env.xml�ovf_env.xml�OVF_ENV.XML�OVF-ENV.XMLzFailed loading ovf file %sF)rGrHrIrJ)NF)	r
rr�isfilerZ	load_filerD�logexcr')�dirnameZ	env_namesZfnameZfull_fnr-rrrr �s

r cCs�|sdSt|t�std|��tjj|�}|jd�rB|jd�d
}|jd�r\|jd�d}n|j	d�dkrndS|svdSd}tj
jd|�}tj
|�}|j|�d	k	S)z�Test if devname matches known list of devices which may contain iso9660
       filesystems.

    Be helpful in accepting either knames (with no leading /dev/) or full path
    names, but do not allow paths outside of /dev/, like /dev/foo/bar/xxx.
    Fz Unexpected input for devname: %sz/dev/�rrz^(sr[0-9]+|hd[a-z]|xvd.*)ZCLOUD_INIT_CDROM_DEV_REGEXN���rO)r2�str�
ValueErrorr
r�normpathr&�	partition�split�count�environrC�re�compile�match)ZdevnameZ
default_regexZ
devname_regexZcdmatchrrr�maybe_cdrom_device�s"



rZTc
Cs�tj�}xT|j�D]H\}}|d}|dkr0|r0qt|�s:q|d}t|�\}}|dk	r|SqW|rhd}nd}dd�tj|r�d|nd�D�}	xV|	D]N}ytj|t|d�\}}Wn$tjk
r�tj	d	|�w�YnX|dk	r�|Sq�WdS)
N�fstypeZiso9660Z
mountpointFcSsg|]}t|�r|�qSr)rZ)�.0�devrrr�
<listcomp>�sz%transport_iso9660.<locals>.<listcomp>zTYPE=%s)�mtypez%s not mountable as iso9660)
r�mountsr?rZr Zfind_devs_withZmount_cbZMountFailedErrorr'r()
Zrequire_isor`r]�infor[ZmpZ_fnamer-r_Zdevsrrrr$�s2
r$cCs ||g}tj|�\}}|||fS)N)r)�rpctool�arg�cmd�stdout�stderrrrr�exec_vmware_rpctoolsrgcCs"|d|g}tj|�\}}|||fS)Nz--cmd)r)rbrcrdrerfrrr�
exec_vmtoolsds
rhcCsd\}}tjd�}tjd�}|r6|t}}tjd|�|rT|sH|t}}tjd|�|sftjd�dSdd�}y
|||�Stjk
�r}z�|r�||kr�tjtd|�dS|s�tj	d	�dSytj	d
�||t�Stjk
�r}ztjtd|�WYdd}~XnXWYdd}~XnXdS)N�vmtoolsdzvmware-rpctoolzdiscovered vmware-rpctool: %szdiscovered vmtoolsd: %szno rpctool discoveredcSs|tjd|�y(||d�\}}}|r&|Stjd|�dStjk
rv}z$|jdkrbtjd||j�|�WYdd}~XnXdS)Nzquery guestinfo.ovfEnv with %szinfo-get guestinfo.ovfEnvz!cmd %s exited 0 with empty stdoutrNz%s exited with code %d)r'rar(r�ProcessExecutionErrorZ	exit_codeZwarning)rb�
rpctool_fnrdre�_�errorrrr�query_guestinfo+s
z3transport_vmware_guestinfo.<locals>.query_guestinfoz+vmtoolsd failed to get guestinfo.ovfEnv: %sz$vmtoolsd fallback option not presentzfallback to vmtoolsd)NN)
rZwhichrgr'r(rhrjrrLra)rbrkriZvmware_rpctoolrnrmrrrr#s>










.r#cCs6g}|j�s|Sx |jD]}||�r|j|�qW|S)N)�
hasChildNodesZ
childNodesr")ZnodeZfilter_func�retZchildrrr�
find_childYsrqc	Cs�tj|�}|jjdkrtd��|jj�s0td��d}t|jdd��}t|�dkrXtd��i}t|dd	d��}x4|D],}|jj	|d
�j
}|jj	|d�j
}|||<qtW|S)NZEnvironmentzNo Environment NodezNo Child Nodesz)http://schemas.dmtf.org/ovf/environment/1cSs
|jdkS)NZPropertySection)�	localName)�nrrr�<lambda>psz get_properties.<locals>.<lambda>rzNo 'PropertySection'scSs
|jdkS)NZProperty)rr)rsrrrrtxs�key�value)rZparseStringZdocumentElementrr�XmlErrorrorqr%Z
attributesZgetNamedItemNSrv)	r-ZdomZenvNsURIZpropSectionsrEZ	propElems�elemrurFrrrr>cs$


r>c@seZdZdS)rwN)r7r8r9rrrrrw�srwcCstj|t�S)N)rZlist_from_depends�datasources)Zdependsrrr�get_datasource_list�srzcCs|siStj|�S)z�
    The meta data could be JSON or YAML. Since YAML is a strict superset of
    JSON, we will unmarshal the data as YAML. If data is None then a new
    dictionary is returned.
    )r�load)�datarrrrB�srB)F)T)"�__doc__r@Zloggingr
rWZxml.domrZ	cloudinitrrrrZ	getLoggerr7r'r
rr;r!r rZr$rgrhr#rqr>rDrwZDEP_FILESYSTEMZDEP_NETWORKryrzrBrrrr�<module>s.
i	

)
&E
 


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