ó oBú]c @s.ddlmZddlmZddlmZddlmZddlmZddlmZej e ƒZ dZ dZ d Zd Zd Zd 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.0ii 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_urlt api_versiontpassword_server_portttimeouttretries(tsuperRt__init__tLOGtdebugtds_cfgtgett METADATA_URLRt API_VERSIONR tinttPASSWORD_SERVER_PORTR t URL_TIMEOUTt url_timeoutt URL_RETRIESt url_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_waitR t 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_dependst datasources(tdepends((sH/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceExoscale.pytget_datasource_list•sc Cs•dj|||ƒ}tj|dd didd6d|d|ƒ}|jjdƒ}|d kred Stj|dd did d6d|d|ƒ|S( sObtain 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 {}:{}/{}/t ssl_detailstheaderstsend_my_passwordt DomU_RequestR R 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$      c Csçi}||ds€w   "