PNG  IHDR;IDATxܻn0K )(pA 7LeG{ §㻢|ذaÆ 6lذaÆ 6lذaÆ 6lom$^yذag5bÆ 6lذaÆ 6lذa{ 6lذaÆ `}HFkm,mӪôô! x|'ܢ˟;E:9&ᶒ}{v]n&6 h_tڠ͵-ҫZ;Z$.Pkž)!o>}leQfJTu іچ\X=8Rن4`Vwl>nG^is"ms$ui?wbs[m6K4O.4%/bC%t Mז -lG6mrz2s%9s@-k9=)kB5\+͂Zsٲ Rn~GRC wIcIn7jJhۛNCS|j08yiHKֶۛkɈ+;SzL/F*\Ԕ#"5m2[S=gnaPeғL lذaÆ 6l^ḵaÆ 6lذaÆ 6lذa; _ذaÆ 6lذaÆ 6lذaÆ RIENDB`  oB]c@sdZddlmZddlmZddlZddlZddlZddlZddl Z ddl Z eZ dZ dZ ddZdZd Zd Zddd Zd ZdS( s Power State Change ------------------ **Summary:** change power state This module handles shutdown/reboot after all config modules have been run. By default it will take no action, and the system will keep running unless a package installation/upgrade requires a system reboot (e.g. installing a new kernel) and ``package_reboot_if_required`` is true. The ``power_state`` config key accepts a dict of options. If ``mode`` is any value other than ``poweroff``, ``halt``, or ``reboot``, then no action will be taken. The system can be shutdown before cloud-init has finished using the ``timeout`` option. The ``delay`` key specifies a duration to be added onto any shutdown command used. Therefore, if a 5 minute delay and a 120 second shutdown are specified, the maximum amount of time between cloud-init starting and the system shutting down is 7 minutes, and the minimum amount of time is 5 minutes. The ``delay`` key must have an argument in a form that the ``shutdown`` utility recognizes. The most common format is the form ``+5`` for 5 minutes. See ``man shutdown`` for more options. Optionally, a command can be run to determine whether or not the system should shut down. The command to be run should be specified in the ``condition`` key. For command formatting, see the documentation for ``cc_runcmd``. The specified shutdown behavior will only take place if the ``condition`` key is omitted or the command specified by the ``condition`` key returns 0. **Internal name:** ``cc_power_state_change`` **Module frequency:** per instance **Supported distros:** all **Config keys**:: power_state: delay: mode: message: timeout: condition: i(t PER_INSTANCE(tutilNicCsyttjrbtjddt|g\}}|jd}tjd|}|jdStjd|SWnt k rdSXdS(Ntprocstats-cis\d+ (\w|\.|-)+\s+(/\w.+)is/proc/%s/cmdline( Rt is_FreeBSDtsubptstrt splitlinestretsearchtgroupt load_filetIOErrortNone(tpidtoutputt_errtlinetm((sJ/usr/lib/python2.7/site-packages/cloudinit/config/cc_power_state_change.pyt givecmdlineCs $  cCs t|tr-|r)|jd|n|Sd|}ytj|dt|t }|j|j}|dkr|r|j|dntS|dkr|r|j|dnt S|r|j |d|d nt SWn2t k r}|r|j |d |nt SXdS( NsStatic Condition: %sscheck_condition command (%s): tshellisexited 0. condition met.isexited 1. condition not met.sunexpected exit %s. sdo not apply change.sUnexpected error: %s( t isinstancetbooltdebugt subprocesstPopentlistt communicatet returncodetTruetFalsetwarningt Exception(tcondtlogtpretproctrette((sJ/usr/lib/python2.7/site-packages/cloudinit/config/cc_power_state_change.pytcheck_conditionUs2      c Csy6t|\}}}|dkr5|jddSWn+tk rc}|jdt|dSX|tkr|jddStj} t | } | s|jddSt tj d} |jd| dj |ft jt| | |||t|| gdS(Ns&no power_state provided. doing nothings%%s Not performing power state change!s3Condition was false. Will not perform state change.s5power_state: failed to get cmdline of current processtws#After pid %s ends, will execute: %st (tload_power_stateR RRRRRtostgetpidRtopentdevnulltjoinRtfork_cbtrun_after_pid_gonetexecmd( t_nametcfgt_cloudR!t_argstargsttimeoutt conditionR%tmypidtcmdlinet devnull_fp((sJ/usr/lib/python2.7/site-packages/cloudinit/config/cc_power_state_change.pythandless(        cCs|jd}|dkrdSt|ts=tdnidd6dd6dd6}|jd }||krtd d j|j|fn|jd d }ydt|}Wntk rnX|d krt j d| rtd|nd|||g}|jdrB|j |jdnyt |jdd}Wn%tk rtd|dnX|jdt }t|tjttfstdn|||fS(Nt power_statespower_state is not a dict.s-Hthalts-Ptpoweroffs-rtreboottmodes<power_state[mode] required, must be one of: %s. found: '%s'.t,tdelaytnows+%ss\+[0-9]+s?power_state[delay] must be 'now' or '+m' (minutes). found '%s'.tshutdowntmessageR7g>@s(failed to convert timeout '%s' to float.R8s2condition type %s invalid. must be list, bool, str(NNN(tgetR Rtdictt TypeErrorR.tkeystintt ValueErrorRtmatchtappendtfloatRtsixt string_typesRR(R3tpstatetopt_mapRARCR6R7R8((sJ/usr/lib/python2.7/site-packages/cloudinit/config/cc_power_state_change.pyR)s@  "   cCstj|dS(N(R*t_exit(tsysexit((sJ/usr/lib/python2.7/site-packages/cloudinit/config/cc_power_state_change.pytdoexitscCssd}yAtj|dtjd|dtj}|j||j}Wntk rdttnXt|dS(Nitstdintstdouttstderr( RRtPIPEtSTDOUTRRRRVt EXIT_FAIL(texe_argsRtdata_inR$R#((sJ/usr/lib/python2.7/site-packages/cloudinit/config/cc_power_state_change.pyR1s   cswd}tj|}fd} tjtjf} xtrtj|kr`d|}Pny0t|} | |krd|| f}PnWnatk r} | j| krd| j}n| d| Pn!tk r} | d| nXtj dq:W|s| dnr.j |nyt |sDdSWn!tk rh} | d | nX||dS( Ncs$rj|nttdS(N(RRVR\(tmsg(R!(sJ/usr/lib/python2.7/site-packages/cloudinit/config/cc_power_state_change.pytfatalsstimeout reached before %s endeds cmdline changed for %s [now: %s]spidfile gone [%d]sIOError during wait: %ssUnexpected Exception: %sg?s&Unexpected error in run_after_pid_gones0Unexpected Exception when checking condition: %s( R ttimeterrnotENOENTtESRCHRRR RtsleepRR&(R t pidcmdlineR7R!R8tfuncR6R_tend_timeR`t known_errnosR:tioerrR%((R!sJ/usr/lib/python2.7/site-packages/cloudinit/config/cc_power_state_change.pyR0s>     (t__doc__tcloudinit.settingsRt cloudinitRRbR*RRPRRat frequencyR\RR R&R<R)RVR1R0(((sJ/usr/lib/python2.7/site-packages/cloudinit/config/cc_power_state_change.pyt2s"          /