ó 'KXc@sWddlZddlmZddlmZddlmZddlmZddlm Z ej e ƒZ dZ dZie d 6ZdZdZed„eddƒDƒƒZde jejfd„ƒYZdefd„ƒYZddd„Zdd„Zd„Zdd„Zed„Zeej ffeej ej!ffgZ"d„Z#dS(iÿÿÿÿN(tlog(tsources(tutil(taix_util(t openstacksiid-dsconfigdrivetpasss instance-idtlocaltnettdisabledsconfig-2ccs|]}d|VqdS(scd%sN((t.0ti((sT/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pys (siitDataSourceConfigDrivecBs#eZd„Zd„Zd„ZRS(cCshtt|ƒj|||ƒd|_d|_tjj|j dƒ|_ d|_ d|_ i|_ dS(NRt config_drive( tsuperR t__init__tNonetsourcetdsmodetostpathtjointseed_dirtversiont ec2_metadatatfiles(tselftsys_cfgtdistrotpaths((sT/opt/freeware/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__RRR(Rtroottmstr((sT/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR5sc Cs’d}i}i}tjj|jƒrsyt|jƒ}|j}Wqstjk rotj t d|jƒqsXn|sxŠt ƒD]|}yt j |tƒ}|}WnMtjk r»n:tjk rÎn'tjk rôtj t d|ƒnX|rƒPqƒqƒWn|stS|jdiƒ}tj|tgƒ}|jddƒ}|tdkrrt jd|ƒd}ntd|dd|jjdƒd |ƒ}|d kr­tSt|jƒ}|d }||kr÷|jd kr÷t|d |jƒn||jkrt jd||ƒtS||_||_|jdƒ|_ |jdƒ|_!|d|_"|j#j$|jdiƒƒ|jdƒ|_%t&S(Ns#Failed reading config drive from %ssBroken config drive: %stmetadataRsUser specified invalid mode: %st cfgdrv_verRtds_cfgtuserRs instance-idRRs&%s: not claiming datasource, dsmode=%ss ec2-metadatatuserdataRt vendordata(N('RRRtisdirRtread_config_driveRt NonReadableRtlogexctLOGtfind_candidate_devsRtmount_cbtMountFailedErrortBrokenMetadatatFalsetgett mergemanydicttDEFAULT_METADATAt VALID_DSMODEStwarnt get_ds_modeR#tget_previous_iidRRt on_first_bootRtdebugRR!Rt userdata_rawRRtupdatetvendordata_rawtTrue( Rtfoundtmdtresultstdevt user_dsmodeRtprev_iidtcur_iid((sT/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pytget_data;sf           (t__name__t __module__RRRE(((sT/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR +s tDataSourceConfigDriveNetcBseZd„ZRS(cCs#tj||||ƒd|_dS(NR(R RR(RRRR((sT/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR…s(RFRGR(((sT/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyRH„scCs4|dk r|S|dk r |S|dkr0dSdS(s`Determine what mode should be used. valid values are 'pass', 'disabled', 'local', 'net' iRRN(R(R"R#R$((sT/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR6Šs   s 2012-08-10c CsŸtj|ƒ}|jgi|d6f|jgifg}g}xN|D]F\}}}y|||ŽSWqGtjk rŒ}|j|ƒqGXqGW|d‚dS(NRiÿÿÿÿ(RtConfigDriveReadertread_v2tread_v1R)tappend( t source_dirRtreadertfinderstexcpstfunctortargstkwargste((sT/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR(£scCsQtjj|jdƒdƒ}ytj|ƒjdƒSWntk rLdSXdS(Ntdatas instance-ids ( RRRt get_cpathRt load_filetrstriptIOErrorR(Rtfname((sT/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR7²s  cCst|tƒs(tdt|ƒƒ‚n|jddƒ}|rc|rctjdƒ|j|ƒn|jdiƒ}|rtjdt|ƒƒx€|j ƒD]o\}}|j t j ƒsÌt j |}nyt j||ddƒWqžtk r t jtd |ƒqžXqžWnd S( sDPerforms any first-boot actions using data read from a config-drive.s/Config-drive data expected to be a dict; not %stnetwork_configts-Updating network interfaces from config driveRsWriting %s injected filestmodei°sFailed writing file: %sN(t isinstancetdictt TypeErrorttypeR1R+R9t apply_networktlent iteritemst startswithRtsepRt write_fileRYR*(RURtnet_confRtfilenametcontent((sT/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR8½s"   cCs[g}|rQxBtD]7}y|jtj|ƒƒWqtjk rIqXqWn|}|S(s Return 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 formated * labeled with 'config-2' (tOPTICAL_DEVICEStextendRtfind_devs_withRtProcessExecutionError(t probe_opticalt by_fstypetdevicetdevices((sT/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyR,Òs  cCstj|tƒS(N(Rtlist_from_dependst datasources(tdepends((sT/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pytget_datasource_listøs(slocalsnetspasssdisabled(sconfig-2($Rt cloudinitRtloggingRRtcloudinit.distrosRtcloudinit.sources.helpersRt getLoggerRFR+t DEFAULT_IIDt DEFAULT_MODER3R4t LABEL_TYPESttupletrangeRkt SourceMixinRR RHRR6R(R7R8R=R,tDEP_FILESYSTEMt DEP_NETWORKRtRv(((sT/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceConfigDrive.pyts.  Y