Current File : //lib/python2.7/site-packages/cloudinit/handlers/__init__.pyc
�
oB�]c@s�ddlZddlZddlZddlmZmZmZddlmZddlm	Z
ddlmZddlmZe
j
e�ZdZdZd	Zd
ZeegZdgZdZd
Zi
dd6dd6dd6dd6dd6dd6dd6dd6dd6dd 6Zeeej��d!d"��Zejej�d#efd$��Y�Z d%�Z!d&�Z"d'�Z#d(�Z$d)�Z%d*�Z&d+�Z'd,�Z(ed-�Z)dd.�Z+dS(/i����N(t
PER_ALWAYStPER_INSTANCEtFREQUENCIES(timporter(tlog(t
type_utils(tutilstext/x-not-multipartsapplication/octet-streamt__end__t	__begin__stext/part-handlerspart-handler-%03ds	part-%03dstext/x-include-urls#includestext/x-include-once-urls
#include-oncestext/x-shellscripts#!stext/cloud-configs
#cloud-configstext/upstart-jobs#upstart-jobs
#part-handlerstext/cloud-boothooks#cloud-boothookstext/cloud-config-archives#cloud-config-archivestext/cloud-config-jsonps#cloud-config-jsonpstext/jinja2s## template: jinjatkeycCsdt|�S(Ni(tlen(te((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pyt<lambda><stHandlercBs8eZdd�Zd�Zd�Zejd��ZRS(icCs||_||_dS(N(thandler_versiont	frequency(tselfRtversion((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pyt__init__Bs	cCsdtj|�|j�fS(Ns%s: [%s](Rtobj_namet
list_types(R((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pyt__repr__FscCsFt|d�std��n$gt|d�D]}t|^q.SdS(Ntprefixess#Missing prefixes subclass attribute(thasattrtNotImplementedErrortgetattrtINCLUSION_TYPES_MAP(Rtprefix((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pyRIscOs
t��dS(N(R(Rtargstkwargs((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pythandle_partQs(t__name__t
__module__RRRtabctabstractmethodR(((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pyR
?s		c	
CsV|j}|tkp*|tko*|tks1dSy|j}t|�}Wn tttfk
rld}nX|d}y�tj	d|||||�|dkr�|j
||||||�n]|dkr�|j
|||||�n5|dkr|j
||||�ntd|��Wn0tk
rQtj
td|||||�nXdS(NisContent-Types1Calling handler %s (%s, %s, %s) with frequency %siisUnknown module version %ss8Failed calling handler %s (%s, %s, %s) with frequency %s(RRRRtintt	TypeErrort
ValueErrortAttributeErrortLOGtdebugRt	ExceptionRtlogexc(	tmodtdatatfilenametpayloadRtheaderstmod_freqtmod_vertcontent_type((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pytrun_partVs4		

	

cCs*itd6}t||dd||�dS(NsContent-Type(t
CONTENT_STARTR3tNone(R+R,RR/((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pyt
call_beginxs
cCs*itd6}t||dd||�dS(NsContent-Type(tCONTENT_ENDR3R5(R+R,RR/((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pytcall_end�s
c
Cs�|d}t|}|d}tjj|dd|�}|jd�sWd|}ntj||d�|d}yNttj	|��}	t
|	|d	|�|j|	d
t�|d|d<Wn't
k
r�tjtd||�nXdS(
NthandlercountRt
handlerdirs%ss.pys%s.pyi�thandlersR,tinitializedis7Failed at registering python file: %s (part handler %s)(tPART_HANDLER_FN_TMPLtostpathtjointendswithRt
write_filet
fixup_handlerRt
import_moduleR6tregistertTrueR)R*R'(
tpdatat_ctypet	_filenameR.tcurcounttmodnameRtmodfnameR;R+((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pytwalker_handle_handler�s 





cCs�yxt|tj�r.|jdd�d}n*|d| jdd�jdd�d}t|�|krw|| }nWntk
r�|d|!}nX|S(Ns
iiiterrorstignore(t
isinstancetsixtstring_typestsplittdecodeR
tUnicodeDecodeError(tblobtsizetstart((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pyt_extract_first_or_bytes�s*
cCsdy|jd�SWnLttfk
rOy|jd�SWq`tk
rKq`Xntk
r_nX|S(Nt
string_escapetunicode_escape(tencodetLookupErrorR$R&(ttext((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pyt_escape_string�s

cCs|d}||jd�kr3tjd|�dS|tkrVt||||�dS|d}||kr�t|||d|||d|�nm|r�t|d�}dt|�}|tkr�tj	d	||�qtj	d
||�ntjd|�dS(NsContent-Typetexcludedscontent_type "%s" is excludedR;R,Ris'%s...'s)Unhandled non-multipart (%s) userdata: %ss0Unhandled unknown content-type (%s) userdata: %ssEmpty payload of type %s(
tgetR'R(tPART_CONTENT_TYPESRMR3RYR_tNOT_MULTIPART_TYPEtwarning(R,R-R.R/R2R;RXtdetails((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pytwalker_callback�s(

	
	
c	Cs�d}x�|j�D]�}|j�dkr1qn|j�}|dkrRt}n|j�}|sqt|}nt|�}tj	|�||d<t
j|�}|||||�|d}qWdS(Nit	multipartsContent-Typei(twalktget_content_maintypetget_content_typeR5t
OCTET_TYPEtget_filenametPART_FN_TPLtdictR'R(Rtfully_decoded_payload(	tmsgtcallbackR,tpartnumtparttctypeR-R/R.((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pyRh�s 	


cCsyt|d�s"t|dd�nt|d�sDt|d|�n1|j}|ru|tkrutjd||�n|S(NRiRs&Handler %s has an unknown frequency %s(RtsetattrRRR'Rd(R+tdef_freqtfreq((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pyRC�s	cCsfytj|�j�}Wntk
r-|SX|j�}x%tD]}|j|�rAt|SqAW|S(N(Rt
decode_binarytlowerRUtlstriptINCLUSION_SRCHt
startswithR(R.tdefaultt
payload_lcR^((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pyttype_from_starts_withs

(,R!R>RQtcloudinit.settingsRRRt	cloudinitRRtloggingRRt	getLoggerRR'RcRkR7R4tCONTENT_SIGNALSRbR=RmRtsortedtlisttkeysR{t
add_metaclasstABCMetatobjectR
R3R6R8RMRYR_RfRhRCR5R(((s?/usr/lib/python2.7/site-packages/cloudinit/handlers/__init__.pyt<module>sR	
	"