Viewing File: /usr/lib/python2.7/site-packages/cloudinit/cmd/main.pyc

ó
oBú]c@sŸddlZddlZddlZddlZddlZddlZddlmZejƒddlm	Z
ddlmZddlmZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZdd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,<ne6ej9ƒZ:e:r›ej;e:ƒq›ndS(/iÿÿÿÿN(tpatcher(tlog(tnetinfo(tsignal_handler(tsources(tstages(t
url_helper(tutil(tversion(twarnings(t	reporting(tevents(tPER_INSTANCEt
PER_ALWAYStPER_ONCEtCLOUD_CONFIG(t
atomic_helper(tcc_set_hostname(t
dhclient_hooksOCloud-init v. {version} running '{action}' at {timestamp}. Up {uptime} seconds.scloud_%s_modulestinstancetalwaystoncetcCs||rtjjd|ƒntjjddƒtjjdƒtjdtjƒtjjddƒtjjdƒdS(Ns%s
t-i<s
tfile(tsyststderrtwritet	tracebackt	print_exc(tmsg((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pyRCscCs<|st|ƒ}ntjd|dtdtdtƒ|S(Ns%s
tconsoleRR(twelcome_formatRt	multi_logtFalsetTruetLOG(tactionR((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pytwelcomeMs
c	Cs4tjdtjƒdtjƒdtjƒd|ƒS(NRtuptimet	timestampR%(tWELCOME_MSG_TPLtformatRtversion_stringRR'ttime_rfc2822(R%((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pyR Us
	cCsFg}|jrBx0|jD]"}|jtjj|jƒƒqWn|S(N(tfilestappendtostpathtrealpathtname(targstfn_cfgstfh((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pytextract_fns]s
	#cCst|}|j|ƒ\}}t|ƒt|ƒ}|dkrvd||f}tjjd|ƒtj|ƒgStjdt|ƒt|ƒƒ|SdS(Nis)No '%s' modules to run under section '%s's%s
sRan %s modules with %s failures(tMOD_SECTION_TPLtrun_sectiontlenRRRR$tdebug(tmodstaction_nametsectiontfull_section_namet	which_rantfailuresttotal_attemptedR((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pytrun_module_sectionjs


	cCs,|jdƒr(tj|jdƒƒndS(NR
(tgetR
tupdate_configuration(tcfg((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pytapply_reporting_cfgzsscloud-config-urlturlcCsTtj|ƒ}x(|D] }||kr|||fSqWtd||fƒ‚dS(Ns!No keys (%s) found in string '%s'(Rtkeyval_str_to_dicttKeyError(tcmdlinetnamestdatatkey((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pytparse_cmdline_urls
c
Cs|dkrtjƒ}nyt|ƒ\}}Wntk
rNtjdfSX|jdƒpj|jdƒ}|rÜtj	j
|ƒrÜ|r¹d||f}tj}|rÒtj}qÒnd||f}tj}||fSi|d6dd6d	d
6}|s|rtj}d|d<ntj}d
|d<d}	d}
y‰t
j|}|jƒr©|j}	|jj|
ƒsÀ|dkr‰tj}n	tj}|d||
ffSn|d||jffSWn't
jk
rê}|d||ffSXtj||	ddƒtjd|||ffS(s’Write data from url referenced in command line to path.

    path: a file to write content to if downloaded.
    network: should network access be assumed.
    cmdline: the cmdline to parse for cloud-config-url.

    This is used in MAAS datasource, in "ephemeral" (read-only root)
    environment where the instance netboots to iscsi ro root.
    and the entity that controls the pxe config has to configure
    the maas datasource.

    An attempt is made on network urls even in local datasource
    for case of network set up in initramfs.

    Return value is a tuple of a logger function (logging.DEBUG)
    and a message indicating what happened.
    s!No kernel command line url found.sfile://t/s_file '%s' existed, possibly from local stage download of command line url '%s'. Not re-writing.safile '%s' existed, possibly from previous boot download of command line url '%s'. Not re-writing.RGi
ttimeoutitretriesitsec_betweengš™™™™™¹?s
#cloud-configscloud-config-urls&contents of '%s' did not start with %ss$url '%s' returned code %s. Ignoring.sretrieving url '%s' failed: %stmodei€s*wrote cloud-config data from %s='%s' to %sN(tNoneRtget_cmdlineRNRItloggingtDEBUGt
startswithR/R0texiststINFOtWARNRtread_file_or_urltoktcontentstcodetUrlErrort
write_file(
R0tnetworkRJtcmdline_nameRGt
path_is_localtmtleveltkwargsRLtheadertrespte((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pytattempt_cmdline_urlˆsX

	
	
	
	
		cCstjtjg}|jr*tjg}ntdtjjdtdƒd|jƒg}|jsqt	|ƒ}nt	d|ƒ}t
jd|d|jƒ}|j
t|ƒƒd}d}y?|jtjdfƒtjƒtj|j|ƒ\}}WnGtk
rCd	}tjt|ƒt|ƒ|jtj|fƒnX|jrgtjd
ƒtjƒntj|jƒt|jƒt |d|ƒx$|D]\}	}tj!|	|ƒq›Wy|j"ƒWn!tk
rìtjtdƒnX|j#}
|jrtj$ntj%}|tj%krÚd
}t&j'j(dt)j*ƒƒtjdƒtjj|
j+dƒdƒg}
g}x0|
D](}tjj,|ƒr{|j|ƒq{q{W|rÊtjd||ƒdgfStjdƒn£d}tj-|jdt.ƒ}|rtjdƒd
}n:|
j/dƒ}tjj0|ƒrNtjd|ƒd
}n|j1ƒtj2tjj|
j+dƒdƒƒyU|j3d|ƒ|tj%krÑ|j4j5|krÑtjd||j4ƒdgfSWn©tj6k
r}|tj$krtjdƒntjtdƒ|j7sj|j8d|jƒtjd|ƒ|tj$krZdgfSddgfSq~tjd |ƒnXt9|ƒ|j:ƒ}tjd!||||j;ƒƒ|tj$krÛt<|d"d#d$dƒn|j8dt=|tj$kƒƒ|tj$krW|j4j5|kr>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=%ststagetlocaltretry_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_FILESYSTEMtDEP_NETWORKRuRkR/R0tjoinRR RtInitRmtread_cfgR6RTR.RVRWRtclose_stdintfixup_outputREt	ExceptiontlogexcR$RR[R:tresetLoggingtsetupLoggingRFR&Rt
initializetpathstDSMODE_LOCALtDSMODE_NETWORKRRRRt
debug_infot	get_cpathtisfiletget_cfg_option_boolR"t
get_ipath_curRYtpurge_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_msgtinittoutfmtterrfmtRtlvltpath_helperRSRrt
stop_filestexisting_filestfntmcfgtmfiletiidtrant_resultsR;toutfmt_origterrfmt_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
tjƒrô|t
tjƒ}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
jt|ƒt
|ƒ|js¬|gSnXt|ƒtj|t|ƒd|jƒ}y.tjdƒt
jƒt
j|j|ƒWn!tk
r(t
jt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
jt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
jt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žtmodule_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.pytmain_singlesT		
	
!		


	


	cCs(|dkr!tjjdƒ}n|dkrBtjjdƒ}ntjj|dƒ}tjj|dƒ}tjj|dƒ}tjj|dƒ}tj||fƒ|j\}}	|dkrß|jrÖd}
qd}
n,|dkrûd|j	}
nt
d	|ƒ‚d}|
|kr5t
d
j|
ƒƒ‚nd}|
dkrtxZ||||fD]}
tj|
ƒqZWn0yt
jtj|ƒƒ}Wntk
r£nXigd6dd6dd6}|dkréiid6}d|dd<nx5|D]-}||dkrð|jƒ|d|<qðqðW|d}|
|d<tjƒ||
d<tj||ƒtjtjj||ƒ|dtƒyz|	||ƒ}|
dkrÊ|\}}|dk	rÐt|ƒ|d<qÐn|}g|D]}t|ƒ^q×||
d<WnKtk
rE}tjtd|
ƒtd|
ƒt|ƒg||
d<nXtjƒ||
d<d|d<tj||ƒ|
dkrg}x<|D]4}||dr|j||jdgƒƒqqWtj|ii|dd6|d6d6ƒtjtjj||ƒ|dtƒnt||
dƒS(Ns/var/lib/cloud/datas/run/cloud-initsstatus.jsonsresult.jsonR¦s
init-localtmoduless
modules-%ssunknown name: %ssmodules-initsmodules-configs
modules-finals'Invalid cloud init mode specified '{0}'terrorststarttfinishedtv1RyRtR“sfailed stage %ssfailed run of stage %s(sinits
init-localsmodules-initsmodules-configs
modules-final(sinits
init-local(RTR/R0tnormpathR|Rtensure_dirsR%RuRSt
ValueErrorR*Rtjsontloadst	load_fileRtcopyttimeRt
write_jsontsym_linktrelpathR#RÃR‚R$RtextendRCR9(R2R3tdata_dtlink_dtstatus_pathtstatus_linktresult_pathtresult_linkt_nametfunctorRStmodeststatustft
nullstatusReRÓtretRyRÐRj((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pytstatus_wrapperMs			





+

$
cCsP|jrLtjj|jjtjƒ}tjj|ƒsL|j	j
ƒqLndS(sCWrite instance-data.json file if absent and datasource is restored.N(tds_restoredR/R0R|R†trun_dirRtINSTANCE_JSON_FILERYRytpersist_instance_data(R¦tinstance_data_file((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pyR•±s
		cCs|jƒ}tj|j|dtƒ\}}|r‹y tjd|j|tdƒWq‹tj	k
r‡}tj
d||t|ƒƒq‹XndS(sâCall set-hostname if metadata, vendordata or userdata provides it.

    @param stage: String representing current stage in which we are running.
    @param retry_stage: String represented logs upon error setting hostname.
    t
metadata_onlysset-hostnamesGFailed setting hostname in %s stage. Will retry in %s stage. Error: %s.N(RœRtget_hostname_fqdnRER#RthandleR$RTtSetHostnameErrorR:RÃ(R¦RtRvtcloudthostnamet_fqdnRj((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pyR˜ºs cCs*tjjdjttjƒƒdƒdS(Ns
(RtstdoutRR|tsortedRtFEATURES(R2R3((s6/usr/lib/python2.7/site-packages/cloudinit/cmd/main.pyt
main_featuresÌscCs1|stj}ntjd|dƒ}|d}|jddddddtjƒƒ|jd	d
dddd
dddtjdƒƒ|jdddddddtƒ|jddddddddtƒ|j	ddƒ|jddddƒ}t|_
|jdddƒ}|jd d!dddd"dtƒ|j	ddtfƒ|jd#dd$ƒ}|jd%d&dd'dd(dd)d*daƒ|j	dd#tfƒ|jd,dd-ƒ}|jd.d/dd'dd0d1tƒ|jd2dd'dd3d1td*ttjƒƒƒ|jd4dddd5d1tƒ|jd6d7d8d9d:dd;ƒ|j	dd,tfƒ|jd<dd=ƒ}|jtjdtjƒ}tj|ƒ|jd>dd?ƒ}|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*ƒ|dbkrt+}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“RmttitletSubcommandst
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(Rthandle_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íRuRSR2treportRtReportEventStackRmRtlog_timeR$R
tflush_events(t	sysv_argstparsert
subparserstparser_initt
parser_modt
parser_singletparser_querytparser_dhclienttparser_featurestparser_analyzetparser_develtparser_collect_logstparser_cleant
parser_statustanalyze_parsertdevel_parsertlogs_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.reportingRtcloudinit.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.pyt<module>sh
"

		
			N	Ó	*	4	Fd				²
Back to Directory File Manager