oB]c@sddlZddlZddlZddlmZddlmZddlmZddlmZddZ dZ d Z d Z d Zd Zd Zedkre ZejZej\ZZeeendS(iN(t json_dumps(tdatetimei(tdump(tshowc CsZ|s!tjdddd}n|jdddd}t|_|jd d d }|jd d ddddddd d|jddddddddd d|jdd tf|jdd d}|jddddddddd d|jd d ddddddd d|jddddddddd d |jddt f|jd!d d"}|jd d ddddddd d#|jddddddddd d|jdd!t f|jd$d d%}|jd d ddddddd d#|jddddddddd d |jdd$t f|S(&Ntprogscloudinit-analyzet descriptions,Devel tool: Analyze cloud-init logs and datattitlet Subcommandstdestt subcommandtblamethelps5Print list of executed stages ordered by time to inits-is--infiletactiontstoretinfiletdefaults/var/log/cloud-init.logsspecify where to read input.s-os --outfiletoutfilet-sspecify where to write output. Rs.Print list of in-order events during executions-fs--formatt print_formats%I%D @%Es +%dssspecify formatting of output.sspecify where to write output.Rs%Dump cloud-init events in JSON formatsspecify where to read input. tboots2Print list of boot times for kernel and cloud-init( targparsetArgumentParsertadd_subparserstTruetrequiredt add_parsert add_argumentt set_defaultst analyze_blamet analyze_showt analyze_dumpt analyze_boot(tparsert subparserst parser_blamet parser_showt parser_dumpt parser_boot((s>/usr/lib/python2.7/site-packages/cloudinit/analyze/__main__.pyt get_parsers^          cCst|\}}tj}|\}}}}tj|} tj|} tj|} yZgt|D],} | ddkrmd| dkrm| ^qmd} tj| d}Wn tk rd}tj}nXd}d }d }i|tj6|tj6|tj 6}||}||}i | d 6| d 6|d 6|d6|d6|d6|d6| d6|d6}|j ||j ||S(sReport a list of how long different boot operations took. For Example: -- Most Recent Boot Record -- Kernel Started at: