Quellcode durchsuchen

Replace old cloudbase-init extraction with new PS 5.1+ command.

Cristian Matiut vor 2 Monaten
Ursprung
Commit
0751f6078c
2 geänderte Dateien mit 4 neuen und 19 gelöschten Zeilen
  1. 2 9
      coriolis/osmorphing/windows.py
  2. 2 10
      coriolis/tests/osmorphing/test_windows.py

+ 2 - 9
coriolis/osmorphing/windows.py

@@ -303,15 +303,8 @@ class BaseWindowsMorphingTools(base.BaseOSMorphingTools):
                         "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)
 

+ 2 - 10
coriolis/tests/osmorphing/test_windows.py

@@ -231,16 +231,8 @@ class BaseWindowsMorphingToolsTestCase(test_base.CoriolisBaseTestCase):
         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)