From 441fbf70d627e10dc56870e9a5d3a2cad09206d8 Mon Sep 17 00:00:00 2001 From: Sanne Raymaekers Date: Thu, 13 Feb 2025 12:31:33 +0100 Subject: [PATCH] org.osbuild.cloud-init: add new datasources and network section Adds WSL and NoCloud datasources. The network section only allows you to disable network configuration by cloud-init for now. --- stages/org.osbuild.cloud-init.meta.json | 14 ++++++++++++++ stages/test/test_cloud-init.py | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/stages/org.osbuild.cloud-init.meta.json b/stages/org.osbuild.cloud-init.meta.json index 773810a9..acd8eeae 100644 --- a/stages/org.osbuild.cloud-init.meta.json +++ b/stages/org.osbuild.cloud-init.meta.json @@ -93,6 +93,8 @@ "enum": [ "Azure", "Ec2", + "NoCloud", + "WSL", "None" ] } @@ -136,6 +138,18 @@ "type": "string" } } + }, + "network": { + "type": "object", + "minProperties": 1, + "properties": { + "config": { + "type": "string", + "enum": [ + "disabled" + ] + } + } } } } diff --git a/stages/test/test_cloud-init.py b/stages/test/test_cloud-init.py index 9a7f8bc9..a46d7338 100644 --- a/stages/test/test_cloud-init.py +++ b/stages/test/test_cloud-init.py @@ -24,3 +24,22 @@ def test_cloud_init_datasource_list_single_line(tmp_path, stage_module): stage_module.main(treedir, options) assert os.path.exists(confpath) assert confpath.read_text() == "datasource_list: [Azure]\n" + + +def test_cloud_init_network(tmp_path, stage_module): + treedir = tmp_path / "tree" + confpath = treedir / "etc/cloud/cloud.cfg.d/network.cfg" + confpath.parent.mkdir(parents=True, exist_ok=True) + + options = { + "filename": confpath.name, + "config": { + "network": { + "config": "disabled", + }, + }, + } + + stage_module.main(treedir, options) + assert os.path.exists(confpath) + assert confpath.read_text() == "network:\n config: disabled\n"