mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #42350 from twangboy/win_fix_ver_grains_2016.11
Fixes problem with Version and OS Release related grains on certain versions of Python (2016.11)
This commit is contained in:
commit
42bb1a64ca
2 changed files with 25 additions and 30 deletions
|
@ -920,28 +920,19 @@ def _windows_platform_data():
|
|||
|
||||
os_release = platform.release()
|
||||
info = salt.utils.win_osinfo.get_os_version_info()
|
||||
server = {'Vista': '2008Server',
|
||||
'7': '2008ServerR2',
|
||||
'8': '2012Server',
|
||||
'8.1': '2012ServerR2',
|
||||
'10': '2016Server'}
|
||||
|
||||
# Starting with Python 2.7.12 and 3.5.2 the `platform.uname()` function
|
||||
# started reporting the Desktop version instead of the Server version on
|
||||
# Server versions of Windows, so we need to look those up
|
||||
# Check for Python >=2.7.12 or >=3.5.2
|
||||
ver = pythonversion()['pythonversion']
|
||||
if ((six.PY2 and
|
||||
salt.utils.compare_versions(ver, '>=', [2, 7, 12, 'final', 0]))
|
||||
or
|
||||
(six.PY3 and
|
||||
salt.utils.compare_versions(ver, '>=', [3, 5, 2, 'final', 0]))):
|
||||
# (Product Type 1 is Desktop, Everything else is Server)
|
||||
if info['ProductType'] > 1:
|
||||
server = {'Vista': '2008Server',
|
||||
'7': '2008ServerR2',
|
||||
'8': '2012Server',
|
||||
'8.1': '2012ServerR2',
|
||||
'10': '2016Server'}
|
||||
os_release = server.get(os_release,
|
||||
'Grain not found. Update lookup table '
|
||||
'in the `_windows_platform_data` '
|
||||
'function in `grains\\core.py`')
|
||||
# So, if you find a Server Platform that's a key in the server
|
||||
# dictionary, then lookup the actual Server Release.
|
||||
if info['ProductType'] > 1 and os_release in server:
|
||||
os_release = server[os_release]
|
||||
|
||||
service_pack = None
|
||||
if info['ServicePackMajor'] > 0:
|
||||
|
|
|
@ -647,18 +647,22 @@ def system_information():
|
|||
release = platform.release()
|
||||
if platform.win32_ver()[0]:
|
||||
import win32api
|
||||
if ((sys.version_info.major == 2 and sys.version_info >= (2, 7, 12)) or
|
||||
(sys.version_info.major == 3 and sys.version_info >= (3, 5, 2))):
|
||||
if win32api.GetVersionEx(1)[8] > 1:
|
||||
server = {'Vista': '2008Server',
|
||||
'7': '2008ServerR2',
|
||||
'8': '2012Server',
|
||||
'8.1': '2012ServerR2',
|
||||
'10': '2016Server'}
|
||||
release = server.get(platform.release(),
|
||||
'UNKServer')
|
||||
_, ver, sp, extra = platform.win32_ver()
|
||||
version = ' '.join([release, ver, sp, extra])
|
||||
server = {'Vista': '2008Server',
|
||||
'7': '2008ServerR2',
|
||||
'8': '2012Server',
|
||||
'8.1': '2012ServerR2',
|
||||
'10': '2016Server'}
|
||||
# Starting with Python 2.7.12 and 3.5.2 the `platform.uname()` function
|
||||
# started reporting the Desktop version instead of the Server version on
|
||||
# Server versions of Windows, so we need to look those up
|
||||
# So, if you find a Server Platform that's a key in the server
|
||||
# dictionary, then lookup the actual Server Release.
|
||||
# If this is a Server Platform then `GetVersionEx` will return a number
|
||||
# greater than 1.
|
||||
if win32api.GetVersionEx(1)[8] > 1 and release in server:
|
||||
release = server[release]
|
||||
_, ver, sp, extra = platform.win32_ver()
|
||||
version = ' '.join([release, ver, sp, extra])
|
||||
|
||||
system = [
|
||||
('system', platform.system()),
|
||||
|
|
Loading…
Add table
Reference in a new issue