From b1cbc909d4274ed766e9f311f7fee45068aef9b8 Mon Sep 17 00:00:00 2001 From: Cristian Matiut Date: Wed, 25 Feb 2026 17:28:16 +0000 Subject: [PATCH 1/2] Allow cloudbase-init reboot and fix extraction when local scripts exist --- coriolis/osmorphing/windows.py | 5 +---- coriolis/tests/osmorphing/test_windows.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/coriolis/osmorphing/windows.py b/coriolis/osmorphing/windows.py index e87d565d..f95f3ed4 100644 --- a/coriolis/osmorphing/windows.py +++ b/coriolis/osmorphing/windows.py @@ -301,9 +301,6 @@ def _expand_archive(self, path, destination, overwrite=True): else: self._conn.exec_ps_command( "rm -recurse -force %s" % destination) - else: - LOG.info("Skipping extraction as destination exists") - return self._conn.exec_ps_command( "if(([System.Management.Automation.PSTypeName]" @@ -517,7 +514,7 @@ def _write_cloudbase_init_conf(self, cloudbaseinit_base_dir, "logfile = cloudbase-init.log\r\n" "default_log_levels = \r\n" "comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN\r\n" - "allow_reboot = false\r\n" + "allow_reboot = true\r\n" "plugins = %(plugins)s\r\n" "debug = true\r\n" "san_policy = OnlineAll\r\n" diff --git a/coriolis/tests/osmorphing/test_windows.py b/coriolis/tests/osmorphing/test_windows.py index 75d03965..0f96b5c4 100644 --- a/coriolis/tests/osmorphing/test_windows.py +++ b/coriolis/tests/osmorphing/test_windows.py @@ -513,7 +513,7 @@ def test__write_cloudbase_init_conf( "logfile = cloudbase-init.log\r\n" "default_log_levels = \r\n" "comtypes=INFO,suds=INFO,iso8601=WARN,requests=WARN\r\n" - "allow_reboot = false\r\n" + "allow_reboot = true\r\n" "plugins = %(plugins)s\r\n" "debug = true\r\n" "san_policy = OnlineAll\r\n" From 62c201a0174c8bb37c61f666bb2433aa176b4448 Mon Sep 17 00:00:00 2001 From: Cristian Matiut Date: Mon, 2 Mar 2026 14:41:03 +0000 Subject: [PATCH 2/2] Replace old cloudbase-init extraction with new PS 5.1+ command. --- coriolis/osmorphing/windows.py | 11 ++--------- coriolis/tests/osmorphing/test_windows.py | 12 ++---------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/coriolis/osmorphing/windows.py b/coriolis/osmorphing/windows.py index f95f3ed4..495e923c 100644 --- a/coriolis/osmorphing/windows.py +++ b/coriolis/osmorphing/windows.py @@ -303,15 +303,8 @@ def _expand_archive(self, path, destination, overwrite=True): "rm -recurse -force %s" % destination) self._conn.exec_ps_command( - "if(([System.Management.Automation.PSTypeName]" - "'System.IO.Compression.ZipFile').Type -or " - "[System.Reflection.Assembly]::LoadWithPartialName(" - "'System.IO.Compression.FileSystem')) {" - "[System.IO.Compression.ZipFile]::ExtractToDirectory('%(path)s', " - "'%(destination)s')} else {mkdir -Force '%(destination)s'; " - "$shell = New-Object -ComObject Shell.Application;" - "$shell.Namespace('%(destination)s').copyhere(($shell.NameSpace(" - "'%(path)s')).items())}" % + "Expand-Archive -LiteralPath '%(path)s' " + "-DestinationPath '%(destination)s' -Force" % {"path": path, "destination": destination}, ignore_stdout=True) diff --git a/coriolis/tests/osmorphing/test_windows.py b/coriolis/tests/osmorphing/test_windows.py index 0f96b5c4..f635561e 100644 --- a/coriolis/tests/osmorphing/test_windows.py +++ b/coriolis/tests/osmorphing/test_windows.py @@ -231,16 +231,8 @@ def test__expand_archive_remove_destination(self): self.conn.exec_ps_command.assert_has_calls([ mock.call("rm -recurse -force %s" % destination), mock.call( - "if(([System.Management.Automation.PSTypeName]" - "'System.IO.Compression.ZipFile').Type -or " - "[System.Reflection.Assembly]::LoadWithPartialName(" - "'System.IO.Compression.FileSystem')) {" - "[System.IO.Compression.ZipFile]::ExtractToDirectory(" - "'%(path)s', '%(destination)s')} else {mkdir -Force " - "'%(destination)s'; $shell = New-Object -ComObject " - "Shell.Application;$shell.Namespace(" - "'%(destination)s').copyhere(($shell.NameSpace(" - "'%(path)s')).items())}" % + "Expand-Archive -LiteralPath '%(path)s' " + "-DestinationPath '%(destination)s' -Force" % {"path": mock.sentinel.archive_path, "destination": destination}, ignore_stdout=True)