Current File : //lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyc
�
oB�]c@sddlZddlZddlmZddlmZddlmZddlmZej	e
�Zdejfd��YZ
dd�Zdd	�Zdd
�Zd�Zd�Zd
e
fd��YZe
ejffeejejffgZd�ZdS(i����N(tlog(teni(tsources(tutiltDataSourceNoCloudcBskeZdZd�Zd�Zd�Zd�Zed��Zd�Z	d�Z
d�Zed	��ZRS(
tNoCloudcCsktjj||||�d|_tjj|jd�tjj|jd�g|_	d|_d|_
dS(Ntnocloudsnocloud-nett/sfile://(Rsfile://(Rt
DataSourcet__init__tNonetseedtostpathtjointseed_dirt	seed_dirstsupported_seed_starts(tselftsys_cfgtdistrotpaths((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyR	s		cCs)tjj|�}d||j|jfS(Ns%s [seed=%s][dsmode=%s](RRt__str__Rtdsmode(Rtroot((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyR"scCs�tj�rHgd|d|gD]}tjj|�r!|^q!}n�tjdd�tjdd�tjd�}|jtjd��tjd|j��}|jtjd|j���t	t
|�t
|�@�}|jd	t�|S(
Ns
/dev/msdosfs/s
/dev/iso9660/R
s/dev/sr0s/dev/sr1s	TYPE=vfatsTYPE=iso9660sLABEL=%streverse(
Rt
is_FreeBSDRR
texiststfind_devs_withtextendtuppertlowertlisttsettsorttTrue(Rtlabeltptdevlisttfslistt
label_list((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyt_get_devices&s! cCs�idd6|jd6}g}iid6dd6dd6dd6}yTi}tjd	�}|r�t||�r�|jd
�t|i|d6�}nWn"tk
r�tjt	d�t
SXy<i}t|�r�|jd�t|i|d6�}nWn"tk
rtjt	d
�t
SXiddgd6ddgd6}xh|jD]]}yCtj||�}|j|�t	j
d|�t||�}PWqCtk
r�qCXqCW|jjd�r�|jd�|jd|dd<nd|jkrd|jkrt||j�}|jd�nd�}	|jjdd�}
|
dk	r:x�|j|
�D]�}y�t	j
d|�ytj||	|�}Wn'tk
r�t	jd||
�wUnXt||�}t	j
d|�|j|�PWqUtk
r}|jtjkr3�q3qUtjk
r2tjt	d|�qUXqUWnt|�dkrPt
Sd|dkr |dd}
t
}x*|jD]}|
j|�r~|}Pq~q~W|s�t	j
d|
|�t
Stj|
dd�\}}t	j
d|
�tj|d|g�|d<||d<|j|
�ntj|d|g�|d<|j|djd�g�|_|jtjkr�t	j
d||j�t
Sd j |�|_!|d|_"|d|_#|d|_$|d|_%|djd!�|_&t'S("NRsinstance-idRs	meta-datats	user-datasvendor-datasnetwork-configssystem-serial-numbertdmisUnable to parse dmi datatcmdlines!Unable to parse command line datatrequiredtoptionalsUsing seeded data from %stseedfromtds_config_seedfromt	ds_configcSstj||�S(N(Rtpathprefix2dict(tmptdata((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyt_pp2d_callbackustfs_labeltcidatasAttempting to use data from %ss)device %s with label=%s not a valid seed.sUsing data from %ss(Failed to mount %s when looking for datais Seed from %s not supported by %sttimeoutsUsing seeded cache data from %ss&%s: not claiming datasource, dsmode=%st,snetwork-interfaces((RR
Rt
read_dmi_datatload_cmdline_datatappendt_merge_new_seedt	ExceptiontlogexctLOGtFalseRR2tdebugt
ValueErrortds_cfgtgetR)tmount_cbtwarningtOSErrorterrnotENOENTtMountFailedErrortlenRt
startswithtread_seededt
mergemanydictt_determine_dsmodeRtDSMODE_DISABLEDRRtmetadatatuserdata_rawtvendordata_rawt_network_configt_network_eniR#(Rtdefaultstfoundtmydatatmdtserialtpp2d_kwargsR
tseededR5R$tdevteR/t	seedfoundtprototmd_seedtud((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyt	_get_data:s�








	

	

	







cCsIt|d�sd|_n|jsBtj�r6dnd|_n|jS(Nt_platform_typetlxdR(thasattrR
ReRtis_lxd(R((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyt
platform_type�s
	cCstjS(s=Return unknown when 'cloud-name' key is absent from metadata.(RtMETADATA_UNKNOWN(R((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyt_get_cloud_name�scCs2|jjd�rd}nd}d||jfS(s/Return the subplatform metadata source details.s/devsconfig-disksseed-dirs%s (%s)(RRM(Rtsubplatform_type((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyt_get_subplatform�s	cCsQ|j�}|sdSt|d|jg�}td|�}|sGdS||kS(NRtdirs(tget_instance_idR
tgetattrRt_quick_read_instance_id(RRtcurrentRntquick_id((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pytcheck_instance_id�scCs@|jdkr9|jdk	r9tj|j�|_q9n|jS(N(RUR
RVRtconvert_eni_data(R((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pytnetwork_config�s(
t__name__t
__module__tdsnameR	RR)RdtpropertyRiRkRmRtRv(((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyRs				�				cCs�|dkrg}nd}i}t|�rA||krA||Sxw|D]o}|dkr`qHnyCtj|ddg�}tj|d�}||kr�||SWqHtk
r�qHXqHWdS(Nsinstance-idR-s	meta-data(R
R;RR2t	load_yamlRC(Rntiid_keytfilltdR4RZ((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyRq�s"	

cCshdtjfdtjfg}xC|D];\}}t|||�r%d|kr\||d<ntSq%WtS(Ns
ds=nocloudsds=nocloud-netR(RtDSMODE_LOCALtDSMODE_NETWORKtparse_cmdline_dataR#RA(R}R,tpairstidstrR((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyR;s
cCsc|dkrtj�}nd|}d||kpBd||ksItSd}x8|j�D]*}|j|�r\|jdd�}q\q\W|djd�}t|�dkr�|d}nd
}idd6d	d
6dd6}x|D]w}|dkr�q�ny|jdd�\}	}
Wntk
r7|}	d}
nX|	|krQ||	}	n|
||	<q�WtS(Ns %s s %s;R*t=it;slocal-hostnamethsinstance-idtiR/ts((	R
Rtget_cmdlineRAtsplitRMRLR>R#(tds_idR}R,targlinettokttmptkvpairsts2ltitemtktv((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyR�s4
 




cCst�}|jd|�}||kr+|Sd}t|t�sWtj|d|�|Stt|j���dkr�tj|d|�|S|jd�dkr�tj|d|�n5t	d|kd	|kf�s�tj|d
|�|Stj|d|�|S(sMIf network-config contains top level 'network' key, then remove it.

    Some providers of network configuration may provide a top level
    'network' key (LP: #1798117) even though it is not necessary.

    Be friendly and remove it if it really seems so.

    Return the original value if no change or the updated value if changed.tnetworks.Top level network key in network-config %s: %sswas not a dictishad multiple top level keystconfigtdisabledswas config/disabledtversions!but missing 'config' or 'version's#fixed by removing shifting network.(
tobjectREt
isinstancetdictR@RBRLR tkeystall(tcfgtnullvaltnetwork_valtbmsg((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyt_maybe_remove_top_networkBs$		cCs�|j�}|jdi�}t|dt�sGtj|d�}ntj|d|g�|d<|jd�r�ttj|jd���|d<nd|kr�|d|d<nd|kr�|d|d<n|S(Ns	meta-datasnetwork-configs	user-datasvendor-data(tcopyRER�R�RR{ROR�(tcurR]trettnewmd((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyR=_s"tDataSourceNoCloudNetcBseZd�ZRS(cCs#tj||||�d|_dS(Nshttp://shttps://sftp://(shttp://shttps://sftp://(RR	R(RRRR((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyR	ss(RwRxR	(((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyR�rscCstj|t�S(N(Rtlist_from_dependstdatasources(tdepends((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pytget_datasource_list�s(RIRt	cloudinitRtloggingt
cloudinit.netRRRt	getLoggerRwR@RRR
RqR;R�R�R=R�tDEP_FILESYSTEMtDEP_NETWORKR�R�(((sG/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceNoCloud.pyt<module>s �(