Skip to content

Commit

Permalink
Merge pull request #48756 from dwoz/core_grains_fix
Browse files Browse the repository at this point in the history
os.uname is not available on py2 windows
  • Loading branch information
dwoz committed Jul 24, 2018
2 parents 062fe7c + b7a37ec commit 8aef6d9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions salt/grains/core.py
Expand Up @@ -82,6 +82,10 @@
'will be missing'
)

HAS_UNAME = True
if not hasattr(os, 'uname'):
HAS_UNAME = False

_INTERFACES = {}


Expand Down Expand Up @@ -689,7 +693,7 @@ def _virtual(osdata):

# Quick backout for BrandZ (Solaris LX Branded zones)
# Don't waste time trying other commands to detect the virtual grain
if osdata['kernel'] == 'Linux' and 'BrandZ virtual linux' in os.uname():
if HAS_UNAME and osdata['kernel'] == 'Linux' and 'BrandZ virtual linux' in os.uname():
grains['virtual'] = 'zone'
return grains

Expand Down Expand Up @@ -1780,7 +1784,10 @@ def os_data():
elif grains['kernel'] == 'SunOS':
if salt.utils.platform.is_smartos():
# See https://github.com/joyent/smartos-live/issues/224
uname_v = os.uname()[3] # format: joyent_20161101T004406Z
if HAS_UNAME:
uname_v = os.uname()[3] # format: joyent_20161101T004406Z
else:
uname_v = os.name
uname_v = uname_v[uname_v.index('_')+1:]
grains['os'] = grains['osfullname'] = 'SmartOS'
# store a parsed version of YYYY.MM.DD as osrelease
Expand Down Expand Up @@ -1809,7 +1816,10 @@ def os_data():
else:
if development is not None:
osname = ' '.join((osname, development))
uname_v = os.uname()[3]
if HAS_UNAME:
uname_v = os.uname()[3]
else:
uname_v = os.name
grains['os'] = grains['osfullname'] = osname
if osname in ['Oracle Solaris'] and uname_v.startswith(osmajorrelease):
# Oracla Solars 11 and up have minor version in uname
Expand Down

0 comments on commit 8aef6d9

Please sign in to comment.