܍~c7 UddlZddlmZddlmZddlmZddlmZddl m Z ddl m Z ddl mZmZdd lmZdd lmZd Zd Z d Zd ddeegeggdZeed<eeZdede de dededdf dZdS)N)Logger)parse_qs) url_helper)util)Cloud)Config) MetaSchema get_meta_doc) ALL_DISTROS) PER_INSTANCEcc_rightscale_userdataCLOUD_INIT_REMOTE_HOOKaIThis module adds support for RightScale configuration hooks to cloud-init. RightScale adds an entry in the format ``CLOUD_INIT_REMOTE_HOOK=http://...`` to ec2 user-data. This module checks for this line in the raw userdata and retrieves any scripts linked by the RightScale user data and places them in the user scripts configuration directory, to be run later by ``cc_scripts_user``. .. note:: the ``CLOUD_INIT_REMOTE_HOOK`` config variable is present in the raw ec2 user data only, not in any cloud-config parts **Raw user data schema**:: CLOUD_INIT_REMOTE_HOOK= zRightScale Userdataz&Support rightscale configuration hooks)idnametitle descriptiondistros frequencyexamplesactivate_by_schema_keysmetarcfgcloudlogargsreturnc t|dd}|rt|s|d|dS|} t|}|r t|vr|d|tdSn%#t $rt j|d|wxYwg}g} |d} |t} t| D]\} } tj | d| z} tj| }|r3|jr,t j||d||#t $r<}| |t j|d t&| |Yd}~d}~wwxYw|r#|d t)|t)|t)| kr5t)| t)|z }|d || r+|d t)| | d dS)Nget_userdata_rawz'Failed to get raw userdata in module %sz:Skipping module %s, did not find %s in parsed raw userdataz1Failed to parse query string %s into a dictionaryscriptszrightscale-%02ii)modez!%s failed to read %s and write %sz)Wrote out rightscale userdata to %s filesz%s urls were skipped or failedz2%s failed with exceptions, re-raising the last one)getattrcallabledebugr MY_HOOKNAME Exceptionrlogexc get_ipath_cur enumerateospathjoinuhelpreadurlokcontents write_fileappendMY_NAMElenwarning)rrrrrrudmdict wrote_fnscaptured_excps scripts_durlsiurlfnamerespeskippeds I/usr/lib/python3/dist-packages/cloudinit/config/cc_rightscale_userdata.pyhandlerCIsu&8$?? 8,<#=#= ;TBBB    B    500 IIL    F 1  Db      IN ##I..I  DdOO  C Y(9Q(?@@ =%%Dwwyy (T] (t%8888  '''     ! !! $ $ $ K8'3          O =s9~~NNN 9~~T""d))c)nn, 2G<<<! @      R  !!s%6A??"B!AE F$(2FF$)r*loggingr urllib.parser cloudinitrr-rcloudinit.cloudrcloudinit.configrcloudinit.config.schemar r cloudinit.distrosr cloudinit.settingsr r3r%MODULE_DESCRIPTIONr__annotations____doc__strlistrCrBrSsg !!!!!!))))))!!!!!!######<<<<<<<<))))))++++++ "& A" # ! 5%}!  j    ,t  (:! :!:!#(:!/5:!=A:! :!:!:!:!:!:!rR