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)
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)
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)
def zap_osd(self): if self.args.osd_id: osd_is_running = systemctl.osd_is_active(self.args.osd_id) if osd_is_running: mlogger.error("OSD ID %s is running, stop it with:" % self.args.osd_id) mlogger.error("systemctl stop ceph-osd@%s" % self.args.osd_id) raise SystemExit("Unable to zap devices associated with OSD ID: %s" % self.args.osd_id) devices = find_associated_devices(self.args.osd_id, self.args.osd_fsid) self.zap(devices)
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)