コード例 #1
0
ファイル: migrate.py プロジェクト: shao-xy/ceph
    def new_volume(self):
        if self.args.osd_id and not self.args.no_systemd:
            osd_is_running = systemctl.osd_is_active(self.args.osd_id)
            if osd_is_running:
                mlogger.error('OSD ID is running, stop it with:'
                    ' systemctl stop ceph-osd@{}'.format(self.args.osd_id))
                raise SystemExit(
                    'Unable to attach new volume for OSD: {}'.format(
                        self.args.osd_id))

        target_lv = api.get_lv_by_fullname(self.args.target)
        if not target_lv:
            mlogger.error(
                'Target path {} is not a Logical Volume'.format(
                    self.args.target))
            raise SystemExit(
                'Unable to attach new volume : {}'.format(self.args.target))
        if target_lv.used_by_ceph:
            mlogger.error(
                'Target Logical Volume is already used by ceph: {}'.format(
                    self.args.target))
            raise SystemExit(
                'Unable to attach new volume : {}'.format(self.args.target))
        else:
            devices = find_associated_devices(self.args.osd_id,
                self.args.osd_fsid)
            self.make_new_volume(
                self.args.osd_id,
                self.args.osd_fsid,
                devices,
                target_lv)
コード例 #2
0
    def migrate_osd(self):
        if self.args.osd_id and not self.args.no_systemd:
            osd_is_running = systemctl.osd_is_active(self.args.osd_id)
            if osd_is_running:
                mlogger.error('OSD is running, stop it with: '
                              'systemctl stop ceph-osd@{}'.format(
                                  self.args.osd_id))
                raise SystemExit(
                    'Unable to migrate devices associated with OSD ID: {}'.
                    format(self.args.osd_id))

        target_lv = api.get_lv_by_fullname(self.args.target)
        if not target_lv:
            mlogger.error('Target path "{}" is not a Logical Volume'.format(
                self.args.target))
            raise SystemExit('Unable to migrate to : {}'.format(
                self.args.target))
        devices = find_associated_devices(self.args.osd_id, self.args.osd_fsid)
        if (not target_lv.used_by_ceph):
            self.migrate_to_new(self.args.osd_id, self.args.osd_fsid, devices,
                                target_lv)
        else:
            if (target_lv.tags['ceph.osd_id'] != self.args.osd_id
                    or target_lv.tags['ceph.osd_fsid'] != self.args.osd_fsid):
                mlogger.error(
                    'Target Logical Volume isn\'t used by the specified OSD: '
                    '{} FSID: {}'.format(self.args.osd_id, self.args.osd_fsid))
                raise SystemExit('Unable to migrate to : {}'.format(
                    self.args.target))

            self.migrate_to_existing(self.args.osd_id, self.args.osd_fsid,
                                     devices, target_lv)