3 \me%@sddlZddlZddlZddlmZddlmZddlmZmZddl m Z dddZ dd Z d d Z d d ZddZddZddZeddddZedkre ZejZej\ZZeeedS)N)datetime)IO)dumpshow) json_dumpscCsh|stjddd}|jddd}d|_|jdd d }|jd d d dddd|jddd dddd|jdtfd|jddd }|jddd dddd|jd d d dddd|jddd dddd|jdtfd|jd d!d }|jd d d ddd"d|jddd dddd|jd t fd|jd#d$d }|jd d d ddd"d|jddd dddd|jd#t fd|S)%Nzcloudinit-analyzez,Devel tool: Analyze cloud-init logs and data)prog descriptionZ SubcommandsZ subcommand)titledestTZblamez5Print list of executed stages ordered by time to init)helpz-iz--infileZstoreinfilez/var/log/cloud-init.logzspecify where to read input.)actionr defaultr z-oz --outfileoutfile-zspecify where to write output. )r rz.Print list of in-order events during executionz-fz--format print_formatz%I%D @%Es +%dszspecify formatting of output.zspecify where to write output.rz%Dump cloud-init events in JSON formatzspecify where to read input. Zbootz2Print list of boot times for kernel and cloud-init) argparseArgumentParserZadd_subparsersZrequiredZ add_parser add_argumentZ set_defaults analyze_blame analyze_show analyze_dump analyze_boot)parserZ subparsersZ parser_blameZ parser_showZ parser_dumpZ parser_bootr/usr/lib/python3.6/__init__.py get_parsers    rcCst|\}}tj}|\}}}}tj|} tj|} tj|} y(ddt|Dd } tj| d} Wntk rd} tj}YnXd}d}d}tj|tj|tj |i}||}||}| | |||||| | d }|j ||j f|t |||S) aReport a list of how long different boot operations took. For Example: -- Most Recent Boot Record -- Kernel Started at: