From 8f42eb547ddf3202268e1e37a300ba8b2e89cbd2 Mon Sep 17 00:00:00 2001 From: Anh Vo Date: Thu, 5 Aug 2021 15:41:10 -0400 Subject: 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. --- cloudinit/sources/helpers/azure.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'cloudinit/sources/helpers') diff --git a/cloudinit/sources/helpers/azure.py b/cloudinit/sources/helpers/azure.py index ad476076..a5ac1d57 100755 --- a/cloudinit/sources/helpers/azure.py +++ b/cloudinit/sources/helpers/azure.py @@ -344,6 +344,40 @@ def http_with_retries(url, **kwargs) -> str: raise exc +def build_minimal_ovf( + username: str, + hostname: str, + disableSshPwd: str) -> bytes: + OVF_ENV_TEMPLATE = textwrap.dedent('''\ + + + 1.0 + + LinuxProvisioningConfiguration + + {username} + {disableSshPwd} + + {hostname} + + + + 1.0 + + true + + + + ''') + ret = OVF_ENV_TEMPLATE.format( + username=username, + hostname=hostname, + disableSshPwd=disableSshPwd) + return ret.encode('utf-8') + + class AzureEndpointHttpClient: headers = { -- cgit v1.2.3