Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
From 402e9331a72d543e779898667488a51ad3e3ec13 Mon Sep 17 00:00:00 2001
From: Ksenija Stanojevic <KsenijaS@users.noreply.github.com>
Date: Fri, 9 Feb 2024 13:32:19 -0800
Subject: [PATCH 1/3] feat(azure): Add ProvisionGuestProxyAgent OVF setting
(#4860)

Add ProvisionGuestProxyAgent Boolean configuration setting into the OvfEnv class.
This PR is only logging the value of ProvisionGuestProxyAgent.
---
cloudinit/sources/DataSourceAzure.py | 6 ++++++
cloudinit/sources/helpers/azure.py | 8 ++++++++
tests/unittests/sources/test_azure.py | 15 +++++++++++++++
3 files changed, 29 insertions(+)

diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py
index 5a82aa34e..dc2b79a3a 100644
--- a/cloudinit/sources/DataSourceAzure.py
+++ b/cloudinit/sources/DataSourceAzure.py
@@ -1784,6 +1784,12 @@ def read_azure_ovf(contents):
"PreprovisionedVMType: %s" % ovf_env.preprovisioned_vm_type,
logger_func=LOG.info,
)
+
+ cfg["ProvisionGuestProxyAgent"] = ovf_env.provision_guest_proxy_agent
+ report_diagnostic_event(
+ "ProvisionGuestProxyAgent: %s" % ovf_env.provision_guest_proxy_agent,
+ logger_func=LOG.info,
+ )
return (md, ud, cfg)


diff --git a/cloudinit/sources/helpers/azure.py b/cloudinit/sources/helpers/azure.py
index 6e5c1f433..2847a9e53 100644
--- a/cloudinit/sources/helpers/azure.py
+++ b/cloudinit/sources/helpers/azure.py
@@ -1064,6 +1064,7 @@ class OvfEnvXml:
public_keys: Optional[List[dict]] = None,
preprovisioned_vm: bool = False,
preprovisioned_vm_type: Optional[str] = None,
+ provision_guest_proxy_agent: bool = False,
) -> None:
self.username = username
self.password = password
@@ -1073,6 +1074,7 @@ class OvfEnvXml:
self.public_keys: List[dict] = public_keys or []
self.preprovisioned_vm = preprovisioned_vm
self.preprovisioned_vm_type = preprovisioned_vm_type
+ self.provision_guest_proxy_agent = provision_guest_proxy_agent

def __eq__(self, other) -> bool:
return self.__dict__ == other.__dict__
@@ -1216,6 +1218,12 @@ class OvfEnvXml:
"PreprovisionedVMType",
required=False,
)
+ self.provision_guest_proxy_agent = self._parse_property(
+ platform_settings,
+ "ProvisionGuestProxyAgent",
+ default=False,
+ required=False,
+ )

def _parse_ssh_section(self, config_set):
self.public_keys = []
diff --git a/tests/unittests/sources/test_azure.py b/tests/unittests/sources/test_azure.py
index 1ddbd3f39..6afde95fd 100644
--- a/tests/unittests/sources/test_azure.py
+++ b/tests/unittests/sources/test_azure.py
@@ -356,6 +356,7 @@ def construct_ovf_env(
disable_ssh_password_auth=None,
preprovisioned_vm=None,
preprovisioned_vm_type=None,
+ provision_guest_proxy_agent=None,
):
content = [
'<?xml version="1.0" encoding="utf-8"?>',
@@ -426,6 +427,11 @@ def construct_ovf_env(
"<ns1:PreprovisionedVMType>%s</ns1:PreprovisionedVMType>"
% preprovisioned_vm_type
)
+ if provision_guest_proxy_agent is not None:
+ content.append(
+ "<ns1:ProvisionGuestProxyAgent>%s</ns1:ProvisionGuestProxyAgent>"
+ % provision_guest_proxy_agent
+ )
content += [
"</ns1:PlatformSettings>",
"</ns1:PlatformSettingsSection>",
@@ -1316,6 +1322,7 @@ scbus-1 on xpt0 bus 0
expected_cfg = {
"PreprovisionedVMType": None,
"PreprovisionedVm": False,
+ "ProvisionGuestProxyAgent": False,
"system_info": {"default_user": {"name": "myuser"}},
}
expected_metadata = {
@@ -2668,6 +2675,14 @@ class TestPreprovisioningReadAzureOvfFlag(CiTestCase):
self.assertTrue(cfg["PreprovisionedVm"])
self.assertEqual("Savable", cfg["PreprovisionedVMType"])

+ def test_read_azure_ovf_with_proxy_guest_agent(self):
+ """The read_azure_ovf method should set ProvisionGuestProxyAgent
+ cfg flag to True."""
+ content = construct_ovf_env(provision_guest_proxy_agent=True)
+ ret = dsaz.read_azure_ovf(content)
+ cfg = ret[2]
+ self.assertTrue(cfg["ProvisionGuestProxyAgent"])
+

@pytest.mark.parametrize(
"ovf_cfg,imds_md,pps_type",
--
2.34.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
From e3ba5800d26065df9ce03ee2ac58ec6f08506423 Mon Sep 17 00:00:00 2001
From: Ksenija Stanojevic <KsenijaS@users.noreply.github.com>
Date: Fri, 5 Apr 2024 16:52:26 -0700
Subject: [PATCH 2/3] feat(azure): parse ProvisionGuestProxyAgent as bool
(#5126)

---
cloudinit/sources/helpers/azure.py | 1 +
tests/unittests/sources/test_azure.py | 12 ++++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/cloudinit/sources/helpers/azure.py b/cloudinit/sources/helpers/azure.py
index 2847a9e53..165f47429 100644
--- a/cloudinit/sources/helpers/azure.py
+++ b/cloudinit/sources/helpers/azure.py
@@ -1221,6 +1221,7 @@ class OvfEnvXml:
self.provision_guest_proxy_agent = self._parse_property(
platform_settings,
"ProvisionGuestProxyAgent",
+ parse_bool=True,
default=False,
required=False,
)
diff --git a/tests/unittests/sources/test_azure.py b/tests/unittests/sources/test_azure.py
index 6afde95fd..255991ec3 100644
--- a/tests/unittests/sources/test_azure.py
+++ b/tests/unittests/sources/test_azure.py
@@ -2675,13 +2675,21 @@ class TestPreprovisioningReadAzureOvfFlag(CiTestCase):
self.assertTrue(cfg["PreprovisionedVm"])
self.assertEqual("Savable", cfg["PreprovisionedVMType"])

- def test_read_azure_ovf_with_proxy_guest_agent(self):
+ def test_read_azure_ovf_with_proxy_guest_agent_true(self):
"""The read_azure_ovf method should set ProvisionGuestProxyAgent
cfg flag to True."""
content = construct_ovf_env(provision_guest_proxy_agent=True)
ret = dsaz.read_azure_ovf(content)
cfg = ret[2]
- self.assertTrue(cfg["ProvisionGuestProxyAgent"])
+ assert cfg["ProvisionGuestProxyAgent"] is True
+
+ def test_read_azure_ovf_with_proxy_guest_agent_false(self):
+ """The read_azure_ovf method should set ProvisionGuestProxyAgent
+ cfg flag to False."""
+ content = construct_ovf_env(provision_guest_proxy_agent=False)
+ ret = dsaz.read_azure_ovf(content)
+ cfg = ret[2]
+ assert cfg["ProvisionGuestProxyAgent"] is False


@pytest.mark.parametrize(
--
2.34.1

Loading