Skip to content

Commit

Permalink
CP-48018: Update to systemd to manage services
Browse files Browse the repository at this point in the history
All existing living XS use systemd to manage services,
Update the service management command to systemd

Signed-off-by: Lin Liu <[email protected]>
  • Loading branch information
liulinC authored and MarkSymsCtx committed Mar 1, 2024
1 parent 808760b commit 9ab89a5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions drivers/iscsilib.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,14 +378,14 @@ def get_luns(targetIQN, portal):


def is_iscsi_daemon_running():
cmd = ["/sbin/pidof", "-s", "/sbin/iscsid"]
cmd = ["/usr/bin/systemctl", "is-active", "iscsid.service"]
(rc, stdout, stderr) = util.doexec(cmd)
return (rc == 0)


def stop_daemon():
if is_iscsi_daemon_running():
cmd = ["service", "iscsid", "stop"]
cmd = ["/usr/bin/systemctl", "stop", "iscsid.service"]
failuremessage = "Failed to stop iscsi daemon"
exn_on_failure(cmd, failuremessage)

Expand All @@ -401,7 +401,7 @@ def restart_daemon():
shutil.rmtree(os.path.join(_ISCSI_DB_PATH, 'send_targets'))
except:
pass
cmd = ["service", "iscsid", "start"]
cmd = ["/usr/bin/systemctl", "start", "iscsid.service"]
failuremessage = "Failed to start iscsi daemon"
exn_on_failure(cmd, failuremessage)

Expand Down
2 changes: 1 addition & 1 deletion drivers/mpath_dmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def activate():

if not _is_mpath_daemon_running():
util.SMlog("Warning: multipath daemon not running. Starting daemon!")
cmd = ["service", "multipathd", "start"]
cmd = ["/usr/bin/systemctl", "start", "multipathd.service"]
util.pread2(cmd)

for i in range(0, 120):
Expand Down
4 changes: 2 additions & 2 deletions scripts/set-iscsi-initiator
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ touch $RUNNING_LOCK
echo "InitiatorName=$INITIATORNAME" > $INITIATORFILE
echo "InitiatorAlias=$INITIATORALIAS" >> $INITIATORFILE

systemctl is-active -q iscsid
systemctl is-active -q iscsid.service
if [ $? -eq 0 ]
then
# iscsid is running so restart
systemctl restart iscsid
systemctl restart iscsid.service
fi

) 200>$RUNNING_LOCK
2 changes: 1 addition & 1 deletion tests/test_mpath_dmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def test_activate_noiscsi_start_mpath(

self.assertEqual(1, mock_util.pread2.call_count)
mock_util.pread2.assert_called_once_with(
['service', 'multipathd', 'start'])
['/usr/bin/systemctl', 'start', 'multipathd.service'])

@testlib.with_context
@mock.patch('mpath_dmp.iscsilib', autospec=True)
Expand Down

0 comments on commit 9ab89a5

Please sign in to comment.