Add osd_noout to set/unset noout
Adds a small method to change the 'noout' setting, which is handy when doing planned maintenance. Change-Id: I3d5fc96b9b69fd98b7d84b5aed6079f3b02c19ab
This commit is contained in:
parent
407d98b96a
commit
27fc74e4e7
|
@ -2282,3 +2282,25 @@ def bootstrap_manager():
|
|||
unit = 'ceph-mgr@{}'.format(hostname)
|
||||
subprocess.check_call(['systemctl', 'enable', unit])
|
||||
service_restart(unit)
|
||||
|
||||
|
||||
def osd_noout(enable):
|
||||
"""Sets or unsets 'noout'
|
||||
|
||||
:param enable: bool. True to set noout, False to unset.
|
||||
:returns: bool. True if output looks right.
|
||||
:raises CalledProcessError: if an error occurs invoking the systemd cmd
|
||||
"""
|
||||
operation = {
|
||||
True: 'set',
|
||||
False: 'unset',
|
||||
}
|
||||
try:
|
||||
subprocess.check_call(['ceph', '--id', 'admin',
|
||||
'osd', operation[enable],
|
||||
'noout'])
|
||||
log('running ceph osd {} noout'.format(operation[enable]))
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
log(e)
|
||||
raise
|
||||
|
|
|
@ -487,6 +487,25 @@ class CephTestCase(unittest.TestCase):
|
|||
call(test_path, owner='ceph', group='ceph'),
|
||||
])
|
||||
|
||||
@patch.object(utils.subprocess, 'check_call')
|
||||
def test_osd_set_noout(self, mock_check_call):
|
||||
"""It changes the setting of ceph osd noout"""
|
||||
utils.osd_noout(True)
|
||||
mock_check_call.assert_called_once_with(
|
||||
['ceph', '--id', 'admin', 'osd', 'set', 'noout'])
|
||||
|
||||
@patch.object(utils.subprocess, 'check_call')
|
||||
def test_osd_unset_noout(self, mock_check_call):
|
||||
utils.osd_noout(False)
|
||||
mock_check_call.assert_called_once_with(
|
||||
['ceph', '--id', 'admin', 'osd', 'unset', 'noout'])
|
||||
|
||||
@patch.object(utils.subprocess, 'check_call')
|
||||
def test_osd_set_noout_fail(self, mock_check_call):
|
||||
mock_check_call.side_effect = CalledProcessError
|
||||
with self.assertRaises(Exception):
|
||||
utils.osd_noout(True)
|
||||
|
||||
|
||||
class CephVersionTestCase(unittest.TestCase):
|
||||
@patch.object(utils, 'get_os_codename_install_source')
|
||||
|
|
Loading…
Reference in New Issue