help = 'Enable systemd units to mount configured devices and start a Ceph OSD'
- def __init__(self, argv, systemd=False):
+ def __init__(self, argv, from_trigger=False):
self.argv = argv
- self.systemd = systemd
+ self.from_trigger = from_trigger
+ self.skip_systemd = False
def validate_devices(self, json_config):
"""
# make sure that the journal has proper permissions
system.chown(device)
- if not self.systemd:
+ if not self.from_trigger and not self.skip_systemd:
+ # means it was scanned and now activated directly, so ensure that
+ # ceph-disk units are disabled, and that the `simple` systemd unit
+ # is created and enabled
+
# enable the ceph-volume unit for this OSD
systemctl.enable_volume(osd_id, osd_fsid, 'simple')
# disable any/all ceph-disk units
systemctl.mask_ceph_disk()
+ terminal.warning(
+ ('All ceph-disk systemd units have been disabled to '
+ 'prevent OSDs getting triggered by UDEV events')
+ )
- # enable the OSD
- systemctl.enable_osd(osd_id)
+ if not self.skip_systemd:
+ # enable the OSD
+ systemctl.enable_osd(osd_id)
- # start the OSD
- systemctl.start_osd(osd_id)
+ # start the OSD
+ systemctl.start_osd(osd_id)
+ else:
+ terminal.info(
+ 'Skipping enabling and starting OSD simple systemd unit because --no-systemd was used'
+ )
terminal.success('Successfully activated OSD %s with FSID %s' % (osd_id, osd_fsid))
- terminal.warning(
- ('All ceph-disk systemd units have been disabled to '
- 'prevent OSDs getting triggered by UDEV events')
- )
def main(self):
sub_command_help = dedent("""
'--file',
help='The path to a JSON file, from a scanned OSD'
)
+ parser.add_argument(
+ '--no-systemd',
+ dest='skip_systemd',
+ action='store_true',
+ help='Skip creating and enabling systemd units and starting OSD services',
+ )
if len(self.argv) == 0:
print(sub_command_help)
return
if not os.path.exists(json_config):
raise RuntimeError('Expected JSON config path not found: %s' % json_config)
args.json_config = json_config
+ self.skip_systemd = args.skip_systemd
self.activate(args)