]> git.proxmox.com Git - ceph.git/blob - 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
1 """
2 Utilities to control systemd units
3 """
4 from ceph_volume import process
5
6
7 def start(unit):
8 process.run(['systemctl', 'start', unit])
9
10
11 def stop(unit):
12 process.run(['systemctl', 'stop', unit])
13
14
15 def enable(unit, runtime=False):
16 if runtime:
17 process.run(['systemctl', 'enable', '--runtime', unit])
18 else:
19 process.run(['systemctl', 'enable', unit])
20
21
22 def disable(unit):
23 process.run(['systemctl', 'disable', unit])
24
25
26 def mask(unit):
27 process.run(['systemctl', 'mask', unit])
28
29
30 def 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
38 def start_osd(id_):
39 return start(osd_unit % id_)
40
41
42 def stop_osd(id_):
43 return stop(osd_unit % id_)
44
45
46 def enable_osd(id_):
47 return enable(osd_unit % id_, runtime=True)
48
49
50 def disable_osd(id_):
51 return disable(osd_unit % id_)
52
53
54 def osd_is_active(id_):
55 return is_active(osd_unit % id_)
56
57
58 def enable_volume(id_, fsid, device_type='lvm'):
59 return enable(volume_unit % (device_type, id_, fsid))
60
61
62 def 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.
66 # /etc/systemd takes precedence regardless of the location of the unit
67 process.run(
68 ['ln', '-sf', '/dev/null', '/etc/systemd/system/ceph-disk@.service']
69 )
70
71
72 #
73 # templates
74 #
75
76 osd_unit = "ceph-osd@%s"
77 ceph_disk_unit = "ceph-disk@%s"
78 volume_unit = "ceph-volume@%s-%s-%s"