]> git.proxmox.com Git - ceph.git/blame - ceph/src/ceph-volume/ceph_volume/systemd/systemctl.py
update sources to 12.2.8
[ceph.git] / ceph / src / ceph-volume / ceph_volume / systemd / systemctl.py
CommitLineData
d2e6a577
FG
1"""
2Utilities to control systemd units
3"""
4from ceph_volume import process
5
6
7def start(unit):
b32b8144 8 process.run(['systemctl', 'start', unit])
d2e6a577
FG
9
10
11def stop(unit):
b32b8144 12 process.run(['systemctl', 'stop', unit])
d2e6a577
FG
13
14
1adf2230
AA
15def enable(unit, runtime=False):
16 if runtime:
17 process.run(['systemctl', 'enable', '--runtime', unit])
18 else:
19 process.run(['systemctl', 'enable', unit])
d2e6a577
FG
20
21
22def disable(unit):
b32b8144 23 process.run(['systemctl', 'disable', unit])
d2e6a577
FG
24
25
3efd9988 26def mask(unit):
b32b8144 27 process.run(['systemctl', 'mask', unit])
3efd9988
FG
28
29
94b18763
FG
30def is_active(unit):
31 out, err, rc = process.call(
32 ['systemctl', 'is-active', unit],
33 verbose_on_failure=False
34 )
35 return rc == 0
36
37
d2e6a577
FG
38def start_osd(id_):
39 return start(osd_unit % id_)
40
41
42def stop_osd(id_):
43 return stop(osd_unit % id_)
44
45
46def enable_osd(id_):
1adf2230 47 return enable(osd_unit % id_, runtime=True)
d2e6a577
FG
48
49
50def disable_osd(id_):
51 return disable(osd_unit % id_)
52
53
94b18763
FG
54def osd_is_active(id_):
55 return is_active(osd_unit % id_)
56
57
d2e6a577
FG
58def enable_volume(id_, fsid, device_type='lvm'):
59 return enable(volume_unit % (device_type, id_, fsid))
60
61
3efd9988
FG
62def mask_ceph_disk():
63 # systemctl allows using a glob like '*' for masking, but there was a bug
64 # in that it wouldn't allow this for service templates. This means that
65 # masking ceph-disk@* will not work, so we must link the service directly.
94b18763 66 # /etc/systemd takes precedence regardless of the location of the unit
3efd9988 67 process.run(
b32b8144 68 ['ln', '-sf', '/dev/null', '/etc/systemd/system/ceph-disk@.service']
3efd9988
FG
69 )
70
71
d2e6a577
FG
72#
73# templates
74#
75
76osd_unit = "ceph-osd@%s"
3efd9988 77ceph_disk_unit = "ceph-disk@%s"
d2e6a577 78volume_unit = "ceph-volume@%s-%s-%s"