Replace "split(' ')" with "split()" in masakari-monitors

By default, if split's step is None, runs of consecutive whitespace
are regarded as a single separator. So there is no need to use
split(' ').

Change-Id: Idcda8dfcaf5fd5abfab106238f91acdd3166883f
This commit is contained in:
YeHaiyang 2021-06-29 14:50:25 +08:00 committed by Ye Haiyang
parent fe5247c228
commit 6a496e7871
3 changed files with 9 additions and 9 deletions

View File

@ -82,7 +82,7 @@ class HandleHost(driver.DriverBase):
def _check_pacemaker_services(self, target_service):
try:
cmd_str = 'systemctl status ' + target_service
command = cmd_str.split(' ')
command = cmd_str.split()
# Execute command.
out, err = utils.execute(*command, run_as_root=True)
@ -150,7 +150,7 @@ class HandleHost(driver.DriverBase):
% (CONF.host.tcpdump_timeout,
corosync_multicast_interfaces[num],
corosync_multicast_ports[num])
command = cmd_str.split(' ')
command = cmd_str.split()
try:
# Execute tcpdump command.
@ -239,7 +239,7 @@ class HandleHost(driver.DriverBase):
% (str(CONF.host.ipmi_timeout), ipmi_values['userid'],
ipmi_values['passwd'], ipmi_values['interface'],
ipmi_values['ipaddr'])
command = cmd_str.split(' ')
command = cmd_str.split()
retry_count = 0
while True:

View File

@ -45,7 +45,7 @@ class HandleProcess(object):
def _execute_cmd(self, cmd_str, run_as_root):
# Split command string and delete empty elements.
command = cmd_str.split(' ')
command = cmd_str.split()
command = filter(lambda x: x != '', command)
try:

View File

@ -149,7 +149,7 @@ class TestHandleHost(testtools.TestCase):
mock_check_pacemaker_services.assert_any_call('pacemaker_remote')
cmd_str = ("timeout %s tcpdump -n -c 1 -p -i %s port %s") \
% (CONF.host.tcpdump_timeout, interfaces, ports)
command = cmd_str.split(' ')
command = cmd_str.split()
mock_execute.assert_called_once_with(*command, run_as_root=True)
@mock.patch.object(handle_host.HandleHost, '_check_pacemaker_services')
@ -281,7 +281,7 @@ class TestHandleHost(testtools.TestCase):
mock_check_pacemaker_services.assert_any_call('pacemaker_remote')
cmd_str = ("timeout %s tcpdump -n -c 1 -p -i %s port %s") \
% (CONF.host.tcpdump_timeout, interfaces, ports)
command = cmd_str.split(' ')
command = cmd_str.split()
mock_execute.assert_called_once_with(*command, run_as_root=True)
@mock.patch.object(utils, 'execute')
@ -400,7 +400,7 @@ class TestHandleHost(testtools.TestCase):
% (str(CONF.host.ipmi_timeout), ipmi_values['userid'],
ipmi_values['passwd'], ipmi_values['interface'],
ipmi_values['ipaddr'])
command = cmd_str.split(' ')
command = cmd_str.split()
mock_execute.assert_called_once_with(*command, run_as_root=False)
@mock.patch.object(utils, 'execute')
@ -440,7 +440,7 @@ class TestHandleHost(testtools.TestCase):
% (str(CONF.host.ipmi_timeout), ipmi_values['userid'],
ipmi_values['passwd'], ipmi_values['interface'],
ipmi_values['ipaddr'])
command = cmd_str.split(' ')
command = cmd_str.split()
calls = [mock.call(*command, run_as_root=False),
mock.call(*command, run_as_root=False),
mock.call(*command, run_as_root=False),
@ -471,7 +471,7 @@ class TestHandleHost(testtools.TestCase):
% (str(CONF.host.ipmi_timeout), ipmi_values['userid'],
ipmi_values['passwd'], ipmi_values['interface'],
ipmi_values['ipaddr'])
command = cmd_str.split(' ')
command = cmd_str.split()
calls = [mock.call(*command, run_as_root=False),
mock.call(*command, run_as_root=False),
mock.call(*command, run_as_root=False),