ó 'KXc@swddlZddlZddlZddlZddlZddlmZddlmZddlm Z ej e ƒZ dZ dZdZdgZdZd ejfd „ƒYZd efd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZd„Zd„Zddddd„Zdd„Zeejffeejej ffgZ!d„Z"dS(i’’’’N(tlog(tsources(tutilsiid-dsopennebulatnettnobodys context.shtlocaltdisabledtDataSourceOpenNebulacBs2eZd„Zd„Zd„Zedd„ZRS(cCsJtjj||||ƒd|_d|_tjj|j dƒ|_ dS(NRt opennebula( Rt DataSourcet__init__tdsmodetNonetseedtostpathtjointseed_dir(tselftsys_cfgtdistrotpaths((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR /s  cCs)tjj|ƒ}d||j|jfS(Ns%s [seed=%s][dsmode=%s](RR t__str__R R (Rtroot((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR5sc Csitd6}d}d}t}d|jkrC|jjdƒ}n|jg}|jtƒƒxŁ|D]Ń}yXtj j |jƒr™t |d|ƒ}n*|j dƒrĆt j|t d|ƒ}nWnPtk rŚqfn=tk rņ}|‚n%t jk rtjd|ƒnX|rf|}tjd|ƒPqfqfW|sEtS|d}t j||gƒ}|djd dƒ} | tdkr£tjd | ƒd} n| r²| } n-|jjd ƒrŁ|jjd ƒ} nt} | d krļtSd |kr1|jdkr1tjd|ƒ|jj|d ƒn| |jkrWtjd|| ƒtS||_||_|jdƒ|_tS(Ns instance-idt parseusertasusers/devtdatas%s was not mountablesfound datasource in %stmetadatatDSMODEsuser specified invalid mode: %sR Rsnetwork-interfacesRs#Updating network interfaces from %ss&%s: not claiming datasource, dsmode=%stuserdata(N( t DEFAULT_IIDR tDEFAULT_PARSEUSERtds_cfgtgetRtextendtfind_candidate_devsRRtisdirtread_context_disk_dirt startswithRtmount_cbtNonContextDiskDirtBrokenContextDiskDirtMountFailedErrortLOGtwarntdebugtFalset mergemanydictt VALID_DSMODESt DEFAULT_MODER Rt apply_networkR Rt userdata_rawtTrue( RtdefaultstresultsR Rt candidatestcdevtexctmdt user_dsmodeR ((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pytget_data9sd           cCsC|dkr-|jdkr$t}q-t}ntjj|||ƒS(NR(R R R4R.RR t get_hostname(Rtfqdnt resolve_ip((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR=s    N(t__name__t __module__R RR<R.R R=(((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR.s   FtDataSourceOpenNebulaNetcBseZd„ZRS(cCs#tj||||ƒd|_dS(NR(RR R (RRRR((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR ‰s(R@RAR (((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyRBˆsR(cBseZRS((R@RA(((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR(ŽsR)cBseZRS((R@RA(((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR)’stOpenNebulaNetworkcBs~eZejdejejBƒZd„Zd„Zd„Z d„Z d„Z d„Z d„Z d„Zd „Zd „ZRS( s3^\d+: (eth\d+):.*?link\/ether (..:..:..:..:..:..) ?cCs%||_||_|jƒ|_dS(N(tiptcontextt get_ifacestifaces(RRDRE((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR ›s  cCs|jj|jƒS(N(t REG_DEV_MACtfindallRD(R((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyRF scCs9|jdƒd}g|D]}tt|dƒƒ^qS(Nt:ii(tsplittstrtint(Rtmact componentstc((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pytmac2ip£scCs;|jƒd}||jkr*|j|Sdj|ƒSdS(Nt_IPt.(tupperRER(RtdevROtvar_name((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pytget_ip§s cCs2|jƒd}||jkr*|j|SdSdS(Nt_MASKs 255.255.255.0(RTRE(RRURV((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pytget_mask®s cCsC|jƒd}||jkr*|j|Sdj|d ƒdSdS(Nt_NETWORKRSi’’’’s.0(RTRER(RRURORV((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyt get_networkµs cCs2|jƒd}||jkr*|j|SdSdS(Nt_GATEWAY(RTRER (RRURV((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyt get_gateway¼s cCs2|jƒd}||jkr*|j|SdSdS(Nt_DNS(RTRER (RRURV((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pytget_dnsĆs cCs2|jƒd}||jkr*|j|SdSdS(Nt_DOMAIN(RTRER (RRURV((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyt get_domainŹs c CsŹg}d|jkr,|j|jdƒng}|jdƒ|jdƒ|jdƒxa|jD]V}|d}|d}|j|ƒ}|jd|ƒ|jd|d ƒ|jd |j||ƒƒ|jd |j||ƒƒ|jd |j|ƒƒ|j|ƒ}|r/|jd |ƒn|j|ƒ}|rX|jd|ƒn|j |ƒ} |ss| r¬|} | r| j| ƒn|jddj | ƒƒn|jdƒqcWdj |ƒS(NtDNSsauto losiface lo inet loopbacktiisauto siface s inet statics address s network s netmask s gateway s dns-search s dns-nameservers t s ( REtappendRGRQRWR[RYR]RaR_R( Rt global_dnstconftiRURNt ip_componentstgatewaytdomaintdnstall_dns((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pytgen_confŃs<      (R@RAtretcompilet MULTILINEtDOTALLRHR RFRQRWRYR[R]R_RaRn(((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyRC–s         cCsag}xTdD]L}tj|ƒ}|jƒx*|D]"}||kr3|j|ƒq3q3Wq W|S(sE Return a list of devices that may contain the context disk. s LABEL=CONTEXTs LABEL=CDROMs TYPE=iso9660(s LABEL=CONTEXTs LABEL=CDROMs TYPE=iso9660(Rtfind_devs_withtsortRe(tcombinedtftdevstd((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR#ūs    cCs dd|gS(Ntsudos-u((tuser((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pytswitch_user_cmd scCs!t|tƒr|g}n|dkr6ddg}n|dkrKt}ngtjdD]}d|^qY}|}|dkr|}g}ndjdƒ}d„} d || |ƒd |d | |ƒd} g} |dk r÷||ƒ} n| j|ƒtj | d | ƒ\} } d}i}i}d}| dd!} xÖ| j dƒD]Å}yo|j ddƒ\}}||krŽ||| /dev/null RtRANDOMtLINENOtSECONDSt__vii’’’’tt=it_start_(s__v="";Rc(RR‚RƒR}R„( t isinstanceRLR R{tstringtlettersRR"RtsubpRKR!t ValueError(tcontenttkeylistR|Rtswitch_user_cbtxtallvarst keylist_intsetupR€tbcmdtcmdtoutputt_errortexcludedtpresettretttargettlinetkeytval((sS/opt/freeware/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pytparse_shell_configsP    $   .      !     cCsji}xBtD]:}tjj||ƒ}tjj|ƒr |||s4      Ze    U \