Current File : //lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyc
�
oB�]c@s<ddlZddlmZddlmZddlmZddlmZddlm	Z	ddl
mZeje
�ZdZd	Zied
6ZdZdZdZed�eD��Zdejejfd��YZd�Zd�Zded�Zd�Zedd�Z eZ!eej"ffgZ#d�Z$dS(i����N(tlog(tsources(tutil(teni(tget_ibm_platform(t	openstacksiid-dsconfigdrivetpasssinstance-idtvfattiso9660sconfig-2sCONFIG-2tsrtcdccs5|]+}tdd�D]}d||fVqqdS(iis	/dev/%s%sN(trange(t.0tzti((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pys	<genexpr>stDataSourceConfigDrivecBsYeZdZd�Zd�Zd�Zd�Zed��Zed��Z	d�Z
RS(tConfigDrivecCs�tt|�j|||�d|_tjj|jd�|_d|_	d|_
d|_tj
|_d|_d|_i|_dS(Ntconfig_drive(tsuperRt__init__tNonetsourcetostpathtjointseed_dirtversiontec2_metadatat_network_configRtUNSETtnetwork_jsontnetwork_enit
known_macstfiles(tselftsys_cfgtdistrotpaths((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR's						cCs@tjj|�}d||j|jf}|d|j7}|S(Ns%s [%s,ver=%s]s[source=%s](Rt
DataSourcet__str__tdsmodeRR(R"troottmstr((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR'3scCsMd}i}i}xp|jdfD]_}tjj|�s@q"nyt|�}|}PWq"tjk
r�tj	t
d|�q"Xq"W|s`|jjd�}x�t
d|�D]�}yLtj�r�|jd�r�d}nd}tj|td|�}|}WnMtjk
rn:tjk
r(n'tjk
rNtj	t
d|�nX|r�Pq�q�Wn|sjtS|jd	i�}tj|tg�}|j|jd
�|jjd
�|ddkr�tjndg�|_|jtjkr�tSt|j�}|d
}	||	kr=t|d|jd|jtjk�n|jtjkrit
j d||j�tS||_!||_"|jd�|_#|jd�|_$|d|_%|j&j'|jdi��|jd�}
|
|_(ytj)|
�|_*Wn,t+k
r$}t
j,d|�d|_*nX|jd�|_-|jd�|_.t/S(Ns
/config-drives#Failed reading config drive from %stdatasource_listtdslists/dev/cdtcd9660tmtypesBroken config drive: %stmetadataR(Risinstance-idR$tnetworks&%s: not claiming datasource, dsmode=%ssec2-metadatatuserdataR!t
vendordatas"Invalid content in vendor-data: %stnetwork_configtnetworkdata(0RRRRtisdirtread_config_driveRtNonReadableRtlogexctLOGR#tgettfind_candidate_devst
is_FreeBSDt
startswithtmount_cbtMountFailedErrortBrokenMetadatatFalset
mergemanydicttDEFAULT_METADATAt_determine_dsmodetds_cfgRtDSMODE_PASSR(tDSMODE_DISABLEDtget_previous_iidR%t
on_first_bootR$tdebugRR/Rtuserdata_rawRR!tupdatetvendordata_puretconvert_vendordatatvendordata_rawt
ValueErrortwarningRRtTrue(R"tfoundtmdtresultstsdirR,tdevR.tprev_iidtcur_iidtvdte((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyt	_get_data9s�		
(

		
	
cCstj|j��S(N(Rtinstance_id_matches_system_uuidtget_instance_id(R"R#((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pytcheck_instance_id�scCs�|jdkr�|jdtjfkrUtjd�tj|jd|j	�|_q�|j
dk	r�tj|j
�|_tjd�q�tjd�n|jS(Ns(network config provided via network_jsonR s.network config provided via converted eni datas"no network configuration available(
RRRRRR9RJRtconvert_net_jsonR RRtconvert_eni_data(R"((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR3�s
cCsdS(NR((R"((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pytplatform�scCs2|jjd�rd}nd}d||jfS(s/Return the subplatform metadata source details.s/devsconfig-disksseed-dirs%s (%s)(RR=(R"tsubplatform_type((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyt_get_subplatform�s	(t__name__t
__module__tdsnameRR'R\R_tpropertyR3RbRd(((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR#s			U	cCs�tj|�}|jgif|jgifg}g}xN|D]F\}}}y|||�SWq@tjk
r�}|j|�q@Xq@W|d�dS(Ni����(RtConfigDriveReadertread_v2tread_v1R7tappend(t
source_dirtreadertfinderstexcpstfunctortargstkwargsR[((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR6�scCsQtjj|jd�d�}ytj|�jd�SWntk
rLdSXdS(Ntdatasinstance-ids
(	RRRt	get_cpathRt	load_filetrstriptIOErrorR(R%tfname((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyRH�s

cCs�t|t�s(tdt|���n|ru|jdd�}|ru|rutjd�|jtj	|��qunt
|jd��dS(sDPerforms any first-boot actions using data read from a config-drive.s/Config-drive data expected to be a dict; not %sR3ts-Updating network interfaces from config driveR!N(t
isinstancetdictt	TypeErrorttypeR:R9RQtapply_network_configRRatwrite_injected_files(RtR$R0tnet_conf((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyRI�s
cCs�|r�tjdt|��x�|j�D]o\}}|jtj�sWtj|}nytj||dd�Wq)t	k
r�tj
td|�q)Xq)WndS(NsWriting %s injected filestmodei�sFailed writing file: %s(R9RJtlentitemsR=RtsepRt
write_fileRxR8(R!tfilenametcontent((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR��s
cCs�|dkrg}n|rZx<tD]1}ytjd|�Wq"tjk
rRq"Xq"Wng}x(tD] }|jtjd|��qgWg}x(tD] }|jtjd|��q�W|jdt	�|jdt	�|g|D]}||kr�|^q�}g|D](}||ks.tj
|�r|^q}	tjd|	|�|	r�d|kr�t
�\}
}||	kr�|	j|�tjd||
�q�n|	S(	sReturn a list of devices that may contain the config drive.

    The returned list is sorted by search order where the first item has
    should be searched first (highest priority)

    config drive v1:
       Per documentation, this is "associated as the last available disk on the
       instance", and should be VFAT.
       Currently, we do not restrict search list to "last available disk"

    config drive v2:
       Disk should be:
        * either vfat or iso9660 formatted
        * labeled with 'config-2' or 'CONFIG-2'
    RsTYPE=%ssLABEL=%streversesdevices=%s dslist=%stIBMClouds5IBMCloud device '%s' (%s) removed from candidate listN(RtOPTICAL_DEVICESRtfind_devs_withtProcessExecutionErrortFS_TYPEStextendtLABEL_TYPEStsortRRtis_partitionR9RJRtremove(t
probe_opticalR,tdevicet	by_fstypetfs_typetby_labeltlabeltdt
candidatestdevicestibm_platformtibm_path((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR;�s6	


)
(
	cCstj|t�S(N(Rtlist_from_dependstdatasources(tdepends((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pytget_datasource_list's(RR(sconfig-2sCONFIG-2(ssrR
(%Rt	cloudinitRtloggingRRt
cloudinit.netRt$cloudinit.sources.DataSourceIBMCloudRtcloudinit.sources.helpersRt	getLoggerReR9tDEFAULT_IIDtDEFAULT_MODERCR�R�tPOSSIBLE_MOUNTSttupleR�tSourceMixinR&RR6RHRRRRIR�R;tDataSourceConfigDriveNettDEP_FILESYSTEMR�R�(((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyt<module>	s0
�		
	>