From 4c9b8f09fc437537de6751b152195e43d15659be Mon Sep 17 00:00:00 2001 From: Alessandro Pilotti Date: Fri, 11 Sep 2015 02:59:20 +0300 Subject: [PATCH] Replaces InitiateSystemShutdownW Uses InitiateSystemShutdownExW instead of InitiateSystemShutdownW. This is needed for Nano Server support. Change-Id: I7ca30de01966cd37b0627ad9eddfd332b8260f62 Closes-Bug: #1494529 --- cloudbaseinit/osutils/windows.py | 4 ++-- cloudbaseinit/tests/osutils/test_windows.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cloudbaseinit/osutils/windows.py b/cloudbaseinit/osutils/windows.py index 51dd8e7a..70960587 100644 --- a/cloudbaseinit/osutils/windows.py +++ b/cloudbaseinit/osutils/windows.py @@ -307,9 +307,9 @@ class WindowsUtils(base.BaseOSUtils): def reboot(self): with privilege.acquire_privilege(win32security.SE_SHUTDOWN_NAME): - ret_val = advapi32.InitiateSystemShutdownW( + ret_val = advapi32.InitiateSystemShutdownExW( 0, "Cloudbase-Init reboot", - 0, True, True) + 0, True, True, 0) if not ret_val: raise exception.WindowsCloudbaseInitException( "Reboot failed: %r") diff --git a/cloudbaseinit/tests/osutils/test_windows.py b/cloudbaseinit/tests/osutils/test_windows.py index 86438b86..f291e369 100644 --- a/cloudbaseinit/tests/osutils/test_windows.py +++ b/cloudbaseinit/tests/osutils/test_windows.py @@ -94,7 +94,7 @@ class TestWindowsUtils(testutils.CloudbaseInitTestBase): expected_ret_value=None): mock_privilege_module.acquire_privilege = mock.MagicMock() advapi32 = self._windll_mock.advapi32 - advapi32.InitiateSystemShutdownW = mock.MagicMock( + advapi32.InitiateSystemShutdownExW = mock.MagicMock( return_value=ret_value) if not ret_value: @@ -104,10 +104,10 @@ class TestWindowsUtils(testutils.CloudbaseInitTestBase): else: self._winutils.reboot() - advapi32.InitiateSystemShutdownW.assert_called_with( + advapi32.InitiateSystemShutdownExW.assert_called_with( 0, "Cloudbase-Init reboot", - 0, True, True) + 0, True, True, 0) mock_privilege_module.acquire_privilege.assert_called_once_with( self._win32security_mock.SE_SHUTDOWN_NAME)