Exemplo n.º 1
0
    def main(self):
        if not self.args.devices:
            return self.parser.print_help()

        # Default to bluestore here since defaulting it in add_argument may
        # cause both to be True
        if not self.args.bluestore and not self.args.filestore:
            self.args.bluestore = True

        if (self.args.auto and not self.args.db_devices
                and not self.args.wal_devices
                and not self.args.journal_devices):
            self._sort_rotational_disks()

        self._check_slot_args()

        ensure_disjoint_device_lists(self.args.devices, self.args.db_devices,
                                     self.args.wal_devices,
                                     self.args.journal_devices)

        plan = self.get_plan(self.args)

        if self.args.report:
            self.report(plan)
            return 0

        if not self.args.yes:
            self.report(plan)
            terminal.info(
                'The above OSDs would be created if the operation continues')
            if not prompt_bool('do you want to proceed? (yes/no)'):
                terminal.error('aborting OSD provisioning')
                raise SystemExit(0)

        self._execute(plan)
Exemplo n.º 2
0
 def activate_all(self, args):
     listed_osds = direct_report()
     osds = {}
     for osd_id, devices in listed_osds.items():
         # the metadata for all devices in each OSD will contain
         # the FSID which is required for activation
         for device in devices:
             fsid = device.get('tags', {}).get('ceph.osd_fsid')
             if fsid:
                 osds[fsid] = osd_id
                 break
     if not osds:
         terminal.warning('Was unable to find any OSDs to activate')
         terminal.warning(
             'Verify OSDs are present with "ceph-volume lvm list"')
         return
     for osd_fsid, osd_id in osds.items():
         if systemctl.osd_is_active(osd_id):
             terminal.warning(
                 'OSD ID %s FSID %s process is active. Skipping activation'
                 % (osd_id, osd_fsid))
         else:
             terminal.info('Activating OSD ID %s FSID %s' %
                           (osd_id, osd_fsid))
             self.activate(args, osd_id=osd_id, osd_fsid=osd_fsid)
Exemplo n.º 3
0
    def execute(self, args):
        strategy = get_strategy(self.get_filtered_devices(args.devices), args)
        if not args.yes:
            strategy.report_pretty()
            terminal.info('The above OSDs would be created if the operation continues')
            if not prompt_bool('do you want to proceed? (yes/no)'):
                terminal.error('aborting OSD provisioning for %s' % ','.join(args.devices))
                raise SystemExit(0)

        strategy.execute()
Exemplo n.º 4
0
    def execute(self):
        if not self.args.yes:
            self.strategy.report_pretty(self.filtered_devices)
            terminal.info('The above OSDs would be created if the operation continues')
            if not prompt_bool('do you want to proceed? (yes/no)'):
                devices = ','.join([device.abspath for device in self.args.devices])
                terminal.error('aborting OSD provisioning for %s' % devices)
                raise SystemExit(0)

        self.strategy.execute()
Exemplo n.º 5
0
    def execute(self, args):
        strategy = self._get_strategy(args)
        if not args.yes:
            strategy.report_pretty()
            terminal.info('The above OSDs would be created if the operation continues')
            if not prompt_bool('do you want to proceed? (yes/no)'):
                devices = ','.join([device.abspath for device in args.devices])
                terminal.error('aborting OSD provisioning for %s' % devices)
                raise SystemExit(0)

        strategy.execute()
Exemplo n.º 6
0
    def execute(self, args):
        strategy = get_strategy(self.get_filtered_devices(args.devices), args)
        if not args.yes:
            strategy.report_pretty()
            terminal.info(
                'The above OSDs would be created if the operation continues')
            if not prompt_bool('do you want to proceed? (yes/no)'):
                terminal.error('aborting OSD provisioning for %s' %
                               ','.join(args.devices))
                raise SystemExit(0)

        strategy.execute()
Exemplo n.º 7
0
 def _is_valid_device(self, raise_sys_exit=True):
     super()._is_valid_device()
     if self._device.used_by_ceph:
         terminal.info('Device {} is already prepared'.format(
             self.dev_path))
         if raise_sys_exit:
             raise SystemExit(0)
     if self._device.has_fs and not self._device.used_by_ceph:
         raise RuntimeError("Device {} has a filesystem.".format(
             self.dev_path))
     if self.dev_path[0] == '/' and disk.has_bluestore_label(self.dev_path):
         raise RuntimeError("Device {} has bluestore signature.".format(
             self.dev_path))
     return self._device
Exemplo n.º 8
0
 def _is_valid_device(self, raise_sys_exit=True):
     out, err, rc = process.call(
         ['ceph-bluestore-tool', 'show-label', '--dev', self.dev_path],
         verbose_on_failure=False)
     if not rc:
         terminal.info("Raw device {} is already prepared.".format(
             self.dev_path))
         raise SystemExit(0)
     if disk.blkid(self.dev_path).get('TYPE') == 'crypto_LUKS':
         terminal.info(
             "Raw device {} might already be in use for a dmcrypt OSD, skipping."
             .format(self.dev_path))
         raise SystemExit(0)
     super()._is_valid_device()
     return self._device
Exemplo n.º 9
0
    def enable_systemd_units(self, osd_id, osd_fsid):
        """
        * disables the ceph-disk systemd units to prevent them from running when
          a UDEV event matches Ceph rules
        * creates the ``simple`` systemd units to handle the activation and
          startup of the OSD with ``osd_id`` and ``osd_fsid``
        * enables the OSD systemd unit and finally starts the OSD.
        """
        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'))
        else:
            terminal.info('Skipping enabling of `simple` systemd unit')
            terminal.info('Skipping masking of ceph-disk systemd units')

        if not self.skip_systemd:
            # enable the OSD
            systemctl.enable_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'
            )
Exemplo n.º 10
0
    def main(self):
        parser = argparse.ArgumentParser(
            prog='ceph-volume activate',
            formatter_class=argparse.RawDescriptionHelpFormatter,
            description=self.help,
        )
        parser.add_argument('--osd-id', help='OSD ID to activate')
        parser.add_argument('--osd-uuid', help='OSD UUID to active')
        parser.add_argument(
            '--no-systemd',
            dest='no_systemd',
            action='store_true',
            help=
            'Skip creating and enabling systemd units and starting OSD services'
        )
        parser.add_argument('--no-tmpfs',
                            action='store_true',
                            help='Do not use a tmpfs mount for OSD data dir')
        self.args = parser.parse_args(self.argv)

        # first try raw
        try:
            RAWActivate([]).activate(
                devs=None,
                start_osd_id=self.args.osd_id,
                start_osd_uuid=self.args.osd_uuid,
                tmpfs=not self.args.no_tmpfs,
                systemd=not self.args.no_systemd,
            )
            return
        except Exception as e:
            terminal.info(f'Failed to activate via raw: {e}')

        # then try lvm
        try:
            LVMActivate([]).activate(
                argparse.Namespace(
                    osd_id=self.args.osd_id,
                    osd_fsid=self.args.osd_uuid,
                    no_tmpfs=self.args.no_tmpfs,
                    no_systemd=self.args.no_systemd,
                ))
            return
        except Exception as e:
            terminal.info(f'Failed to activate via lvm: {e}')

        # then try simple
        try:
            SimpleActivate([]).activate(
                argparse.Namespace(
                    osd_id=self.args.osd_id,
                    osd_fsid=self.args.osd_uuid,
                    no_systemd=self.args.no_systemd,
                ))
            return
        except Exception as e:
            terminal.info(f'Failed to activate via simple: {e}')

        terminal.error('Failed to activate any OSD(s)')
Exemplo n.º 11
0
 def activate_all(self, args):
     listed_osds = direct_report()
     osds = {}
     for osd_id, devices in listed_osds.items():
         # the metadata for all devices in each OSD will contain
         # the FSID which is required for activation
         for device in devices:
             fsid = device.get('tags', {}).get('ceph.osd_fsid')
             if fsid:
                 osds[fsid] = osd_id
                 break
     if not osds:
         terminal.warning('Was unable to find any OSDs to activate')
         terminal.warning('Verify OSDs are present with "ceph-volume lvm list"')
         return
     for osd_fsid, osd_id in osds.items():
         if systemctl.osd_is_active(osd_id):
             terminal.warning(
                 'OSD ID %s FSID %s process is active. Skipping activation' % (osd_id, osd_fsid)
             )
         else:
             terminal.info('Activating OSD ID %s FSID %s' % (osd_id, osd_fsid))
             self.activate(args, osd_id=osd_id, osd_fsid=osd_fsid)
Exemplo n.º 12
0
    def enable_systemd_units(self, osd_id, osd_fsid):
        """
        * disables the ceph-disk systemd units to prevent them from running when
          a UDEV event matches Ceph rules
        * creates the ``simple`` systemd units to handle the activation and
          startup of the OSD with ``osd_id`` and ``osd_fsid``
        * enables the OSD systemd unit and finally starts the OSD.
        """
        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')
            )
        else:
            terminal.info('Skipping enabling of `simple` systemd unit')
            terminal.info('Skipping masking of ceph-disk systemd units')

        if not self.skip_systemd:
            # enable the OSD
            systemctl.enable_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'
            )