summaryrefslogtreecommitdiff
path: root/cloudinit/sources/DataSourceAzure.py
diff options
context:
space:
mode:
authorAnh Vo <anhvo@microsoft.com>2021-08-05 15:41:10 -0400
committerGitHub <noreply@github.com>2021-08-05 14:41:10 -0500
commit8f42eb547ddf3202268e1e37a300ba8b2e89cbd2 (patch)
treed48e92b047398a5fa24a14a2b4a43be766b2e806 /cloudinit/sources/DataSourceAzure.py
parent3d9c862b6ded798031fad827328fa437bc14ac97 (diff)
downloadvyos-cloud-init-8f42eb547ddf3202268e1e37a300ba8b2e89cbd2.tar.gz
vyos-cloud-init-8f42eb547ddf3202268e1e37a300ba8b2e89cbd2.zip
generate contents for ovf-env.xml when provisioning via IMDS (#959)
Azure Linux Agent (WaLinuxAgent) waits for the ovf-env.xml file to be written by cloud-init when cloud-init provisions the VM. This file is written whenever cloud-init reads its contents from the provisioning ISO. With this change, when there is no provisioning ISO, DataSourceAzure will generate the ovf-env.xml file based on the metadata obtained from Azure IMDS.
Diffstat (limited to 'cloudinit/sources/DataSourceAzure.py')
-rwxr-xr-xcloudinit/sources/DataSourceAzure.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index 2e7bfbe3..01e2c959 100755
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -45,7 +45,8 @@ from cloudinit.sources.helpers.azure import (
is_byte_swapped,
dhcp_log_cb,
push_log_to_kvp,
- report_failure_to_fabric)
+ report_failure_to_fabric,
+ build_minimal_ovf)
LOG = logging.getLogger(__name__)
@@ -540,6 +541,18 @@ class DataSourceAzure(sources.DataSource):
)
crawled_data['metadata']['disable_password'] = imds_disable_password # noqa: E501
+ if metadata_source == 'IMDS' and not crawled_data['files']:
+ try:
+ contents = build_minimal_ovf(
+ username=imds_username,
+ hostname=imds_hostname,
+ disableSshPwd=imds_disable_password)
+ crawled_data['files'] = {'ovf-env.xml': contents}
+ except Exception as e:
+ report_diagnostic_event(
+ "Failed to construct OVF from IMDS data %s" % e,
+ logger_func=LOG.debug)
+
# only use userdata from imds if OVF did not provide custom data
# userdata provided by IMDS is always base64 encoded
if not userdata_raw: