mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Address grain issue and add test
This commit is contained in:
parent
e5057287a7
commit
f9ac093cdd
2 changed files with 18 additions and 8 deletions
|
@ -1327,14 +1327,18 @@ def _windows_os_release_grain(caption, product_type):
|
|||
version = "Unknown"
|
||||
release = ""
|
||||
if "Server" in caption:
|
||||
for item in caption.split(" "):
|
||||
# If it's all digits, then it's version
|
||||
if re.match(r"\d+", item):
|
||||
version = item
|
||||
# If it starts with R and then numbers, it's the release
|
||||
# ie: R2
|
||||
if re.match(r"^R\d+$", item):
|
||||
release = item
|
||||
# Edge case here to handle MS Product that doesn't contain a year
|
||||
if re.match(r"^Microsoft Hyper-V Server$", caption):
|
||||
version = "2019"
|
||||
else:
|
||||
for item in caption.split(" "):
|
||||
# If it's all digits, then it's version
|
||||
if re.match(r"\d+", item):
|
||||
version = item
|
||||
# If it starts with R and then numbers, it's the release
|
||||
# ie: R2
|
||||
if re.match(r"^R\d+$", item):
|
||||
release = item
|
||||
os_release = "{0}Server{1}".format(version, release)
|
||||
else:
|
||||
for item in caption.split(" "):
|
||||
|
|
|
@ -869,6 +869,12 @@ class CoreGrainsTestCase(TestCase, LoaderModuleMockMixin):
|
|||
version = core._windows_os_release_grain(caption, 1)
|
||||
self.assertEqual(version, "7")
|
||||
|
||||
# Microsoft Hyper-V Server 2019
|
||||
# Issue https://github.com/saltstack/salt/issue/55212
|
||||
caption = "Microsoft Hyper-V Server"
|
||||
version = core._windows_os_release_grain(caption, 1)
|
||||
self.assertEqual(version, "2019Server")
|
||||
|
||||
@skipIf(not salt.utils.platform.is_linux(), "System is not Linux")
|
||||
def test_linux_memdata(self):
|
||||
"""
|
||||
|
|
Loading…
Add table
Reference in a new issue