x[hddlZddlmZddlmZmZddlmZddlm Z ddl m Z ejeZddiZd Zd Zd ZGd d ej(ZGd deZeej.ffeej.ej0ffgZdZy)N)net)sourcesutil)NoDHCPLeaseError)EphemeralDHCPv4)upcloud metadata_urlz'http://169.254.169.254/metadata/v1.jsoncBeZdZdZdZdZdZdZdZdZ e dZ y ) DataSourceUpCloudUpCloudFctjj||||||_t |_t jt j|ddgitg|_ |jd|_ |jjdt|_|jjdt|_|jjdt"|_d|_d|_y)N datasourcerr retriestimeout wait_retry)r DataSource__init__distrodictmetadatar mergemanydictget_cfg_by_pathBUILTIN_DS_CONFIGds_cfgmetadata_addressget MD_RETRIESr MD_TIMEOUTr MD_WAIT_RETRYr_network_config metadata_full)selfsys_cfgrpathss E/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceUpCloud.pyrzDataSourceUpCloud.__init__"s##D'65A  (($$W|Y.GL!   !% N ;{{y*= {{y*= ++//, F#!c*tjSN) uc_helper read_sysinfor$s r' _get_sysinfozDataSourceUpCloud._get_sysinfo3s%%''r(ctj|j|j|j|j S)N)r sec_betweenr)r+ read_metadatarrrrr-s r'_read_metadataz DataSourceUpCloud._read_metadata6s3&&  ! !LLLL   r(c|j\}}|sytjd||jrp tj dt j }tj d|t|j|5|j}dddn& tj d|j}|_|j#d||j$d<|j#d |j$d <|j#d |j$d <|j#d |j$d <|j#dd|j$d<|j#dd|_|j#dd|_y#1swYxYw#ttjf$r-}tjtt|Yd}~yd}~wwxYw#tj$rC}tjtt|tjd|Yd}~yd}~wwxYw)NFz"Running on UpCloud. server_uuid=%szFinding a fallback NICz*Discovering metadata via DHCP interface %sz7Discovering metadata without DHCP-configured networkingzENo DHCP-enabled interfaces available, unable to fetch metadata for %s instance_idz instance-idhostnamezlocal-hostnamenetwork public_keysz public-keysregiondefaultavailability_zone vendor_data user_dataT)r.LOGinfoperform_dhcp_setupdebugcloudnetfind_fallback_nicrrr2rrInvalidMetaDataExceptionrlogexcstrr#rrvendordata_raw userdata_raw)r$ is_upcloud server_uuidnicmdes r' _get_datazDataSourceUpCloud._get_data>s$($5$5$7![ 5{C  " "  23002 FL$T[[#6/,,.B/  M((* ')vvm['I m$*,&&*< &'#%66)#4 i ')vvm'< m$-/VVHi-H )* ff]D9FF;5;//$g&F&FG  CQ( 33  CQ(6  sHAF)F F)*%G2F&"F))G/#G**G/2I9IIcHtj|jSr*)rinstance_id_matches_system_uuidget_instance_id)r$r%s r'check_instance_idz#DataSourceUpCloud.check_instance_idks66t7K7K7MNNr(c|jr |jS|jjd}|s tdt j ||_|jS)z Configure the networking. This needs to be done each boot, since the IP and interface information might have changed due to reconfiguration. r6z/Unable to get network meta-data from server....)r"rr RuntimeErrorr+convert_network_config)r$raw_network_configs r'network_configz DataSourceUpCloud.network_confignsg   '' '!]]..y9!A  )??  ###r(N) __name__ __module__ __qualname__dsnamer?rr.r2rMrQpropertyrVr(r'r r s> F""( +ZO$$r(r ceZdZdZdZy)DataSourceUpCloudLocalaz Run in init-local using a DHCP discovery prior to metadata crawl. In init-local, no network is available. This subclass sets up minimal networking with dhclient on a viable nic so that it can talk to the metadata service. If the metadata service provides network configuration then render the network configuration for that instance based on metadata. TN)rWrXrY__doc__r?r\r(r'r^r^sr(r^c6tj|tSr*)rlist_from_depends datasources)dependss r'get_datasource_listrds  $ $Wk ::r()logging cloudinitrrArrcloudinit.net.dhcprcloudinit.net.ephemeralrcloudinit.sources.helpersrr+ getLoggerrWr=rrr r!rr r^DEP_FILESYSTEM DEP_NETWORKrbrdr\r(r'rms%#/3:g!#%NO   h$**h$V . g4467//1D1DEF ;r(