Skip to content

Commit 62c201a

Browse files
committed
Replace old cloudbase-init extraction with new PS 5.1+ command.
1 parent b1cbc90 commit 62c201a

2 files changed

Lines changed: 4 additions & 19 deletions

File tree

coriolis/osmorphing/windows.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,15 +303,8 @@ def _expand_archive(self, path, destination, overwrite=True):
303303
"rm -recurse -force %s" % destination)
304304

305305
self._conn.exec_ps_command(
306-
"if(([System.Management.Automation.PSTypeName]"
307-
"'System.IO.Compression.ZipFile').Type -or "
308-
"[System.Reflection.Assembly]::LoadWithPartialName("
309-
"'System.IO.Compression.FileSystem')) {"
310-
"[System.IO.Compression.ZipFile]::ExtractToDirectory('%(path)s', "
311-
"'%(destination)s')} else {mkdir -Force '%(destination)s'; "
312-
"$shell = New-Object -ComObject Shell.Application;"
313-
"$shell.Namespace('%(destination)s').copyhere(($shell.NameSpace("
314-
"'%(path)s')).items())}" %
306+
"Expand-Archive -LiteralPath '%(path)s' "
307+
"-DestinationPath '%(destination)s' -Force" %
315308
{"path": path, "destination": destination},
316309
ignore_stdout=True)
317310

coriolis/tests/osmorphing/test_windows.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,16 +231,8 @@ def test__expand_archive_remove_destination(self):
231231
self.conn.exec_ps_command.assert_has_calls([
232232
mock.call("rm -recurse -force %s" % destination),
233233
mock.call(
234-
"if(([System.Management.Automation.PSTypeName]"
235-
"'System.IO.Compression.ZipFile').Type -or "
236-
"[System.Reflection.Assembly]::LoadWithPartialName("
237-
"'System.IO.Compression.FileSystem')) {"
238-
"[System.IO.Compression.ZipFile]::ExtractToDirectory("
239-
"'%(path)s', '%(destination)s')} else {mkdir -Force "
240-
"'%(destination)s'; $shell = New-Object -ComObject "
241-
"Shell.Application;$shell.Namespace("
242-
"'%(destination)s').copyhere(($shell.NameSpace("
243-
"'%(path)s')).items())}" %
234+
"Expand-Archive -LiteralPath '%(path)s' "
235+
"-DestinationPath '%(destination)s' -Force" %
244236
{"path": mock.sentinel.archive_path,
245237
"destination": destination},
246238
ignore_stdout=True)

0 commit comments

Comments
 (0)