mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Update set_hwclock to only accept UTC on NILinuxRT
NILinuxRT systems do not support non-UTC timezones for hwclock, so enforce that in set_hwclock.
This commit is contained in:
parent
3b9924f165
commit
6254b8f326
@ -480,12 +480,14 @@ def set_hwclock(clock):
|
||||
|
||||
salt '*' timezone.set_hwclock UTC
|
||||
'''
|
||||
if 'AIX' in __grains__['os_family']:
|
||||
if clock.lower() != 'utc':
|
||||
raise SaltInvocationError(
|
||||
'UTC is the only permitted value'
|
||||
)
|
||||
return True
|
||||
os_family = __grains__['os_family']
|
||||
for family in ('AIX', 'NILinuxRT'):
|
||||
if family in os_family:
|
||||
if clock.lower() != 'utc':
|
||||
raise SaltInvocationError(
|
||||
'UTC is the only permitted value'
|
||||
)
|
||||
return True
|
||||
|
||||
timezone = get_zone()
|
||||
|
||||
|
@ -316,15 +316,16 @@ class TimezoneModuleTestCase(TestCase, LoaderModuleMockMixin):
|
||||
@patch('os.path.exists', MagicMock(return_value=True))
|
||||
@patch('os.unlink', MagicMock())
|
||||
@patch('os.symlink', MagicMock())
|
||||
def test_set_hwclock_aix(self):
|
||||
def test_set_hwclock_aix_nilinuxrt(self):
|
||||
'''
|
||||
Test set hwclock on AIX
|
||||
Test set hwclock on AIX and NILinuxRT
|
||||
:return:
|
||||
'''
|
||||
with patch.dict(timezone.__grains__, {'os_family': ['AIX']}):
|
||||
with self.assertRaises(SaltInvocationError):
|
||||
assert timezone.set_hwclock('forty two')
|
||||
assert timezone.set_hwclock('UTC')
|
||||
for osfamily in ['AIX', 'NILinuxRT']:
|
||||
with patch.dict(timezone.__grains__, {'os_family': osfamily}):
|
||||
with self.assertRaises(SaltInvocationError):
|
||||
assert timezone.set_hwclock('forty two')
|
||||
assert timezone.set_hwclock('UTC')
|
||||
|
||||
@patch('salt.utils.which', MagicMock(return_value=False))
|
||||
@patch('os.path.exists', MagicMock(return_value=True))
|
||||
|
Loading…
Reference in New Issue
Block a user