From 1add169cc5ce58e16ac54432a476baf15c4889bc Mon Sep 17 00:00:00 2001 From: Cosmin Poieana Date: Tue, 1 Sep 2015 18:00:47 +0300 Subject: [PATCH] Show the error code in network config If there is a problem with static addresses setting, then throw an exception containing the error code (returned value) for a better understanding of the issue. Change-Id: I44cdeec667c98212dbab6b303d3bd5765b8ea9c0 --- cloudbaseinit/osutils/windows.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cloudbaseinit/osutils/windows.py b/cloudbaseinit/osutils/windows.py index c0afbb73..615f24d5 100644 --- a/cloudbaseinit/osutils/windows.py +++ b/cloudbaseinit/osutils/windows.py @@ -560,7 +560,8 @@ class WindowsUtils(base.BaseOSUtils): (ret_val,) = adapter_config.EnableStatic([address], [netmask]) if ret_val > 1: raise exception.CloudbaseInitException( - "Cannot set static IP address on network adapter") + "Cannot set static IP address on network adapter (%d)", + ret_val) reboot_required = (ret_val == 1) if gateway: @@ -568,7 +569,8 @@ class WindowsUtils(base.BaseOSUtils): (ret_val,) = adapter_config.SetGateways([gateway], [1]) if ret_val > 1: raise exception.CloudbaseInitException( - "Cannot set gateway on network adapter") + "Cannot set gateway on network adapter (%d)", + ret_val) reboot_required = reboot_required or ret_val == 1 if dnsnameservers: @@ -576,7 +578,8 @@ class WindowsUtils(base.BaseOSUtils): (ret_val,) = adapter_config.SetDNSServerSearchOrder(dnsnameservers) if ret_val > 1: raise exception.CloudbaseInitException( - "Cannot set DNS on network adapter") + "Cannot set DNS on network adapter (%d)", + ret_val) reboot_required = reboot_required or ret_val == 1 return reboot_required