Current File : //lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pyc
�
oB�]c@s.ddlmZddlmZddlmZddlmZddlmZddlmZej	e
�ZdZdZ
d	Zd
ZdZdZd
ejfd��YZeejejffgZd�Zee
eeed�Zee
eeed�Ze
dkr*ddlZejdd�Zejdddddde�ejdddddde
�ejddd d!edd"de�ejd#dd d!edd$de�ejd%dd&d!edd'de�ej�Z ed(e j!d)e j"d*e j#d+e j$d,e j%�Z&ej'e&�GHndS(-i����(t	ec2_utils(tlog(tsources(thelpers(t
url_helper(tutilshttp://169.254.169.254s1.0i�i
itExoscaletDataSourceExoscalecBsSeZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	RixcCs�tt|�j|||�tjd�|jjdt�|_|jjdt	�|_
t|jjdt��|_
|jjdt�|_|jjdt�|_i|_dS(Ns$Initializing the Exoscale datasourcetmetadata_urltapi_versiontpassword_server_portttimeouttretries(tsuperRt__init__tLOGtdebugtds_cfgtgettMETADATA_URLRtAPI_VERSIONR	tinttPASSWORD_SERVER_PORTR
tURL_TIMEOUTturl_timeouttURL_RETRIESturl_retriestextra_config(tselftsys_cfgtdistrotpaths((sH/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pyRs
cCsQd}|jjd�}tj|�}|jd|d�rMtjd�ndS(s<Adjust set-passwords module to run 'always' during each boott
set_passwordstsemtconfig_s5Overriding module set-passwords with frequency alwaysN(Rt
get_ipath_curRtFileSemaphorestcleartNoneRR(Rtcfgtis_new_instancetmodtsem_patht
sem_helper((sH/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pytactivate+s
	c	CsXdj|j|j�}tjd|gd|jd|jdtj�\}}t	|�S(s.Wait for the metadata service to be reachable.s{}/{}/meta-data/instance-idturlstmax_waitRt	status_cb(
tformatRR	Rtwait_for_urlturl_max_waitRRtcriticaltbool(RRturlt	_response((sH/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pytwait_for_metadata_service:s				cCsStjdtjddd|j�}|s.iSt|j|j|j|j	|j
�S(sw
        Crawl the metadata service when available.

        @returns: Dictionary of crawled metadata content.
        tlogfunctmsgs waiting for the metadata servicetfunc(Rtlog_timeRtinfoR7t
read_metadataRR	R
RR(Rtmetadata_ready((sH/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pytcrawl_metadataHs		cCs�|j�stStjdtjddd|j�}|s>tS|d|_|d|_|j	d�}i}|r�it
d6|d6itd	6d
6}ntj|j|g�|_t
S(s�Fetch the user data, the metadata and the VM password
        from the metadata service.

        Please refer to the datasource documentation for details on how the
        metadata server and password server are crawled.
        R8R9sCrawl of metadata serviceR:s	user-datas	meta-datatpasswordt
ssh_pwauthtexpiretchpasswd(
t_is_platform_viabletFalseRR;RRR?tuserdata_rawtmetadataRtTruet
mergemanydictR(RtdataR@tpassword_config((sH/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pyt	_get_dataZs*		

cCs|jS(N(R(R((sH/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pytget_config_obj�scCstjd�jt�S(Nssystem-product-name(Rt
read_dmi_datat
startswithtEXOSCALE_DMI_NAME(R((sH/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pyRD�s(t__name__t
__module__tdsnameR2RR,R7R?RLRMRD(((sH/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pyRs					,	cCstj|t�S(N(Rtlist_from_dependstdatasources(tdepends((sH/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pytget_datasource_list�sc
Cs�dj|||�}tj|dddidd6d|d|�}|jjd�}|dkredStj|dddid
d6d|d|�|S(
s�Obtain the VM's password if set.

    Once fetched the password is marked saved. Future calls to this method may
    return empty string or 'saved_password'.s	{}:{}/{}/tssl_detailstheaderstsend_my_passwordtDomU_RequestRRsutf-8ttsaved_passwordN(R\R](R0Rtread_file_or_urlR&tcontentstdecode(RR	R
RRtpassword_urltresponseR@((sH/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pytget_password�s$		
	
cCs�i}||d<yHtj||d|d|�|d<tj||d|d|�|d<Wn*tk
r�}tjtd||�iSXy/td|d|d	|d
|d|�|d<Wn,tk
r�}tjtd
|||�nX|S(s8Query the metadata server and return the retrieved data.t_metadata_api_versionRRs	user-datas	meta-datas(failed reading from metadata url %s (%s)R	RR
RRR@s2failed to read from password server url %s:%s (%s)(tec2tget_instance_userdatatget_instance_metadatat	ExceptionRtlogexcRRc(RR	R
RRtcrawled_metadatate((sH/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pyR=�s8


t__main__NtdescriptionsQuery Exoscale Metadatas
--endpointtmetavartURLthelps The url of the metadata service.tdefaults	--versiontVERSIONs.The version of the metadata endpoint to query.s	--retriestNUMttypes,The number of retries querying the endpoint.s	--timeouts.The time in seconds to wait before timing out.s--password-porttPORTs/The port on which the password endpoint listensRR	R
RR((t	cloudinitRReRtloggingRRRRt	getLoggerRQRRRRRRRPt
DataSourceRtDEP_FILESYSTEMtDEP_NETWORKRURWRcR=targparsetArgumentParsertparsertadd_argumentRt
parse_argstargstendpointtversiont
password_portRRRJt
json_dumps(((sH/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pyt<module>s�w	"