Rename systemd to systemctl and move it to tools
Signed-off-by: Katarzyna Treder <katarzyna.treder@h-partners.com>
This commit is contained in:
@@ -4,18 +4,17 @@
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
from test_tools import fs_utils
|
||||
from test_utils import systemd
|
||||
from test_tools import fs_utils, systemctl
|
||||
|
||||
|
||||
def add_mountpoint(device, mount_point, fs_type, mount_now=True):
|
||||
fs_utils.append_line("/etc/fstab",
|
||||
f"{device.path} {mount_point} {fs_type.name} defaults 0 0")
|
||||
systemd.reload_daemon()
|
||||
systemctl.reload_daemon()
|
||||
if mount_now:
|
||||
systemd.restart_service("local-fs.target")
|
||||
systemctl.restart_service("local-fs.target")
|
||||
|
||||
|
||||
def remove_mountpoint(device):
|
||||
fs_utils.remove_lines("/etc/fstab", device.path)
|
||||
systemd.reload_daemon()
|
||||
systemctl.reload_daemon()
|
||||
|
25
test_tools/systemctl.py
Normal file
25
test_tools/systemctl.py
Normal file
@@ -0,0 +1,25 @@
|
||||
#
|
||||
# Copyright(c) 2019-2022 Intel Corporation
|
||||
# Copyright(c) 2024 Huawei Technologies Co., Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
from pathlib import Path
|
||||
from core.test_run import TestRun
|
||||
|
||||
systemd_service_directory = Path("/usr/lib/systemd/system/")
|
||||
|
||||
def enable_service(name):
|
||||
TestRun.executor.run_expect_success(f"systemctl enable {name}")
|
||||
|
||||
|
||||
def disable_service(name):
|
||||
TestRun.executor.run_expect_success(f"systemctl disable {name}")
|
||||
|
||||
|
||||
def reload_daemon():
|
||||
TestRun.executor.run_expect_success("systemctl daemon-reload")
|
||||
|
||||
|
||||
def restart_service(name):
|
||||
TestRun.executor.run_expect_success(f"systemctl restart {name}")
|
Reference in New Issue
Block a user