From 9439eee23a4fcc90c0eaad689d46f85196b4040d Mon Sep 17 00:00:00 2001 From: Nikos Skalkotos <skalkoto@grnet.gr> Date: Wed, 9 Jul 2014 17:37:06 +0300 Subject: [PATCH] windows: Disable hibernation when booting This used to be a sysprep but it is better if we disable it right away. This is not needed for VMs and if this is enabled, the system will hibernate on an ACPI shutdown event which will make the system preparation to fail. --- image_creator/os_type/windows/__init__.py | 8 ++------ image_creator/os_type/windows/powershell.py | 3 +++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/image_creator/os_type/windows/__init__.py b/image_creator/os_type/windows/__init__.py index e382424..9ce8688 100644 --- a/image_creator/os_type/windows/__init__.py +++ b/image_creator/os_type/windows/__init__.py @@ -315,12 +315,6 @@ class Windows(OSBase): self.vm.rexec('netsh firewall set icmpsetting 8') - @sysprep('Disabling hibernation support') - def disable_hibernation(self): - """Disable hibernation support and remove the hibernation file""" - - self.vm.rexec(r'powercfg.exe /hibernate off') - @sysprep('Setting the system clock to UTC') def utc(self): """Set the hardware clock to UTC""" @@ -590,6 +584,8 @@ class Windows(OSBase): commands = {} + # Disable hibernation. This is not needed for a VM + commands['hibernate'] = r'powercfg.exe /hibernate off' # This script will send a random string to the first serial port. This # can be used to determine when the OS has booted. commands['BootMonitor'] = "cmd /q /a /c echo " + TOKEN + " > COM1" diff --git a/image_creator/os_type/windows/powershell.py b/image_creator/os_type/windows/powershell.py index 56ccf3f..b048f44 100644 --- a/image_creator/os_type/windows/powershell.py +++ b/image_creator/os_type/windows/powershell.py @@ -50,6 +50,9 @@ function Cat2Cert [System.IO.File]::WriteAllBytes($certFile, $cert.Export("Cert")) return $certFile } + +# This is not needed on VMs +powercfg.exe /hibernate off """ ADD_CERTIFICATE = r""" -- GitLab