45 Commits

Author SHA1 Message Date
Jenkins
83743c7f5c Merge "Replaces InitiateSystemShutdownW" 2015-09-11 00:17:54 +00:00
Alessandro Pilotti
4c9b8f09fc Replaces InitiateSystemShutdownW
Uses InitiateSystemShutdownExW instead of InitiateSystemShutdownW.
This is needed for Nano Server support.

Change-Id: I7ca30de01966cd37b0627ad9eddfd332b8260f62
Closes-Bug: #1494529
2015-09-11 03:03:57 +03:00
Jenkins
0997dd560e Merge "Fixes check_os_version on Windows 10" 2015-09-10 23:42:55 +00:00
Alessandro Pilotti
f7c539fe4f Fixes check_os_version on Windows 10
VerifyWindowsVersion requires a manifest on Windows 10, not a
suitable option in Python.

This patch replaces VerifyWindowsVersion with RtlVerifyWindowsVersion.

Co-Authored-By: Cosmin Poieana <cpoieana@cloudbasesolutions.com>
Change-Id: I6f9414a44aab97b15359ae4b4ca9cc1777b396f8
Closes-Bug: #1493324
2015-09-09 15:54:45 +03:00
Alessandro Pilotti
d3fcf925d2 Replaces ADSI COM API calls with NetApi
This is needed for Nano Server compatibility

Closes-Bug: #1493150
Co-Authored-By: Cosmin Poieana <cpoieana@cloudbasesolutions.com>
Change-Id: Id805e8e96f749567f34435816d43f571b44bdb4a
2015-09-09 06:05:19 +03:00
Claudiu Popa
fccf0e6f00 Move to the new oslo_config and oslo_log modules
Since a couple of releases ago, the old oslo.config is now
oslo_config, the same thing happening to oslo.log as well.
This patch also removes the vendorized openstack package,
since it's redundant now that oslo_log is out of the
incubator.

Change-Id: Iae1318aa0d2a9aab2d4f6af7d11ed1dfda51e733
2015-08-12 17:43:45 +03:00
Claudiu Popa
47e52e2e34 Add support for changing the password at next logon
This patch exports a new option, `password_next_logon`, which determines
what will happen at the next logon in certain conditions. The option
can accept three possible arguments: `always`, which forces the user
to change the password at next logon, 'no', which doesn't change anything
and `clear_text_injected_only`, which forces the user to change the password
at the next logon if the password comes in clear text from the metadata.

Change-Id: Ic6a0526ea9c9902e183898c42497133a135b5c53
2015-06-29 20:39:18 +03:00
Claudiu Popa
5cd9947a3c Improve WindowsUtils._get_ipv4_forward_table
This patch improves _get_ipv4_forward_table by doing only
one call to iphlpapi.GetIpForwardTable. Previously two calls were
made, where the second call should have been called only when
the first one failed with INSUFFICIENT_BUFFER. This patch also
adds tests for _get_ipv4_forward_table, which was previously
untested.

Change-Id: I5728948557e749d0e0005a9d90c12e4093dc3307
2015-06-17 18:58:22 +03:00
Cosmin Poieana
d96fc944cd Add support for IPv6 network configuration
* proper parsing of network content metadata, including v6 support
* v6 addresses static network configuration support (address, netmask, gateway)
* remove redundant code in networkconfig and osutils network related tests

Change-Id: Ieb2c18e29d0c275feb3a03e7340b3c91327705ba
2015-05-07 23:16:56 +03:00
Claudiu Popa
b10917f9b0 Add a new cloud-config plugin for setting the timezone
cloud-config supports a new plugin, called 'set-timezone', which
can be used to change the timezone on the underlying instance.
The patch adds a new method in the osutils abstraction, called `set_timezone`,
which should be implemented  by each separated OS. The abstraction calls
into cloudbaseinit.utils.windows.timezone, another layer of abstraction
over two API methods, SetTimeZoneInformation for Windows 2003 and older
and SetDynamicTimeZoneInformation, for newer versions of Windows,
which also handles Daylight Saving Time.
The plugin supports standard IANA timezone names, which are then translated
to the Windows-specific timezone names, using tzlocal library.

Change-Id: I18674e1ae078fc69f3fb938065ba01a4de5464a1
2015-03-25 13:01:12 +02:00
Claudiu Popa
0073c7b86b Fix the names of assert methods belonging to a mock
Due to mock.Mock's nature, using an undefined method will not result
in an AttributeError, since the object will be created silently. This
changed in Python 3.5, where accessing a member which doesn't exist
will raise an AttributeError explicitly. This uncovered a couple of bugs
in the test suite.

Change-Id: Idbfa92d82b01ff4710dfdd4556500b5c61d20db6
2015-03-24 17:30:13 +02:00
Claudiu Popa
0b40f6368b Provide the error code in the Windows exception messages
This patch adds a type of exception for the Windows code, which interpolates
the given exception message with the last Windows API error, retrieved with
ctypes.GetLastError. This is useful in the case where we have only the log
at our disposal for debugging and some API method failed with reasons unknown.
Since we can't replicate what the user does everytime, having some additional
clue why an API failed could improve our bug detection workflow.

Change-Id: I364324ad5a8529b5363be3a7c6dc03ca52eb637c
2015-03-16 16:51:40 +02:00
Cosmin Poieana
980aa0a76e Return the appropriate system path
With x64 Python on x64 OS, when the `sysnative` parameter
is set to False, return the SysWOW64 path instead of System32.

Change-Id: I72aaff5ff7719526227368a7b3d73ba177ed56fe
2015-03-06 17:10:26 +02:00
Claudiu Popa
86bed21950 Increase the password limit
Previously it was using 14, for some compatibility with Windows NT.
We don't support Windows NT and the oldest version that we are supporting,
Windows 2003, supports passwords much larger than 14 characters.

Change-Id: Ifebb2ef8cee7eea76de4853bfd7399be97a95be3
2015-03-02 22:21:33 +02:00
Jenkins
3eb632c2fc Merge "Handle the choice of reboot of the instance in osutils.set_host_name" 2015-02-17 15:39:40 +00:00
Claudiu Popa
757438abf9 Add a method for obtaining the maximum password length
The patch adds `get_maximum_password_length` to osutils. The Windows
specific value which was used in setuserpassword and createuser plugins
is moved in the Windows implementation of get_maximum_password_length.

Change-Id: I08f999c750ac7e2858493072d41bb8f4927521ca
2015-02-17 17:09:36 +02:00
Claudiu Popa
e1d9e6b9c3 Handle the choice of reboot of the instance in osutils.set_host_name
Since the sethostname plugin was moved in plugins.common, there was a bit
of Windows specific functionality inside it, the fact that it returns reboot_required
in order to set the hostname on Windows. Now this choice is moved to
osutils.set_host_name, which will simply return False for non-Windows systems.

Change-Id: Ic7774f2c7dd86f3ade82a19520df4301bc9674a7
2015-02-16 19:06:48 +02:00
Jenkins
bc72058779 Merge "Global mass refactor" 2015-02-06 17:36:59 +00:00
Cosmin Poieana
415bdc7a72 Global mass refactor
* remove unnecessary vim comments
* use unittest.mock first, then mock
* consistent spaces
* ignore *.orig files
* pep8 & flake8 compliant

Change-Id: I48e8b5c13b8ea436a48180f526e97fa8da003b68
2015-01-18 17:51:56 +02:00
Claudiu Popa
086863ac9e Add support for multiple NTP hosts
This patch unpacks all the ips received as the NTP data from
the DHCP options and passes them properly to w32tm.

Change-Id: I19f0f8dfe040e983a04abe4744387adcbd9d0bdd
Closes-Bug: #1411006
2015-01-15 00:41:08 +02:00
Jenkins
f6ba6c7481 Merge "Fix x64 architecture related issues" 2015-01-12 14:15:26 +00:00
Cosmin Poieana
231414a004 Fix x64 architecture related issues
* fix types
* fix struct size

Change-Id: Ic219b7a40e6a69607bc4648c7d845b91f57faa66
2015-01-12 15:45:22 +02:00
Claudiu Popa
ef9b68c363 Change the trigger modes to network availability for w32time
This patch always changes the trigger mode of w32time service to
network availability mode, even if it was already set on domain joined
triggers. Even if the service was set to start automatically, if the
triggers weren't fulfilled, the service would have stopped after a while.

Change-Id: I4dea740e970fa71eb5af4fab784321d08ae10bbf
Closes-Bug: #1408983
2015-01-12 15:35:00 +02:00
Alessandro Pilotti
414fd1116c Adds ADSI based Windows user management
Replaces the Windows user creation and password management
implementation from "NET USER" execution to ADSI COM usage.

Change-Id: I4f95b094c95abb11762943afdb4be26541493159
Closes-Bug: #1404533
2014-12-21 23:58:02 +01:00
Claudiu Popa
3f91aabce2 Use keyword argument for boolean flags
Using keyword arguments makes the intent of the code clearer, due to
the fact that a name is attached to a boolean value, making the
reasoning about the code easier.

Change-Id: I0dd05fa521ed8bbaf1c6dbd7a3e554384642c1f4
2014-12-08 00:35:09 +02:00
Cosmin Poieana
8befa6c833 Add support for specific network configuration
The networkconfig plugin can now handle custom NetworkDetails
objects that contain data like IP address, gateway, broadcast etc.

Change-Id: Ife3f8f62b47704e7f25e0304b15953d6f06e8620
2014-11-26 22:22:15 +02:00
Robert Tingirica
4beacf6037 Added CloudbaseInitException class 2014-09-25 00:34:06 +03:00
Robert Tingirica
82293036cb Fixed assertEqual order in tests
Correct order should be assertEqual(<expected value>, <actual value>)
2014-09-10 14:27:53 +03:00
Robert Tingirica
6ebad94f38 Fixed various pep8 errors 2014-09-10 12:35:18 +03:00
Alessandro Pilotti
ceb4ae92d3 Replaces s.unicode with six.text_type
six.text_type() provides already the feature provided by s.unicode().
2014-09-09 23:44:40 +03:00
Robert Tingirica
7e01d19411 Modified osutils/test_windows.py to work on Linux 2014-09-09 18:57:42 +03:00
Alessandro Pilotti
26fd3229ed Refactoring of test_windows.py
Adds missing @mock.patch decorators for winreg and other modules.
2014-09-08 20:39:09 +03:00
Alessandro Pilotti
f2e6e9bd55 Fixes PEP8 errors in unicode management 2014-09-08 13:55:08 +03:00
Alessandro Pilotti
78811b3e85 Adds module for Python 3.x unicode compatibility
Adds the cloudbaseinit.utils.s module to replace the usage of the
"unicode()" builtin and support both Python 2.x and Python 3.x.
2014-09-08 00:22:29 +03:00
Alessandro Pilotti
324aadd4bf Replaces _winreg module with six.moves.winreg
The Python 2.x _winreg module is named winreg in Python 3.x
2014-09-07 23:19:23 +03:00
Robert Tingirica
1f3f29785d Removed print statements from test files 2014-09-07 21:36:07 +03:00
Alessandro Pilotti
b96c547857 Adds cloudbaseinit.utils.windows.network module
Replaces WMI queries to obtain DHCP client configuration with Win32 calls
in order to execute plugins that require DHCP options in the Specialize
pass after Sysprep.
2014-07-25 23:48:49 +03:00
Alessandro Pilotti
d0f0b9c803 Adds mac address as return value in get_dhcp_hosts_in_use 2014-06-11 20:38:12 +03:00
Robert Tingirica
bc5eb5f554 Adds tests for NTP and DHCP configuration 2014-06-10 15:48:24 +03:00
Tingirica Robert
695d622672 Added tests for windows config drive
Added tests for the metadata config drive modules for windows and
modiffied os utils tests for windows to match latest commit.
2014-04-25 21:08:42 +03:00
Tingirica Robert
5cbfe8b851 Removed static values from plugins tests
Replaced assertions with the value codes for execution from plugins/base.py and removed
mock for WMI method in osutils module windows.py
2014-04-10 17:19:56 +03:00
Robert Tingirica
fa53671896 Updated unit tests 2014-03-04 15:12:28 +02:00
Alessandro Pilotti
d7dff62e0a Move to oslo.config 2014-02-10 04:47:28 +02:00
Alessandro Pilotti
075a157927 Fixes get_network_adapters issue on Windows 2003
The "PhysicalAdapter" property of the WMI class "Win32_NetworkAdapter"
has been introduced with Windows Vista / 2008.

This patch avoids using the property in WQL queries based on
the current os.
2014-02-06 22:55:58 +02:00
trobert2
dd112383b0 Added unit tests using mock 2014-01-19 22:12:01 +02:00