Bugfix: access 'osmajorrelease' as an integer value

This commit is contained in:
Bo Maryniuk 2016-07-18 17:14:57 +02:00
parent 2040c7caa5
commit 3cb6940904
5 changed files with 13 additions and 14 deletions

View File

@ -165,8 +165,8 @@ def adduser(name, username, root=None):
Verifies if a valid username 'bar' as a member of an existing group 'foo',
if not then adds it.
'''
on_redhat_5 = __grains__.get('os_family') == 'RedHat' and __grains__.get('osmajorrelease') == '5'
on_suse_11 = __grains__.get('os_family') == 'Suse' and __grains__.get('osrelease_info')[0] == 11
on_redhat_5 = __grains__.get('os_family') == 'RedHat' and __grains__.get('osmajorrelease') == 5
on_suse_11 = __grains__.get('os_family') == 'Suse' and __grains__.get('osmajorrelease') == 11
if __grains__['kernel'] == 'Linux':
if on_redhat_5:
@ -200,8 +200,8 @@ def deluser(name, username, root=None):
Removes a member user 'bar' from a group 'foo'. If group is not present
then returns True.
'''
on_redhat_5 = __grains__.get('os_family') == 'RedHat' and __grains__.get('osmajorrelease') == '5'
on_suse_11 = __grains__.get('os_family') == 'Suse' and __grains__.get('osrelease_info')[0] == 11
on_redhat_5 = __grains__.get('os_family') == 'RedHat' and __grains__.get('osmajorrelease') == 5
on_suse_11 = __grains__.get('os_family') == 'Suse' and __grains__.get('osmajorrelease') == 11
grp_info = __salt__['group.info'](name)
try:
@ -244,8 +244,8 @@ def members(name, members_list, root=None):
Replaces a membership list for a local group 'foo'.
foo:x:1234:user1,user2,user3,...
'''
on_redhat_5 = __grains__.get('os_family') == 'RedHat' and __grains__.get('osmajorrelease') == '5'
on_suse_11 = __grains__.get('os_family') == 'Suse' and __grains__.get('osrelease_info')[0] == 11
on_redhat_5 = __grains__.get('os_family') == 'RedHat' and __grains__.get('osmajorrelease') == 5
on_suse_11 = __grains__.get('os_family') == 'Suse' and __grains__.get('osmajorrelease') == 11
if __grains__['kernel'] == 'Linux':
if on_redhat_5:

View File

@ -65,8 +65,7 @@ def __virtual__():
return __virtualname__
if __grains__['os'] == 'FreeBSD' and float(__grains__['osrelease']) >= 10:
return __virtualname__
if __grains__['os'] == 'FreeBSD' and \
float(__grains__['osmajorrelease']) == 9:
if __grains__['os'] == 'FreeBSD' and __grains__['osmajorrelease'] == 9:
providers = {}
if 'providers' in __opts__:
providers = __opts__['providers']

View File

@ -1,7 +1,7 @@
{% if grains['os'] == 'CentOS' %}
# START CentOS pkgrepo tests
{% if grains['osmajorrelease'] == '7' %}
{% if grains['osmajorrelease'] == 7 %}
epel-salttest:
pkgrepo.managed:
- humanname: Extra Packages for Enterprise Linux 7 - $basearch (salttest)

View File

@ -415,7 +415,7 @@ class PkgTest(integration.ModuleCase,
self.skipTest('Package manager is not available')
os_family = grains.get('os_family', '')
os_version = grains.get('osmajorrelease', [''])[0]
os_version = grains.get('osmajorrelease')
target = _PKG_TARGETS_DOT.get(os_family, {}).get(os_version)
if target:
version = latest_version(self.run_function, target)
@ -443,7 +443,7 @@ class PkgTest(integration.ModuleCase,
self.skipTest('Package manager is not available')
os_family = grains.get('os_family', '')
os_version = grains.get('osmajorrelease', [''])[0]
os_version = grains.get('osmajorrelease')
target = _PKG_TARGETS_EPOCH.get(os_family, {}).get(os_version)
if target:
version = latest_version(self.run_function, target)

View File

@ -113,7 +113,7 @@ class GroupAddTestCase(TestCase):
Tests if specified user gets added in the group.
'''
os_version_list = [
{'grains': {'kernel': 'Linux', 'os_family': 'RedHat', 'osmajorrelease': '5'},
{'grains': {'kernel': 'Linux', 'os_family': 'RedHat', 'osmajorrelease': 5},
'cmd': ('gpasswd', '-a', 'root', 'test')},
{'grains': {'kernel': 'Linux', 'os_family': 'Suse', 'osrelease_info': [11, 2]},
@ -140,7 +140,7 @@ class GroupAddTestCase(TestCase):
Tests if specified user gets deleted from the group.
'''
os_version_list = [
{'grains': {'kernel': 'Linux', 'os_family': 'RedHat', 'osmajorrelease': '5'},
{'grains': {'kernel': 'Linux', 'os_family': 'RedHat', 'osmajorrelease': 5},
'cmd': ('gpasswd', '-d', 'root', 'test')},
{'grains': {'kernel': 'Linux', 'os_family': 'Suse', 'osrelease_info': [11, 2]},
@ -175,7 +175,7 @@ class GroupAddTestCase(TestCase):
Tests if members of the group, get replaced with a provided list.
'''
os_version_list = [
{'grains': {'kernel': 'Linux', 'os_family': 'RedHat', 'osmajorrelease': '5'},
{'grains': {'kernel': 'Linux', 'os_family': 'RedHat', 'osmajorrelease': 5},
'cmd': ('gpasswd', '-M', 'foo', 'test')},
{'grains': {'kernel': 'Linux', 'os_family': 'Suse', 'osrelease_info': [11, 2]},