ó oBú]c@s<ddlZddlmZddlmZddlmZddlmZddlm Z ddl m Z ej e ƒZdZd Zied 6ZdZdZdZed„eDƒƒZde jejfd„ƒYZd„Zd„Zded„Zd„Zedd„Z eZ!eej"ffgZ#d„Z$dS(iÿÿÿÿN(tlog(tsources(tutil(teni(tget_ibm_platform(t openstacksiid-dsconfigdrivetpasss instance-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 stDataSourceConfigDrivecBsYeZdZd„Zd„Zd„Zd„Zed„ƒZed„ƒZ d„Z RS(t ConfigDrivecCs†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_jsont network_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`|j j 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 ƒ|d d 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(Ris instance-idR$tnetworks&%s: not claiming datasource, dsmode=%ss ec2-metadatatuserdataR!t vendordatas"Invalid content in vendor-data: %stnetwork_configt networkdata(0RRRRtisdirtread_config_driveRt NonReadableRtlogexctLOGR#tgettfind_candidate_devst is_FreeBSDt startswithtmount_cbtMountFailedErrortBrokenMetadatatFalset mergemanydicttDEFAULT_METADATAt_determine_dsmodetds_cfgRt DSMODE_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‰t j |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/devs config-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(Ntdatas instance-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 } t j d| |ƒ| r d|kr t ƒ\} } | | kr | j| ƒt j 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_TYPEStextendt LABEL_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_dependst datasources(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 getLoggerReR9t DEFAULT_IIDt DEFAULT_MODERCRŽRtPOSSIBLE_MOUNTSttupleR‹t SourceMixinR&RR6RHRRRRIR€R;tDataSourceConfigDriveNettDEP_FILESYSTEMR R¢(((sK/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyt s0  Š   >