oB]c@s_ddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ej e Z dZdZdgZd e jfd YZd efd YZd efdYZdefdYZdZdZdddddZddZdZeZee jffgZ dZ!dS(iN(tlog(tnet(tsources(tutilsiid-dsopennebulatnobodys context.shtDataSourceOpenNebulacBsSeZdZdZdZdZdZedZe e e dZ RS(t OpenNebulacCsAtjj||||d|_tjj|jd|_dS(Nt opennebula( Rt DataSourcet__init__tNonetseedtostpathtjointseed_dir(tselftsys_cfgtdistrotpaths((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR &s cCs)tjj|}d||j|jfS(Ns%s [seed=%s][dsmode=%s](RRt__str__R tdsmode(Rtroot((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR+sc Csitd6}d}d}t}d|jkrC|jjd}n|jg}|jtx|D]}yXtj j |jrt |d|}n*|j drt j|t d|}nWnOtk rqfn<tk r}|n$t jk rtjd|nX|rf|}tjd|PqfqfW|sDtS|d}t j||g}|j|jd |jjd g|_|jtjkrtS||_|jd |_||_|jd |_tS( Ns instance-idt parseusertasusers/devtdatas%s was not mountablesfound datasource in %stmetadatatDSMODERsnetwork-interfacestuserdata( t DEFAULT_IIDR tDEFAULT_PARSEUSERtds_cfgtgetRtextendtfind_candidate_devsR R tisdirtread_context_disk_dirt startswithRtmount_cbtNonContextDiskDirtBrokenContextDiskDirtMountFailedErrortLOGtwarningtdebugtFalset mergemanydictt_determine_dsmodeRRtDSMODE_DISABLEDR tnetworkRt userdata_rawtTrue( RtdefaultstresultsR Rt candidatestcdevtexctmd((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyt _get_data/sL      '  cCs2|j|jkrd}nd}d||jfS(s/Return the subplatform metadata source details.sseed-dirs config-disks%s (%s)(RR (Rtsubplatform_type((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyt_get_subplatformbs cCs|jdk r|jSdSdS(N(R1R (R((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pytnetwork_configjscCsF|dkr0|jtjkr't}q0t}ntjj|||S(N(R RRtDSMODE_NETWORKR3R-Rt get_hostname(Rtfqdnt resolve_ipt metadata_only((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR?qs    ( t__name__t __module__tdsnameR RR:R<tpropertyR=R-R?(((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR"s   3 R'cBseZRS((RCRD(((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR'zsR(cBseZRS((RCRD(((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR(~stOpenNebulaNetworkcBseZddZdZdZdZdZdZdZ dZ dZ d Z d Z d Zdd Zd ZRS(cCs||_|dkr!t}ntjgt|jddD] }|^qC|_i|_xQ|jD]C\}}t j d|}|rq|j d|j|j ss ^(.+)_MAC$i( tcontextR tget_physical_nics_by_mact collectionst OrderedDicttsortedtitemstifacestcontext_devnametretmatchtgrouptlower(RRLtsystem_nics_by_macRJtvtm((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyR s   " cCs<djg|jddD]}tt|d^qS(Nt.t:ii(Rtsplittstrtint(Rtmactc((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pytmac2ipscCs|j|jdddS(NR[is.0(Rbt rpartition(RR`((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyt mac2networkscCsi}|j|ddj}|j|jjddj|rV||d_ (example: eth0_DOMAIN). an empty string for value will return default.t_RfN(NRf(RLR RtupperR (RRltnametdefaulttval((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pyRks'cCsi}d|d /dev/null Rt EPOCHREALTIMEt EPOCHSECONDStRANDOMtLINENOtSECONDSt__viitt=it_start_(s__v="";Rf(RRRRRRR( t isinstanceR^R Rtstringt ascii_lettersRR!RtsubpR]R t ValueError(tcontenttkeylistRRtswitch_user_cbtxtallvarst keylist_intsetupRtbcmdtcmdtoutputt_errortexcludedtpresettretttargettlineRHR((sJ/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceOpenNebula.pytparse_shell_configsR    $   .      !     cCsEi}xBtD]:}tjj||}tjj|r |||} t d | qptk r`} td | qpXn td |sz|S||ds2      X    W Y