ó oBú]c@sŸddlZddlZddlZddlZddlZddlZddlmZejƒddlm Z ddlm Z ddlm Z ddlm Z ddlmZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZmZmZmZddlmZddlmZddlmZdZdZ ied6ed6ed6Z!e j"ƒZ#dd„Z$dd„Z&d„Z'd„Z(d„Z)d„Z*d.d „Z+e,dd!„Z-d"„Z.d#„Z/d$„Z0d%„Z1ddd&„Z2d'„Z3d(„Z4d)„Z5dd*„Z6e7d+kr›d,ej8krsd-ej8d,tjd%| |j4ƒ|j4gfStjd&| |j4ƒn|j>ƒ|j?ƒt<|d"d'd$d(ƒyJ|j@ƒjAd)|jBd*tCgd+tCƒ\}}|sÊ|jBtDƒnWn.tk rûtjtd,ƒ|j4d,gfSXt|jƒt jE|t|ƒd|j ƒ}yt|}|}tjF|j|ƒ\}}||ksl||krtjGd-||ƒtj|j|ƒ\}}nWn!tk rÁtjtd.ƒnXtj|jƒ|jHƒtId/|j4d0|jƒ|j4tJ|||ƒfS(1NR0s%s.ds91_kernel_cmdline_url.cfgRbs%s-localtds_depstreportersClosing stdin.s#Failed to setup output redirection!s@Logging being reset, this logger may no longer be active shortlyRs0Failed to initialize, likely bad things to come!ttrusts%s sjChecking to see if files that we need already exist from a previous run that would allow us to stop early.RLsno-nets"[%s] Exiting. stop file %s existedsQExecution continuing, no previous run detected that would allow us to stop early.tchecktmanual_cache_cleans"manual cache clean set from configtmanual_clean_markers(manual cache clean found from marker: %stexistings)[%s] Exiting. datasource %s in local modesNo local datasource founds8No instance datasource found! Likely bad things to come!tbring_ups[%s] Exiting without datasourcesNo instance datasource found.s2[%s] barreling on in force mode without datasources5[%s] %s will now be targeting instance id: %s. new=%ststagetlocalt retry_stages.[%s] Exiting. datasource %s not in local mode.s6[%s] %s is in local mode, will apply init modules now.sinit-netsmodules:configt consume_dataR3tfreqsConsuming user data failed!s#Stdout, stderr changing to (%s, %s)s'Failed to re-adjust output redirection!t datasourceRE(KRtDEP_FILESYSTEMt DEP_NETWORKRuRkR/R0tjoinRR RtInitRmtread_cfgR6RTR.RVRWRt close_stdint fixup_outputREt ExceptiontlogexcR$RR[R:t resetLoggingt setupLoggingRFR&Rt initializetpathst DSMODE_LOCALtDSMODE_NETWORKRRRRt debug_infot get_cpathtisfiletget_cfg_option_boolR"t get_ipath_curRYt purge_cachetdel_filetfetchRytdsmodetDataSourceNotFoundExceptiontforcetapply_network_configt_maybe_persist_instance_datat instancifytis_new_instancet_maybe_set_hostnametbooltsetup_datasourcetupdatetcloudifytrunRwR R tModulestget_output_cfgtwarningtactivate_datasourcetdi_report_warnRB(R2R3tdepst early_logstw_msgtinittoutfmtterrfmtRtlvlt path_helperRSRrt stop_filestexisting_filestfntmcfgtmfiletiidtrant_resultsR;t outfmt_origt errfmt_orig((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pyt main_initÖsö             !        %!                   !  "  cCsSd|krtjdƒdS|d}|dkrDtjdƒdSt|tƒsgtjd|ƒdS|jdƒ}|dkr“tjdƒdSt|tƒs¶tjd|ƒdS|jj dƒd }|j t j ƒrô|t t j ƒ}ntjd ||ƒ||kr-tjd |||ƒdStjd |d |dt|ƒƒdS(Nt di_reportsno di_report found in config.sdi_report was None.s%di_report config not a dictionary: %stdatasource_lists(no 'datasource_list' found in di_report.s(di_report/datasource_list not a list: %st.is1Datasource '%s' came from unexpected module '%s'.s:used datasource '%s' from '%s' was in di_report's list: %stdsid_missing_sourcetsourcetdslist(R$R:RTt isinstancetdictR RCtlistt __module__t rpartitionRXRt DS_PREFIXR9R t show_warningtstr(RyREtdicfgR»tmodname((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pyR¢©s8            cCs‰|j}td||fƒ}tjdgd|jƒ}|jt|ƒƒy|jddƒWnHtj k r«d|}t j t |ƒt |ƒ|js¬|gSnXt|ƒtj|t|ƒd|jƒ}y.t jdƒt jƒt j|j|ƒWn!tk r(t j t dƒnX|jrLt jd ƒtjƒntj|jƒt|jƒt|d |ƒt|||ƒS( Ns%s:%sRlRmRrRnsGCan not apply stage %s, no datasource found! Likely bad things to come!s Closing stdins#Failed to setup output redirection!s@Logging being reset, this logger may no longer be active shortlyR(RSR RR}RmR~R6RRR’RR‚R$RR“R•RžR:RR€RERRVRƒR„RFR&RB(R<R3R2R¥R¦RR;((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pyt main_modulesÓs8     !       c Cs |j}t|ƒ}tjdgd|jƒ}|jt|ƒƒy|jddƒWn;tj k r”t j t dƒt dƒ|js•dSnXt|ƒtj|t|ƒd|jƒ}|j}|rât jd|ƒn|j}|rt jd|ƒtj|ƒ}ny.t jd ƒt jƒt j|jdƒWn!tk rdt j t d ƒnX|jrˆt jd ƒtjƒntj|jƒt|jƒt|d |ƒ|j |||ƒ\}} | rêt j!d |ƒdS|st j!d|ƒdSdSdS(NRlRmRrRns;Failed to fetch your datasource, likely bad things to come!isUsing passed in arguments %ssUsing passed in frequency %ss Closing stdins#Failed to setup output redirection!s@Logging being reset, this logger may no longer be active shortlyRsRan %s but it failed!sDid not run %s, does it exist?i("R2R RR}RmR~R6RRR’RR‚R$RR“R•Ržt module_argsR:t frequencytFREQ_SHORT_NAMESRCRR€RERTRRVRƒR„RFR&t run_singleR ( R2R3tmod_nameR¥R¦R;tmod_argstmod_freqR?R@((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pyt main_singlesT     !          cCs(|dkr!tjjdƒ}n|dkrBtjjdƒ}ntjj|dƒ}tjj|dƒ}tjj|dƒ}tjj|dƒ}tj||fƒ|j\}} |dkrß|jrÖd} q d} n,|dkrûd|j } nt d |ƒ‚d} | | kr5t d j | ƒƒ‚nd} | dkrtxZ||||fD]} tj | ƒqZWn0yt jtj|ƒƒ} Wntk r£nXigd6dd6dd6}| dkréiid6} d| dddd?ƒ}|j dd>tfƒ|jd@ddAƒ} |jdBddCƒ} |jdDddEƒ} |jdFddGƒ} |jdHddIƒ} |rµ|dd@kradJdKlm}|| ƒqµ|ddBkrŽdJdKlm}|| ƒqµ|ddDkr×dJdLlm}m}|| ƒ| j ddD|fƒqµ|ddFkr dJdMlm}m}|| ƒ| j ddF|fƒqµ|dd<kridJdNl m}m!}||ƒ|j ddO|fƒqµ|ddHkrµdJdPl"m}m#}|| ƒ| j ddH|fƒqµn|j$dQ|ƒ}|j%\}}|j&rìt'j(ƒnt)j*ƒ|dbkr t+}nd}t }|dkrJ|j,r;dc\}}q½dd\}}ns|d#krtdV|j-dW|j-}}nI|d,kr§dX|j.dY|j.}}|j/}n|}dZ|}t}t0j1||d[|ƒ|_2|j2Jt3j4d\t5j&d]d^|d_t d`|dQ||fƒ}t6j7ƒ|SWdQXdS(eNtprogiis --versions-vR%Rs %(prog)s s--files-fR.tdestR-thelps*additional yaml configuration files to usettypetrbs--debugs-dt store_trues9show additional pre-action logging (default: %(default)s)tdefaults--forcesCforce running even if no datasource is found (use at your own risk)R“Rmttitlet Subcommandst subcommandR¦s3initializes cloud-init and performs initial moduless--locals-ls*start in local mode (default: %(default)s)RÏs1activates modules using a given configuration keys--modes-mtstores7module configuration name to use (default: %(default)s)tconfigtchoicestfinaltsinglesrun a single module s--names-nsmodule name to runtrequireds --frequencysfrequency of the modules--reportsenable reportingRÇtnargst*tmetavartarguments/any additional arguments to pass to this moduletquerys;Query standardized instance metadata from the command line.tfeaturesslist defined featurestanalyzes,Devel tool: Analyze cloud-init logs and datatdevelsRun development toolss collect-logss)Collect and tar all cloud-init debug infotcleans3Remove logs and artifacts so cloud-init can re-run.Rés/Report cloud-init status or wait on completion.iÿÿÿÿ(t get_parser(Rthandle_collect_logs_args(Rthandle_clean_args(Rt handle_argstrender(Rthandle_status_argsR3s init-localssearching for local datasourcess init-networks!searching for network datasourcess modules-%ssrunning modules for %ss single/%ssrunning single module %ssrunning 'cloud-init %s'treporting_enabledtlogfuncRscloud-init mode '%s't get_uptimetfunc(sinitsconfigsfinal(smodulessinit(s init-localssearching for local datasources(s init-networks!searching for network datasources(8RtargvtargparsetArgumentParsert add_argumentRR+tFileTypeR"t set_defaultsRTtadd_subparsersR#R t add_parserRµRÆR¾RÉtkeysRÎRtNAMEt__doc__RRýtcloudinit.analyze.__main__tcloudinit.cmd.devel.parsertcloudinit.cmd.devel.logsRtcloudinit.cmd.cleanRtcloudinit.cmd.queryRtcloudinit.cmd.statusRt parse_argsR%R:RVtsetupBasicLoggingRtattach_handlersRíRuRSR2treportR tReportEventStackRmRtlog_timeR$R t flush_events(t sysv_argstparsert subparserst parser_initt parser_modt parser_singlet parser_querytparser_dhclienttparser_featurestparser_analyzet parser_develtparser_collect_logst parser_cleant parser_statustanalyze_parsert devel_parsert logs_parserRt clean_parserRt query_parserthandle_query_argst status_parserRR3R2Rçtrnamet report_ontrdesctretval((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pytmainÐsþ                                       t__main__tTZs:/etc/localtime(scloud-config-urlsurl(<R"R×R/RRÛRt cloudinitRtpatchRRVRRRRRRRR R tcloudinit.reportingR tcloudinit.settingsR R RRRtcloudinit.configRRR)R7RÉt getLoggerR$RRTR&R R6RBRFRNR#RkRµR¢RÆRÎRíR•R˜RýRRt__name__tenvironR!t return_valuetexit(((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pytsh       "       N Ó * 4 Fd   ²