܍~c& rddlZddlZddlmZddlmZddlmZmZddlm Z m Z m Z ej e ZdZdZdZd ZeegZd gZd Zd Zd dddd dddddddd ZeeedZGddejZdZdZd Z d!Z!d"Z"d#Z#d$Z$d%Z%e fd&Z&d(d'Z'dS))N)importer)log) type_utilsutil) FREQUENCIES PER_ALWAYS PER_INSTANCEztext/x-not-multipartzapplication/octet-stream__end__ __begin__ztext/part-handlerzpart-handler-%03dz part-%03dztext/x-include-urlztext/x-include-once-urlztext/x-shellscriptztext/cloud-configztext/cloud-boothookztext/cloud-config-archiveztext/cloud-config-jsonpz text/jinja2text/x-shellscript-per-boottext/x-shellscript-per-instancetext/x-shellscript-per-once) z#includez #include-oncez#!z #cloud-configz #part-handlerz#cloud-boothookz#cloud-config-archivez#cloud-config-jsonpz## template: jinjar r rc&dt|z S)Nr)len)es =/usr/lib/python3/dist-packages/cloudinit/handlers/__init__.pyr?sQQZ)keycBeZdZddZdZdZejdZdS)Handlerc"||_||_dSN)handler_version frequency)selfrversions r__init__zHandler.__init__Ds&"rcZtj|d|dS)Nz: [])robj_name list_typesrs r__repr__zHandler.__repr__Hs.'066668I8I8I8IJJrctt|dstddt|dDS)Nprefixesz#Missing prefixes subclass attributec(g|]}t|S)INCLUSION_TYPES_MAP).0prefixs r z&Handler.list_types..Ps-$F+r)hasattrNotImplementedErrorgetattrr$s rr#zHandler.list_typesKsNtZ(( %&KLL L%dJ77 rctr)r/)rargskwargss r handle_partzHandler.handle_partUs!###rN)r) __name__ __module__ __qualname__rr%r#abcabstractmethodr4r)rrrrCsh####KKK $$$$$rr) metaclassc ^|j}|tks|tkr |tksdS |j}t |}n#t t tf$rd}YnwxYw|d} t d||||||dkr| ||||||dS|dkr| |||||dS|dkr| ||||dSt d|z#t$r#tj td|||||YdSwxYw)N Content-Typez1Calling handler %s (%s, %s, %s) with frequency %srzUnknown module version %sz8Failed calling handler %s (%s, %s, %s) with frequency %s)rrr rint TypeError ValueErrorAttributeErrorLOGdebugr4 Exceptionrlogexc) moddatafilenamepayloadrheadersmod_freqmod_ver content_types rrun_partrOZs}HJ  % %(l*B*B%g,, z> 2>*L  ?          a<< OOlHgy'     \\ OOD,'9 M M M M M \\ OOD,' B B B B B8GDEE E       F             s5AAA+?C?,C? C?-C??)D,+D,c@dti}t||dd||dSNr=) CONTENT_STARTrOrGrHrrKs r call_beginrTs0  G S$dIw77777rc@dti}t||dd||dSrQ) CONTENT_ENDrOrSs rcall_endrWs0  G S$dIw77777rc|d}t|z}|d}tj|dd|z}|dsd|z}t j||d|d} ttj |} t| |d || | d |d z|d<dS#t$r t j td ||YdSwxYw)N handlercountr handlerdirz%sz.pyz%s.pyihandlersrHT) initializedr<z7Failed at registering python file: %s (part handler %s))PART_HANDLER_FN_TMPLospathjoinendswithr write_file fixup_handlerr import_modulerTregisterrErFrC) pdata_ctype _filenamerJcurcountmodnamermodfnamer[rGs rwalker_handle_handlerrls)^$H"h/Gk"Iw||E,/1ABBH   U # #(h'OHgu---Z H  H27;;<<3f y111 #4000 (1 n      E          s=AC&D?DcR t|tr|ddd}n;|dd|zdddd}t ||kr |d|}n#t $r |d|}YnwxYw|S)N r<rignore)errors) isinstancestrsplitdecoderUnicodeDecodeError)blobsizestarts r_extract_first_or_bytesrzs  dC  OJJtQ''*EE1t8$++8+<<BB4KKANE u::  %4%LE QtV  LsB B B$#B$c |dS#ttf$r+ |dcYS#t$rYnwxYwYnt$rYnwxYw|S)N string_escapeunicode_escape)encode LookupErrorr@rB)texts r_escape_stringrs  {{?+++  # ;;/00 0 0 0    D  D       Ks7AAA A  A A  A AAc,|d}||dvrtd|dS|tvrt ||||dS|d}||vr(t |||d|||d|dS|rit |d}dt|z}|tkrt d ||dSt d ||dStd |dS) Nr=excludedzcontent_type "%s" is excludedr[rHrz'%s...'z)Unhandled non-multipart (%s) userdata: %sz0Unhandled unknown content-type (%s) userdata: %szEmpty payload of type %s) getrCrDPART_CONTENT_TYPESrlrOrzrNOT_MULTIPART_TYPEwarning)rHrIrJrKrNr[rydetailss rwalker_callbackrs[>*Ltxx ++++ 1<@@@)))dL(GDDDJHx \ " L            <'44~e445 - - - KK;      KKB      ,l;;;;;rcd}|D]}|dkr|}|t}|}|s t |z}t |}t|||d<tj |}||||||dz}dS)Nr multipartr=r<) walkget_content_maintypeget_content_type OCTET_TYPE get_filename PART_FN_TPLdictrCrDrfully_decoded_payload) msgcallbackrHpartnumpartctyperIrKrJs rrrsG   $ $ & &+ 5 5 %%'' =E$$&& /"g.Ht** '"',T22x'222A+%rct|dst|ddt|dst|d|n.|j}|r%|tvrtd|||S)Nrr<rz&Handler %s has an unknown frequency %s)r.setattrrrrCr)rGdef_freqfreqs rrcrcs 3) * *+&*** 3 $ $M[(++++}  MD ++ KK@#t L L L Jrc tj|}n#t$r|cYSwxYw|}t D]&}||rt|cS'|Sr)r decode_binarylowerrvlstripINCLUSION_SRCH startswithr*)rJdefault payload_lcrs rtype_from_starts_withr$s'006688 ""$$J--   & & -&t, , , , - Ns &) 88r)(r8r^ cloudinitrrloggingrrcloudinit.settingsrrr getLoggerr5rCrrrVrRCONTENT_SIGNALSrr]rr*sortedlistkeysrABCMetarrOrTrWrlrzrrrrcrr)rrrs $$$$$$&&&&&&&&DDDDDDDDDDg!!,(    +.*** %. ((,84' $A'H#@!(D  ! ! # #$$+?+? $$$$$ $$$$.- - - `888888   4$$$<$<$