From d767ff6a82a0434445fcfdbec9531789dfb26041 Mon Sep 17 00:00:00 2001 From: Francois Leurent <131.code@leurent.email> Date: Sat, 8 Nov 2025 17:08:54 +0100 Subject: [PATCH] With nocloud localfolder support --- cloudbaseinit/conf/nocloud.py | 3 +++ cloudbaseinit/constant.py | 2 ++ cloudbaseinit/metadata/services/nocloudservice.py | 2 +- cloudbaseinit/metadata/services/osconfigdrive/windows.py | 7 +++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cloudbaseinit/conf/nocloud.py b/cloudbaseinit/conf/nocloud.py index 8b0d23024..b2b018b13 100644 --- a/cloudbaseinit/conf/nocloud.py +++ b/cloudbaseinit/conf/nocloud.py @@ -34,6 +34,9 @@ def __init__(self, config): "userdata_file", default="user-data", help="The file name where the service looks for" "userdata"), + cfg.StrOpt( + "drive_label", default="cidata", + help="The path the service looks for metadata"), ] def register(self): diff --git a/cloudbaseinit/constant.py b/cloudbaseinit/constant.py index 3a7b772aa..ba35a8157 100644 --- a/cloudbaseinit/constant.py +++ b/cloudbaseinit/constant.py @@ -16,6 +16,7 @@ CD_TYPES = { "vfat", # Visible device (with partition table). "iso", # "Raw" format containing ISO bytes. + "local", # Cloud-drive is just a local folder } CD_LOCATIONS = { # Look into optical devices. Only an ISO format could be @@ -27,6 +28,7 @@ # Search through partitions for raw ISO content or through volumes # containing configuration drive's content. "partition", + "local", # Cloud-drive is just a local folder } POLICY_IGNORE_ALL_FAILURES = "ignoreallfailures" diff --git a/cloudbaseinit/metadata/services/nocloudservice.py b/cloudbaseinit/metadata/services/nocloudservice.py index 70190d018..b078b8019 100644 --- a/cloudbaseinit/metadata/services/nocloudservice.py +++ b/cloudbaseinit/metadata/services/nocloudservice.py @@ -659,7 +659,7 @@ class NoCloudConfigDriveService(baseconfigdrive.BaseConfigDriveService): def __init__(self): super(NoCloudConfigDriveService, self).__init__( - 'cidata', CONF.nocloud.metadata_file, + CONF.nocloud.drive_label, CONF.nocloud.metadata_file, CONF.nocloud.userdata_file) self._meta_data = {} diff --git a/cloudbaseinit/metadata/services/osconfigdrive/windows.py b/cloudbaseinit/metadata/services/osconfigdrive/windows.py index 3fa212ddc..73aa5f760 100644 --- a/cloudbaseinit/metadata/services/osconfigdrive/windows.py +++ b/cloudbaseinit/metadata/services/osconfigdrive/windows.py @@ -182,6 +182,12 @@ def _get_config_drive_from_partition(self, drive_label, metadata_file): return True return False + def _get_config_drive_from_local(self, drive_label, metadata_file): + os.rmdir(self.target_path) + shutil.copytree(drive_label, self.target_path) + return True + + def _get_config_drive_from_volume(self, drive_label, metadata_file): """Look through all the volumes for config drive.""" volumes = self._osutils.get_volumes() @@ -231,6 +237,7 @@ def get_config_drive_files(self, drive_label, metadata_file, @property def config_drive_type_location(self): return { + "local_local": self._get_config_drive_from_local, "cdrom_iso": self._get_config_drive_from_cdrom_drive, "hdd_iso": self._get_config_drive_from_raw_hdd, "hdd_vfat": self._get_config_drive_from_vfat,