a 'DgZ%@sddlZddlZddlZddlmZmZddlmZddlmZm Z ddl m Z dddZ dd Z d d Zd d ZddZddZddZeddddZedkre ZeZej\ZZeeedS)N)datetimetimezone)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--infilestoreinfilez/var/log/cloud-init.logzspecify where to read input.)actionr defaultr z-oz --outfileoutfile-zspecify where to write output. )rrz.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) argparseArgumentParseradd_subparsersrequired add_parser add_argument set_defaults analyze_blame analyze_show analyze_dump analyze_boot)parserZ subparsersZ parser_blameZ parser_showZ parser_dumpZ parser_bootr >/usr/lib/python3.9/site-packages/cloudinit/analyze/__init__.py get_parsersr"c Cst|\}}t}|\}}}}t|tj} t|tj} t|tj} z,ddt|Dd} t| dtj} Wntyd} tj }Yn0d}d}d}tj |tj |tj |i}||}||}| | |||||| | d }| ||j fi|t|||S) aReport a list of how long different boot operations took. For Example: -- Most Recent Boot Record -- Kernel Started at: