Skip to content

Commit 81d88bc

Browse files
committed
cephadm: add option to install systemd unit only
Cephadm is responsible for installing systemd units on the system. If for some reasons the units are missing, this newly added option cephadm unit-install will install them (and do nothing else). This is useful in some cases where going through the others means of creating such unit are not possible, or do extra unwanted things. Signed-off-by: Cyril Duval <[email protected]>
1 parent b044a96 commit 81d88bc

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/cephadm/cephadm.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5493,6 +5493,24 @@ def command_ceph_volume(ctx):
54935493
##################################
54945494

54955495

5496+
def command_unit_install(ctx):
5497+
# type: (CephadmContext) -> int
5498+
if not ctx.fsid:
5499+
raise Error('must pass --fsid to specify cluster')
5500+
5501+
fsid = ctx.fsid
5502+
install_base_units(ctx, fsid)
5503+
unit = get_unit_file(ctx, fsid)
5504+
unit_file = 'ceph-%[email protected]' % (fsid)
5505+
with open(ctx.unit_dir + '/' + unit_file + '.new', 'w') as f:
5506+
f.write(unit)
5507+
os.rename(ctx.unit_dir + '/' + unit_file + '.new',
5508+
ctx.unit_dir + '/' + unit_file)
5509+
call_throws(ctx, ['systemctl', 'daemon-reload'])
5510+
5511+
return 0
5512+
5513+
54965514
@infer_fsid
54975515
def command_unit(ctx):
54985516
# type: (CephadmContext) -> int
@@ -7223,6 +7241,10 @@ def _get_parser():
72237241
required=True,
72247242
help='daemon name (type.id)')
72257243

7244+
parser_unit_install = subparsers.add_parser(
7245+
'unit-install', help="Install the daemon's systemd unit")
7246+
parser_unit_install.set_defaults(func=command_unit_install)
7247+
72267248
parser_logs = subparsers.add_parser(
72277249
'logs', help='print journald logs for a daemon container')
72287250
parser_logs.set_defaults(func=command_logs)

0 commit comments

Comments
 (0)