oB]c@sqdZddlZddlmZddlmZddlmZddlm Z eZ dZ dZ d Z dS( s  Rightscale Userdata ------------------- **Summary:** support rightscale configuration hooks This module adds support for RightScale configuration hooks to cloud-init. RightScale adds a 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 **Internal name:** ``cc_rightscale_userdata`` **Module frequency:** per instance **Supported distros:** all **Config keys**:: CLOUD_INIT_REMOTE_HOOK= iN(t PER_INSTANCE(t url_helper(tutil(tparse_qstcc_rightscale_userdatatCLOUD_INIT_REMOTE_HOOKcCs y|j}Wn"tk r4|jd|dSXy:t|}| sWt|krn|jd|tdSWn'tk rtj|d|nXg}g}|jd} |t} xt| D]\} } t j j | d| } yNt j | }|jr=|jr=tj| |dd|j| nWqtk ry}|j|tj|dt| | qXqW|r|jd t|nt|t| krt| t|}|jd |n|r|jd t||d ndS( Ns'Failed to get raw userdata in module %ss:Skipping module %s, did not find %s in parsed raw userdatas1Failed to parse query string %s into a dictionarytscriptssrightscale-%02itmodeis!%s failed to read %s and write %ss)Wrote out rightscale userdata to %s filess%s urls were skipped or faileds2%s failed with exceptions, re-raising the last onei(tget_userdata_rawt ExceptiontdebugRt MY_HOOKNAMERtlogexct get_ipath_curt enumeratetostpathtjointuhelptreadurltoktcontentst write_filetappendtMY_NAMEtlentwarning(tnamet_cfgtcloudtlogt_argstudtmdictt wrote_fnstcaptured_excpst scripts_dturlstiturltfnametresptetskipped((sK/usr/lib/python2.7/site-packages/cloudinit/config/cc_rightscale_userdata.pythandleBsN          (t__doc__Rtcloudinit.settingsRt cloudinitRRRtsix.moves.urllib_parseRt frequencyRR R,(((sK/usr/lib/python2.7/site-packages/cloudinit/config/cc_rightscale_userdata.pyt!s