Viewing File: /usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyc


jbc@s{ddlZddlZddlZddlmZddlZddlZddlZddlZddl	m	Z	ddl
mZddlj
jZddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZmZmZddlmZdd
l m!Z!ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*ej+e,Z-dZ.idd6Z/dddgZ0dZ1dddgZ2dddgZ3dZ4dZ5dZ6dZ7dZ8dZ9d Z:d!Z;d"Z<d#Z=d$Z>d%d&d'd(gZ?d)Z@d*ZAd+ZBeCd,ZDd-ZEd.ZFd/ZGd0ZHejIrd1Z5d2Z6d3Z7eHd4ZJeJeCk	re-jKd5d6eJZ4n
e-jKd7eCZ>nie1d86e;d96eLd:6ie5d;6eLd<6d=d>6d?d@6dA6ie4dB6dC6e6dD6eLdE6ZMiiidFdG6dHgdI6eLdJ6dB6dK6ie7dL6dMdN6gdO6ZNdPe.gZOdQZPdRZQdSZRd?dTZSd?dUZTe$ejUd?dVZVdWejWfdXYZXdYdZZYe$d[ZZe$d\Z[e$e4d]e\e\d^Z]e$d_Z^e$eCd`Z_e$daZ`e$eCdbZae$dcZbddZce$deZde$dfZee$dgZfdhdiZge$djZhe$e>dkZie$dlZje$dmZkdnZle$doZme$dpZne$eCdqZodrZpdseqfdtYZrdueqfdvYZseXZteXejuffgZvdwZwdS(xiN(tpartial(ttime(tminidom(tlog(tnet(t	EventType(tEphemeralDHCPv4(tsources(tnetlink(tUrlErrortreadurltretry_on_url_exc(tutil(tevents(tazure_ds_reportertazure_ds_telemetry_reportertget_metadata_from_fabrictget_boot_telemetrytget_system_infotreport_diagnostic_eventtEphemeralDHCPv4WithReportingtis_byte_swappedtAzuresiid-AZURE-NODEsinstance-idtservicetwalinuxagenttstartt__builtin__tshs-xcs>i=$interface; x=0; ifdown $i || x=$?; ifup $i || x=$?; exit $xsLi=$interface; x=0; ifconfig down $i || x=$?; ifconfig up $i || x=$?; exit $xs/dev/disk/cloud/azure_resourceteth0s"/var/lib/dhcp/dhclient.eth0.leasestext4s 7783-7084-3265-9085-8269-3286-77s/var/lib/cloud/data/poll_imdss"/var/lib/cloud/data/reported_readys/var/lib/waagentis http://169.254.169.254/metadata/s/sys/firmware/acpi/tables/OEM0s"/etc/netplan/90-hotplug-azure.yamls /usr/local/sbin/ephemeral_eth.shs+/etc/udev/rules.d/10-net-device-added.ruless#/run/network/interfaces.ephemeral.dcCsx|jD]}tjd|r
|j}t|dkr|djd}t|dkr|ddkr|dj|r|djd}|dSqq
q
Wd	S(
s
    dev.storvsc.1.%pnpinfo:
        classid=32412632-86cb-44a2-9b5c-50d1417354f5
        deviceid=00000000-0001-8899-0000-000000000000
    tpnpinfoiit=itdeviceidit.N(t
splitlinestretsearchtsplittlent
startswithtNone(t
sysctl_outR tlinetfieldstcolumnstcomps((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyt"find_storvscid_from_sysctl_pnpinfoTscCsAx:|jD],}tj||r
|j}|dSq
WdS(s
    scbus0 on ata0 bus 0
    scbus1 on ata1 bus 0
    scbus2 on blkvsc0 bus 0
    scbus3 on blkvsc1 bus 0
    scbus4 on storvsc2 bus 0
    scbus5 on storvsc3 bus 0
    scbus-1 on xpt0 bus 0
    iN(R"R#R$R%R((tcamcontrol_outtdisk_drvR*titems((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytfind_busdev_from_diskhs
cCslxe|jD]W}tj||r
|jd}t|dkrd|djd}|dSq
q
WdS(s
    <Msft Virtual CD/ROM 1.0>          at scbus1 target 0 lun 0 (cd0,pass0)
    <Msft Virtual Disk 1.0>            at scbus2 target 0 lun 0 (da0,pass1)
    <Msft Virtual Disk 1.0>            at scbus3 target 1 lun 0 (da1,pass2)
    t(iit,iN(R"R#R$R%R&R((R/tbusdevR*R1tdev_pass((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytfind_dev_from_busdev{scCsJytj|dSWn.tjk
rEtjddj||SXdS(NisFailed to execute: %st (RtsubptProcessExecutionErrortLOGtdebugtjoin(tcmdtfail_ret((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytexecute_or_debugs
cCstddgddS(Ntsysctlsdev.storvscR?t(R@(((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytget_dev_storvsc_sysctlscCstdddgS(Nt
camcontroltdevlists-b(R@(((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytget_camcontrol_dev_busscCstddgS(NRDRE(R@(((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytget_camcontrol_devscCs4d}|dkr%d}|d}ndt|}dj||}t}t||}|svtjddSt}t}dj|}t	||}	|	rt
||	}
|
dkrtjd	dS|
Sd
j|}t	||}	|	r0t
||	}
|
dkr,tjd	dS|
SdS(Nt00000000it00000001it000s{0}-{1}s#Fail to find storvsc id from sysctls	blkvsc{0}sFail to find /dev/daXs
storvsc{0}(tstrtformatRCR.R;R<R(RFRGR2R7(tport_idtg0tg1tg0g1R)t	storvscidtcamcontrol_b_outR/tblkvsctscbusxtdevnametstorvsc((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytget_resource_disk_on_freebsds<
	
		

thn0s/var/db/dhclient.leases.hn0sfreebsd-ufsisresource disk is not Nones/dev/sresource disk is Nonet
agent_commandtdata_dirtset_hostnamet	interfacetpolicytbuiltintcommandthostnamethostname_commandthostname_bouncet
ephemeral0tdisk_aliasestdhclient_lease_filetapply_network_configtgptt
table_typeidtlayoutt	overwritet
disk_setupt
filesystemsephemeral0.1tdevicetfs_setupt
datasourcetnever_destroy_ntfssTemporary StoragetREDACTEDcCs>t|ttfs!|f}ntj|dtdjS(Ntcapturei(t
isinstancetlistttupleRR9tTruetstrip(Ra((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytget_hostnamescCs tjddt|gdS(Nthostnamectlsset-hostname(RR9RK(R`Ra((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyR[sc	cs|dd}t|}tj|jdsZtj|sZ||krc|dkrcdVdSt||z	|VWdt||XdS(s
    Set a temporary hostname, restoring the previous hostname on exit.

    Will have the value of the previous hostname when used as a context
    manager, or None if the hostname was not changed.
    RbR]R[tforceN(RxRtis_truetgettis_falseR(R[(t
temp_hostnametcfgRaR]tprevious_hostname((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyttemporary_hostnames	
	tDataSourceAzurecBs4eZdZeZejZdZdZ	e
dZe
dZdZ
e
dZdZddZe
d	Zd
ZdZdZdd
Ze
dZdZe
dZdZdZe
dZe
dZedZedZ edZ!RS(RcCstjj||||tjj|jd|_i|_d|_	t
jt
j|t
itg|_|jjd|_d|_|jdjtjd|_dS(NtazureRetnetwork(Rt
DataSourcet__init__tostpathR=tseed_dirRR(tseedRt
mergemanydicttget_cfg_by_pathtDS_CFG_PATHtBUILTIN_DS_CONFIGtds_cfgR|Ret_network_configt
update_eventstaddRtBOOTt_ephemeral_dhcp_ctx(tselftsys_cfgtdistrotpaths((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyR#s			cCs#tjj|}d||jfS(Ns%s [seed=%s](RRt__str__R(Rtroot((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyR1scCs|jjd}tjd||jdd}t||jd|}|dk	rtj|jjdr|jd}yt	d|d|d|SWqt
k
r}tjd	|tjtd
qXnWdQXt
S(Nslocal-hostnamesHostname in metadata is %sRbRaR[R`Rt
prev_hostnamesFailed publishing hostname: %sshandling set_hostname failed(tmetadataR|R;R<RRR(RR{tperform_hostname_bouncet	ExceptiontwarningtlogexctFalse(Rtazure_hostnameRatprevious_hnRte((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyt"bounce_network_with_azure_hostname5s"	
c
Cs|jjd}|jd}tjd|||jyt|Wn.tjk
rztj	td|jdnX|jd}g}d}x|jjdgD]o}|jddr|d}tjdqt|d	d
}|t
jj||g7}tjdqWtjdd
dddtTtjdtjdddtjd|df}t|rtjd|nWdQXi}	|pt||	d<|	S(Nslocal-hostnameRYs/Getting metadata via agent.  hostname=%s cmd=%ssagent command '%s' failed.RZt_pubkeystvalues+ssh authentication: using value from fabrictfingerprints.crts1ssh authentication: using fingerprint from fabrictnameswaiting-for-ssh-public-keytdescriptions$wait for agents to retrieve ssh keystparenttlogfunctmsgs waiting for SSH public key filestfunctargsis$Did not find files, but going on: %sspublic-keys(RR|RR;R<Rtinvoke_agentRR:RR(RRKRRR=R
tReportEventStackRtlog_timetwait_for_filesR&Rtpubkeys_from_crt_files(
RR~t	agent_cmdtddirtfp_filest	key_valuetpktbnametmissingR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytget_metadata_from_agentOsB
	



	
	cCs2|jjdrd}nd}d||jfS(s/Return the subplatform metadata source details.s/devsconfig-disksseed-dirs%s (%s)(RR'(Rtsubplatform_type((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyt_get_subplatform~s	c	Csi}|jd}|jg}tjjtrD|jddn|jt|rj|j	|nd}t}x|D]}yv|dkrd}t}nW|j
drtjrtj|tdd}qtj|t}nt|}Wntk
rtd|q}nmtk
rR}d|}	t|	tj|	n8tjk
rd	|}	t|	tj|	q}nX|p|j|}
|
rtjrd
}	tj|	t|	tj|	n|j}nt|jdd}|\}}
}}||_|j i|d
6|d6tj!|i|d6gd6|
d6|}tj"d|Pq}W|sd}	t|	tj|	n||krtj"d|nt#}|r||dd<n|j$|dd<|
rtj%dt&j'|jo(t(|dd}|rW|j)d|j*j+|j*j,qy)t-t.}|j)d|WdQXWqt/k
r}td|qXn|S(sWalk all instance metadata sources returning a dict on success.

        @return: A dictionary of any metadata content for this instance.
        @raise: InvalidMetaDataException when the expected metadata service is
            unavailable, broken or disabled.
        RZitIMDSs/dev/tmtypetudfs$Did not find Azure data source in %ssBrokenAzureDataSource: %ss%s was not mountables%Free BSD is not supported for PPS VMstretriesi
RtfilestimdsRtuserdata_rawsfound datasource in %ssNo Azure metadata foundsusing files cached in %strandom_seedsinstance-ids6Reporting ready to Azure after getting ReprovisionDataRtleaseNs#exception while reporting ready: %s(0RRRRtisfiletREPROVISION_MARKER_FILEtinserttextendtlist_possible_azure_ds_devstappendR(RRvR'Rt
is_FreeBSDtmount_cbtload_azure_ds_dirtNonAzureDataSourceRtBrokenAzureDataSourceRtInvalidMetaDataExceptiontMountFailedErrorR;Rt_should_reprovisionterrort_reprovisiontget_metadata_from_imdstfallback_interfaceRtupdateRR<t_get_random_seedt_iidtinfoRtis_uptgetattrt
_report_readyRRt
clean_networkRRR(Rtcrawled_dataRt
candidatestfoundtreprovisiontcdevtrettexcRtperform_reprovisiontimds_mdtmdRRRRtuse_cached_ephemeralRR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytcrawl_metadatas

	







		
	

cCs
t|jS(s@Check platform environment to report if this datasource may run.(t_is_platform_viableR(R((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRscCs&tt|j|tj|_dS(s.Reset any cached class attributes to defaults.N(tsuperRtclear_cached_attrsRtUNSETt_metadata_imds(Rt
attr_defaults((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRscCs|jstSytWn#tk
r@}tjd|nXytWn#tk
rq}tjd|nXy(tjdtj	ddd|j
}Wn'tjk
r}tjd|tSX|j
r|j
jdkr|jjd	rtntj|d
tg|_|dd|_tj|dtg|_|d
|_tj|jti}tj||jg|_t|jd|dddtS(sCrawl and process datasource metadata caching metadata as attrs.

        @return: True on success, False on error, invalid or disabled
            datasource.
        s Failed to get boot telemetry: %ss$Failed to get system information: %sRRsCrawl of metadata serviceRs"Could not crawl Azure metadata: %stubuntuRfRRRRRZRtdirmodei(RRRRR;RRRRR<RRRRRRR|t*maybe_remove_ubuntu_network_config_scriptsRtBUILTIN_CLOUD_CONFIGRRtDEFAULT_METADATARRRRtwrite_filesRv(RRRtuser_ds_cfg((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyt	_get_datas>	

cCs|jdj|S(NRd(RR|(RR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytdevice_name_to_device'scCs|jS(N(R(R((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytget_config_obj*scCstj|jS(N(Rtinstance_id_matches_system_uuidtget_instance_id(RR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytcheck_instance_id-scCsqtjj|jjdd}tjd}tjj|rmtj|j	}t
||rm|Sn|S(Ntdatasinstance-idssystem-uuid(RRR=Rt	get_cpathRt
read_dmi_datatexistst	load_fileRwR(Rtprevioust
prev_iid_pathtiid((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyR1s	cCs|jtkritjd|j||j}tjd||r]|jj|nt|_ntjd|jdS(Ns$negotiating for %s (new_instance=%s)snegotiating returned %ssnegotiating already done for %s(	t_negotiatedRR;R<Rt
_negotiateRRRv(Rtis_new_instancetfabric_data((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytsetup;s		c
std}idd6}d
}ttjjt}d_d_d}t	}d
}fd}t
jdxtrzyt
jdd	d
ddt t_jj}	Wd
QX|r|d7}n|rytj}Wn;tjk
r+}
t|
t
j|
jjPnXt}t
jd|tj|djdtjdtjd|	t	}t
jddd
ddtKytj ||	dWn+t!k
r}t|t
j"|PnXWd
QXt}jjnSt
jddd
ddt2t#|dt$d|d|dtdt	j%}Wd
QXPWnt&k
rxjjnXWd
|r|j'nXqyW|rtd|tdjn|S(stPoll IMDS for the new provisioning data until we get a valid
        response. Then return the returned JSON object.s&reprovisiondata?api-version=2017-04-02ttruetMetadataiicst|tr|jdkrjjkrqjd9_tjd||jjtjdjnjd7_tStjd||jtd|jt	S(NiisJCall to IMDS with arguments %s failed with status code %s after %s retriess:Backing off logging threshold for the same exception to %dis:Call to IMDS with arguments %s failed  with status code %ss%polling IMDS failed with exception %s(
RsR	tcodetimds_poll_countertimds_logging_thresholdR;R<RvRR(Rt	exception(R(sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytexc_cbVs		
	
sWait for vnetswitch to happenRsobtain-dhcp-leaseRsobtain dhcp leaseRNs*Creating a marker file to report ready: %ss{pid}: {time}
tpidRRs!wait-for-media-disconnect-connectswait for vnet switchR\sget-reprovision-data-from-imdssget reprovision data from imdsttimeouttheaderstexception_cbtinfinitetlog_req_resps#attempted dhcp %d times after reuses polled imds %d times after reuse((tIMDS_URLR(tboolRRRtREPORTED_READY_MARKER_FILERRRR;R<RvR
RRRRtobtain_leaseRtcreate_bound_netlink_sockettNetlinkCreateSocketErrorRRRRRt
write_fileRLtgetpidRRt!wait_for_media_disconnect_connecttAssertionErrorRR
tIMDS_TIMEOUT_IN_SECONDStcontentsR	tclose(
RturlRtnl_socktreport_readyt
dhcp_attemptst
vnet_switchedt
return_valRRRRR((RsE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyt
_poll_imdsIs

		
		





	


	
	

cCs@ytd|dWn$tk
r;tjddtnXdS(s,Tells the fabric provisioning has completed sunknown-245sNError communicating with Azure fabric; You may experience.connectivity issues.texc_infoN(RR(RR;RRv(RR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs
cCs|s
tS|\}}}}t}|jdtksItjj|rtjj|stjd|t	j
|djdtjdt
ntStS(sWhether or not we should poll IMDS for reprovisioning data.
        Also sets a marker file to poll IMDS.

        The marker file is used for the following scenario: the VM boots into
        this polling loop, which we expect to be proceeding infinitely until
        the VM is picked. If for whatever reason the platform moves us to a
        new host (for instance a hardware issue), we need to keep polling.
        However, since the VM reports ready to the Fabric, we will not attach
        the ISO, thus cloud-init needs to have a way of knowing that it should
        jump back into the polling loop in order to retrieve the ovf_env.tPreprovisionedVms'Creating a marker file to poll imds: %ss{pid}: {time}
RR(RRR|RvRRRR;RRR!RLR"R(RRt_mdt
_userdata_rawRt_filesR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs	c
Csa|j}tjdddddt1t|\}}}|||i|d6fSWdQXdS(s%Initiate the reprovisioning workflow.Rsreprovisioning-read-azure-ovfRs$read azure ovf during reprovisioningRsovf-env.xmlN(R.R
RRtread_azure_ovf(RR&RtudR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs	
cCs|jdtkrP|j|jjdd	}ttd|jd|}n	|j	}t
jd|jdy
|}Wn5tk
r}t
d|t
jddttSXtjttjt|S(
sNegotiate with fabric and return data from it.

           On success, returns a dictionary including 'public_keys'.
           On failure, returns False.
        RYRtfallback_lease_filetpubkey_infos,negotiating with fabric via agent command %ssQError communicating with Azure fabric; You may experience connectivity issues: %ssNError communicating with Azure fabric; You may experience connectivity issues.R/N(RtAGENT_START_BUILTINRRR|R(RRReRR;R<RRRRvRRtdel_fileRR(RR7t
metadata_funcRR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyR
s,
				


cCs&td|d|jjttdS(NRt
preserve_ntfs(taddress_ephemeral_resizeRR|tDS_CFG_KEY_PRESERVE_NTFSR(RRR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytactivates	
cCs(|jjdijdijdS(NRtcomputetplatformFaultDomain(RR|(R((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytavailability_zones	cCsY|js|jtjkrR|jjdr:|j}nd}t||_n|jS(sGenerate a network config like net.generate_fallback_network() with
           the following exceptions.

           1. Probe the drivers of the net-devices present and inject them in
              the network configuration under params: driver: <driver> value
           2. Generate a fallback network config that does not include any of
              the blacklisted devices.
        RfN(RRRRR|RR(tparse_network_config(Rtnc_src((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytnetwork_configs
cCs(|jjdijdijdS(NRR?tlocation(RR|(R((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytregion"s(N("t__name__t
__module__tdsnameRR	RRRRRRRRRRRRRRRRR(RR
R.RRRR
R>tpropertyRARDRF(((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs4			/	i	/			
	j
		
$icCsxdD]x}g}x_td|D]N}||t|}tjj|r#|j|tjj|fq#q#W|r|SqWgS(Ns-parttpRBi(s-partRKRB(trangeRKRRRRtrealpath(tdevpathtmaxnumtsuffRtpnumtppath((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyt_partitions_on_device's
&cCs;tjddt}tjd|tjj||kS(Ns	TYPE=ntfstno_cachesntfs_devices found = %s(Rtfind_devs_withRvR;R<RRRM(RNtntfs_devices((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyt_has_ntfs_filesystem4sc
Cs\|r)ddjttf}t|fStjj|sItd|fStjd|tjj	|t
|}t|dkrtd|fSt|dkrd|d	jg|D]}|d
^qf}t|fSt|dkr|d
\}}n|d\}}t|s>d|||f}t|fSt
d}d
|||f}tjdddddt}	y)tj||dddidd6}
WnTtjk
r}d|	_dt|krt|dfSt|d||ffSX|
dkrHd|
|	_tjddjttt|d|
fSWdQXt|dfS( sDetermine if the ephemeral drive at devpath should be reformatted.

    A fresh ephemeral disk is formatted by Azure and will:
      a.) have a partition table (dos or gpt)
      b.) have 1 partition that is ntfs formatted, or
          have 2 partitions with the second partition ntfs formatted.
          (larger instances with >2TB ephemeral disk have gpt, and will
           have a microsoft reserved partition as part 1.  LP: #1686514)
      c.) the ntfs partition will have no files other than possibly
          'dataloss_warning_readme.txt'

    User can indicate that NTFS should never be destroyed by setting
    DS_CFG_KEY_PRESERVE_NTFS in dscfg.
    If data is found on NTFS, user is warned to set DS_CFG_KEY_PRESERVE_NTFS
    to make sure cloud-init does not accidentally wipe their data.
    If cloud-init cannot mount the disk to check for data, destruction
    will be allowed, unless the dscfg key is set.s:config says to never destroy NTFS (%s.%s), skipping checksR!sdevice %s does not existsResolving realpath of %s -> %sisdevice %s was not partitionedis&device %s had 3 or more partitions: %sR8is5partition %s (%s) on device %s was not ntfs formattedcSsGtdg}tgtj|D]}|j|kr"|^q"S(Nsdataloss_warning_readme.txt(tsetR&Rtlistdirtlower(tmptignoredtf((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytcount_fileslss1partition %s (%s) on device %s was ntfs formattedRsmount-ntfs-and-countRRRtntfstupdate_env_for_mounttCtLANGscannot mount ntfssunknown filesystem type 'ntfs's^ but this system cannot mount NTFS, assuming there are no important files. Formatting allowed.s but mount of %s failed: %ssmounted and counted %d filessxit looks like you're using NTFS on the ephemeral disk, to ensure that filesystem does not get wiped, set %s.%s in configs but had %d files on it.Ns3 and had no important files. Safe for reformatting.(R=RR=RRRRR;R<RMRSR&RWRR
RRRRRRRKRvR(RNR;Rt
partitionsRKt	cand_partt	cand_pathR^tbmsgtevtt
file_countR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytcan_dev_be_reformatted;sX
-

		
	ixcCsdd}tjdddddtFtj|gd|d|d	d
}|rftjd||dSWdQXt}d}|rt	d}}nt
||\}}tjd
|||sdSxddgD]}d|}	d|	|f}
tj
j|	rLy!tj|	tjd|
Wq\tk
rH}tjd|
|q\Xqtjd|
qWdS(Ng?Rswait-for-ephemeral-diskRswait for ephemeral diskRtmaxwaittnaplentlog_presAzure ephemeral disk: s6ephemeral device '%s' did not appear after %d seconds.sFirst instance boot.sreformattable=%s: %sRktmountss#/var/lib/cloud/instance/sem/config_sMarker "%s" for module "%s"s%s removed.s%s: remove failed! (%s)s%s did not exist.(R
RRRRR;RRR(RvRiR<RRRtunlinkR(RNRjRR;RkRtresultRtmodtsempathRfR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyR<s@	
		



c	
Cs|d}|d}|d}d|||f}tjj}||d<||d<||d<|dkrtjrt}qtjdrt}qtj	d	t
Sntj	d
|t|tt
f}tjdtj	dd
dtdtjdi|d6|d6t
d6|d6tS(NR_R\R]s"hostname=%s policy=%s interface=%sR`told_hostnameR^tifups7Skipping network bounce: ifupdown utils aren't present.s"pubhname: publishing hostname [%s]RRspublishing hostnamet
get_uptimeRtkwargsRtshellRrtenv(RtenvirontcopyRRtBOUNCE_COMMAND_FREEBSDtwhichtBOUNCE_COMMAND_IFUPR;R<RRsRtRuRRvR9(	R`RRR_R\R]RRwRv((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs0





		cCs=d}tjdd||gdtd|\}}|jS(NsHopenssl x509 -noout -pubkey < "$0" |ssh-keygen -i -m PKCS8 -f /dev/stdinRs-cRrR(RR9Rvtrstrip(tfnameRtpipelinetoutt_err((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytcrtfile_to_pubkeyscCsug}g}xI|D]A}y|jt|Wqtjk
rS|j|qXqW|rqtjd|n|S(Ns-failed to convert the crt files to pubkey: %s(RRRR:R;R(tflisttpubkeysterrorsR~((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs
cCsd}|sdS|s"i}ntj||xi|jD][\}}tjj||}d|kr~|||}ntjd|d|ddq?WdS(NcSsyatj|}x>|jD]0}d|jkr|jtkrt|_qqWtj|SWn"tk
rtj	d||SXdS(s>Azure provides the UserPassword in plain text. So we redact ittUserPasswords#failed to redact userpassword in %sN(
tETt
fromstringtiterttagttexttDEF_PASSWD_REDACTIONttostringRR;tcritical(tcntR~Rtelem((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyt_redact_passwords
sovf-env.xmltfilenametcontenttmodei(Rt
ensure_dirR1RRR=R!(tdatadirRRRRRR~((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs	
	cCsG|r6tjd|tj|dt|tn
tjddS(Nsinvoking agent: %sRvsnot invoking agent(R;R<RR9RsRt(R>((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs cCsJg}|js|Sx-|jD]"}||r |j|q q W|S(N(t
hasChildNodest
childNodesR(tnodetfilter_funcRtchild((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyt
find_childsc
Cst|d}t|dkr(gSt|dkrStdt|n|d}t|d}t|dkrgSg}tjj}x|D]}|jsqnidd6dd6dd	6}x|jD]}|j|ks|j	rqn|j	j
}	|	|jkr'qnt|jdks|jdj|krXqn|jdjj
||	<qW|j|qW|S(
NcSs
|jdkS(Nt
PublicKeys(t	localName(tn((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyt<lambda>6siis%Multiple 'PublicKeys'(%s) in SSH nodecSs
|jdkS(Nt	PublicKey(R(R((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyR>sRBRRR(RR&RRtDocumentt	TEXT_NODERRtnodeTypeRRZtkeyst	wholeTextRwR(
tsshnodetresultstpubkeys_nodeRRt	text_nodetpk_nodetcurRR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytload_azure_ovf_pubkeys)s8


c	CsSytj|}Wn3tk
rH}d|}t|t|nXt|jd}t|dkrtdnt|dkrtdt|n|d}t|d}t|dkrtdnt|dkrtd	t|d
fn|d}|j	s=tdnd}iid
6}	i}
d}d}d}
x?|jD]4}|j|j
ksr|jrqrn|jj}t}d}t|jdkr|jdj|j
krt}|jdj}ntg|jjD]\}}||f^q}|dksH|dkr|jdd%kr~tjdj|j}q|}qr|dkr|}
qr|dkr|}qr|dkr||	d<qr|dkr5|jdd&krtjdj|j}n|}itj|dit6|
d<qr|dkrTt||
d<qr|dkrvtj||
d<qr|rr||kr||	|<q||	d
|<qrqrWi}|
r|
|d<n|rt|d<t |krt!||d <|
d!<qn|ri|d"6|
d#<nd|
kr6|r6t|
d<nt"||
d$<|	||
fS('NsInvalid ovf-env.xml: %scSs
|jdkS(NtProvisioningSection(R(R((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRhsisNo ProvisioningSectionis$found '%d' ProvisioningSection itemscSs
|jdkS(Nt!LinuxProvisioningConfigurationSet(R(R((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRrss$No LinuxProvisioningConfigurationSetsfound '%d' %ssRs#no child nodes of configuration settseedfromt
azure_dataRBtuserdatat
customdatatencodingtbase64tusernametuserpasswordR`slocal-hostnametdscfgtdefaultRotsshRt disablesshpasswordauthenticationt
ssh_pwauthRtlock_passwdtpasswdtpasswordtdefault_usertsystem_infoR0(Nsbase64(Nsbase64(#RtparseStringRRRRtdocumentElementR&RRR(RRRRRZRRvRtdictt
attributesR1R|Rt	b64decodeR=R%Rt	load_yamltDS_NAMERR}Rtencrypt_passt"_extract_preprovisioned_vm_setting(R&tdomRt	error_strRtprovSectiont
lpcs_nodestlpcstmd_propsRRR5RRRRtsimpleRtktvtattrsRtdefuser((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyR4^s

	
	

4!			
!#



cCst|jd}|s.t|dkr?tjdtSt|dd}|snt|dkrtjdtSt|dd}|st|dkrtjdtStj|djj	S(sPRead the preprovision flag from the ovf. It should not
       exist unless true.cSs
|jdkS(NtPlatformSettingsSection(R(R((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRsis!PlatformSettingsSection not foundcSs
|jdkS(NtPlatformSettings(R(R((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRssPlatformSettings not foundcSs
|jdkS(NR0(R(R((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRssPreprovisionedVm not found(
RRR&R;R<RRttranslate_boolt
firstChildt	nodeValue(Rtplatform_settings_sectiontplatform_settingstpreprovisionedVm((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs&


s$6$cCs tj||tjddS(Ntstrleni(tcryptRtrand_str(Rtsalt_id((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRscCsRy*t|}|jdtSWdQXWn!tk
rMtjd|nXtS(s;Return boolean indicating path to cdrom device has content.iNscdrom (%s) is not configured(topentreadRvtIOErrorR;R<R(t	cdrom_devtfp((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyt_check_freebsd_cdroms

cCsD|dkrdStj|dtdt}tj|j}|S(sLReturn content random seed file if available, otherwise,
       return None.tquiettdecodeN(R(RRRvRRt	b64encodeR(tsourceR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs
cCsmg}tjr.d}t|rY|gSn+x(dD] }|jtjd|q5W|jdt|S(Ns/dev/cd0tiso9660RsTYPE=%streverse(Rsudf(RRRRRUtsortRv(RERtfstype((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs

cCstjj|d}tjj|s6tdnt|d}|j}WdQXt|\}}}|||i|d6fS(Nsovf-env.xmlsNo ovf-env file foundtrb(RRR=RRRRR4(t
source_dirtovf_fileRR&RR5R((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRscCsVtjdddddt2}|tjkr|ridd6id6}tjd	|d
}xt|dD]\}}djd
|}i|ddd6}it	d6|d6t
d6}xd.D]}	|j|	ijdg}
|	dkrd}n#d}|
r#t	|d<||d<nxy|
dD]m}||	ddjd|}
|d}|jdsxg|d<n|djdjd |d|
q.WqW|rrd!j
tjd"|d#}|jii|jd$6d%6|d&6||d|<qrqrWd'|_n7d(g}tjd)tjd*|d+t	}d,|_|SWd-QXd-S(/s`Convert imds_metadata dictionary to network v2 configuration.

    Parses network configuration from imds metadata if present or generate
    fallback network config excluding mlx4_core devices.

    @param: imds_metadata: Dict of content read from IMDS network service.
    @return: Dictionary containing network version 2 standard configuration.
    RRBRRBRitversiont	ethernetss1Azure: generating network configuration from IMDSRR\seth{idx}tidxiidsroute-metrictdhcp4sdhcp4-overridestdhcp6tipv4tipv6t	ipAddresst24t128sdhcp6-overridestsubnetitprefixtprivateIpAddresst	addressess
{ip}/{prefix}tipt:s..t
macAddresst
macaddresstmatchsset-namesnetwork config from imdst	mlx4_cores(Azure: generating fallback configurationtblacklist_driverst
config_driversnetwork config from fallbackN(RR(R
RRRRR;R<t	enumerateRLRvRR|RR=R#tfindallRRZRRtgenerate_fallback_config(t
imds_metadataRgt	netconfigtnetwork_metadataRtintftnicnamet
dhcp_overridet
dev_configt	addr_typeRtdefault_prefixtaddrt	netPrefixt	privateIptmact	blacklist((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRB$sV		



	




		
		cCsitjd6dd6td6|fd6}tj|rDtj|Sy'tt|tj|SWdQXWn$t	k
r}t
d|nXdS(sQuery Azure's network metadata service, returning a dictionary.

    If network is not up, setup ephemeral dhcp on fallback_nic to talk to the
    IMDS. For more info on IMDS:
        https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service

    @param fallback_nic: String. The name of the nic which requires active
        network in order to query IMDS.
    @param retries: The number of retries of the IMDS_URL.

    @return: A dict of instance metadata containing compute and network
        info.
    Rs/Crawl of Azure Instance Metadata Service (IMDS)RRRNs$exception while getting metadata: %s(R;R<t_get_metadata_from_imdsRRRRRRRR(tfallback_nicRRuR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRds


c
Cstd}idd6}y(t|dtd|d|dt}Wn5tk
rv}d|}t|tj|iSXytj	t
|SWn=tjj
k
r}td	|tjd
t
|nXiS(Nsinstance?api-version=2017-12-01RRRRRRs#Ignoring IMDS instance metadata: %ssnon-json imds responses,Ignoring non-json IMDS instance metadata: %s(RR
R%RRRR;R<Rt	load_jsonRKtjsontdecodertJSONDecodeErrorR(RR(RtresponseRR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs$




cCs|st}nt}xt|D]l}tjj|r|sVtjdtjt	}ntjj
|rxtj|qtj
|qqWdS(s(Remove Azure-specific ubuntu network config for non-primary nics.

    @param paths: List of networking scripts or directories to remove when
        present.

    In certain supported ubuntu images, static udev rules or netplan yaml
    config is delivered in the base ubuntu image to support dhcp on any
    additional interfaces which get attached by a customer at some point
    after initial boot. Since the Azure datasource can now regenerate
    network configuration as metadata reports these new devices, we no longer
    want the udev rules or netplan's 90-hotplug-azure.yaml to configure
    networking on eth1 or greater as it might collide with cloud-init's
    configuration.

    Remove the any existing extended network scripts if the datasource is
    enabled to write network per-boot.
    s{Removing Ubuntu extended network scripts because cloud-init updates Azure network configuration on the following event: %s.N(tUBUNTU_EXTENDED_NETWORK_SCRIPTSRRRRR;RRRRvtisdirRtdel_dirR9(RtloggedR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs	

	cCstjdddddty}tjd}|tkr@tSd|}tj|||_	t
|tjj
tjj|drtStSWdQXdS(	NRscheck-platform-viabilityRsfound azure asset tagRschassis-asset-tags(Non-Azure DMI asset tag '%s' discovered.sovf-env.xml(R
RRRRtAZURE_CHASSIS_ASSET_TAGRvR;R<RRRRRR=R(RRgt	asset_tagR((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRs	

	
!RcBseZRS((RGRH(((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRsRcBseZRS((RGRH(((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyRscCstj|tS(N(Rtlist_from_dependstdatasources(tdepends((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pytget_datasource_lists(xRt
contextlibRt	functoolsRRRtos.pathR#Rtxml.domRtxml.etree.ElementTreetetreetElementTreeRt	cloudinitRtloggingRtcloudinit.eventRtcloudinit.net.dhcpRRtcloudinit.sources.helpersRtcloudinit.url_helperR	R
RRtcloudinit.reportingR
tcloudinit.sources.helpers.azureRRRRRRRRt	getLoggerRGR;RRtAGENT_STARTR8R|RztRESOURCE_DISK_PATHtDEFAULT_PRIMARY_NICt
LEASE_FILEt
DEFAULT_FSR%RRtAGENT_SEED_DIRR%RtPLATFORM_ENTROPY_SOURCER!R.R2R7R(R@RCRFRGRWRtres_diskR<RvRRRR=tDEF_EPHEMERAL_LABELRRxR[tcontextmanagerRRRRSRWRiRR<RRRRRRRR4RRRRRRRBRRRRRRRtDataSourceAzureNettDEP_FILESYSTEMR(R*(((sE/usr/lib/python2.7/site-packages/cloudinit/sources/DataSourceAzure.pyt<module>s:

										,


	




S,$
	
5h	@$	
Back to Directory File Manager