fetch meta/userdata from directory
Change-Id: I46ae67cdba0a2af3937288e2256d71c9455871e0
This commit is contained in:
parent
912eea88ed
commit
7263de81b1
|
@ -16,6 +16,7 @@
|
||||||
CD_TYPES = {
|
CD_TYPES = {
|
||||||
"vfat", # Visible device (with partition table).
|
"vfat", # Visible device (with partition table).
|
||||||
"iso", # "Raw" format containing ISO bytes.
|
"iso", # "Raw" format containing ISO bytes.
|
||||||
|
"files" # Set of files. Considers a number of files in directory as a pseudo-config-drive.
|
||||||
}
|
}
|
||||||
CD_LOCATIONS = {
|
CD_LOCATIONS = {
|
||||||
# Look into optical devices. Only an ISO format could be
|
# Look into optical devices. Only an ISO format could be
|
||||||
|
@ -27,6 +28,8 @@ CD_LOCATIONS = {
|
||||||
# Search through partitions for raw ISO content or through volumes
|
# Search through partitions for raw ISO content or through volumes
|
||||||
# containing configuration drive's content.
|
# containing configuration drive's content.
|
||||||
"partition",
|
"partition",
|
||||||
|
# Search for configuration drive's content in %PROGRAMDATA%\{config drive label} directory
|
||||||
|
"directory"
|
||||||
}
|
}
|
||||||
|
|
||||||
POLICY_IGNORE_ALL_FAILURES = "ignoreallfailures"
|
POLICY_IGNORE_ALL_FAILURES = "ignoreallfailures"
|
||||||
|
|
|
@ -228,6 +228,16 @@ class WindowsConfigDriveManager(base.BaseConfigDriveManager):
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def _get_config_drive_from_directory(self, drive_label, metadata_file):
|
||||||
|
"""Look through directory %PROGRAMDTA%\drive_label for config drive files."""
|
||||||
|
sourcefilespath = os.environ["PROGRAMDATA"] + f"\{drive_label}"
|
||||||
|
if self._meta_data_file_exists(sourcefilespath, metadata_file):
|
||||||
|
LOG.info('Config Drive found on %s', sourcefilespath)
|
||||||
|
os.rmdir(self.target_path)
|
||||||
|
shutil.copytree(sourcefilespath, self.target_path)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def config_drive_type_location(self):
|
def config_drive_type_location(self):
|
||||||
return {
|
return {
|
||||||
|
@ -236,4 +246,5 @@ class WindowsConfigDriveManager(base.BaseConfigDriveManager):
|
||||||
"hdd_vfat": self._get_config_drive_from_vfat,
|
"hdd_vfat": self._get_config_drive_from_vfat,
|
||||||
"partition_iso": self._get_config_drive_from_partition,
|
"partition_iso": self._get_config_drive_from_partition,
|
||||||
"partition_vfat": self._get_config_drive_from_volume,
|
"partition_vfat": self._get_config_drive_from_volume,
|
||||||
|
"directory_files": self._get_config_drive_from_directory
|
||||||
}
|
}
|
||||||
|
|
|
@ -468,13 +468,20 @@ class TestWindowsConfigDriveManager(unittest.TestCase):
|
||||||
self._test__get_config_drive_files(
|
self._test__get_config_drive_files(
|
||||||
"vfat", "partition", func)
|
"vfat", "partition", func)
|
||||||
|
|
||||||
|
@mock.patch('cloudbaseinit.metadata.services.osconfigdrive.windows.'
|
||||||
|
'WindowsConfigDriveManager.'
|
||||||
|
'_get_config_drive_from_directory')
|
||||||
|
def test__get_config_drive_files_directory_files(self, func):
|
||||||
|
self._test__get_config_drive_files(
|
||||||
|
"files", "directory", func)
|
||||||
|
|
||||||
@mock.patch('cloudbaseinit.metadata.services.osconfigdrive.windows.'
|
@mock.patch('cloudbaseinit.metadata.services.osconfigdrive.windows.'
|
||||||
'WindowsConfigDriveManager.'
|
'WindowsConfigDriveManager.'
|
||||||
'_get_config_drive_files')
|
'_get_config_drive_files')
|
||||||
def _test_get_config_drive_files(self, mock_get_config_drive_files,
|
def _test_get_config_drive_files(self, mock_get_config_drive_files,
|
||||||
found=True):
|
found=True):
|
||||||
check_types = ["iso", "vfat"] if found else []
|
check_types = ["iso", "vfat", "files"] if found else []
|
||||||
check_locations = ["cdrom", "hdd", "partition"]
|
check_locations = ["cdrom", "hdd", "partition", "directory"]
|
||||||
product = list(itertools.product(check_types, check_locations,
|
product = list(itertools.product(check_types, check_locations,
|
||||||
[self._fake_label]))
|
[self._fake_label]))
|
||||||
product_calls = [mock.call(self._fake_label, self._fake_metadata_file,
|
product_calls = [mock.call(self._fake_label, self._fake_metadata_file,
|
||||||
|
|
|
@ -126,7 +126,8 @@ NoCloudConfigDriveService is similar to OpenStack config drive metadata in terms
|
||||||
the medium on which the data is provided (as an attached ISO, partition or disk) and
|
the medium on which the data is provided (as an attached ISO, partition or disk) and
|
||||||
similar to the EC2 metadata in terms of how the metadata files are named and structured.
|
similar to the EC2 metadata in terms of how the metadata files are named and structured.
|
||||||
|
|
||||||
The metadata is provided on a config-drive (vfat or iso9660) with the label cidata or CIDATA.
|
The metadata is provided on a config-drive (vfat or iso9660) with the label cidata or CIDATA,
|
||||||
|
or in %PROGRAMDATA%\CIDATA directory.
|
||||||
|
|
||||||
The folder structure for NoCloud is:
|
The folder structure for NoCloud is:
|
||||||
|
|
||||||
|
@ -150,8 +151,8 @@ Config options for `config_drive` section:
|
||||||
* raw_hdd (bool: True)
|
* raw_hdd (bool: True)
|
||||||
* cdrom (bool: True)
|
* cdrom (bool: True)
|
||||||
* vfat (bool: True)
|
* vfat (bool: True)
|
||||||
* types (list: ["vfat", "iso"])
|
* types (list: ["vfat", "iso", "files"])
|
||||||
* locations (list: ["cdrom", "hdd", "partition"])
|
* locations (list: ["cdrom", "hdd", "partition", "directory"])
|
||||||
|
|
||||||
Example metadata:
|
Example metadata:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue