def scan_device(self, path): device_metadata = {'path': None, 'uuid': None} if not path: return device_metadata if self.is_encrypted: encryption_metadata = encryption.legacy_encrypted(path) device_metadata['path'] = encryption_metadata['device'] device_metadata['uuid'] = disk.get_partuuid( encryption_metadata['device']) return device_metadata # cannot read the symlink if this is tmpfs if os.path.islink(path): device = os.readlink(path) else: device = path lvm_device = lvm.get_lv_from_argument(device) if lvm_device: device_uuid = lvm_device.lv_uuid else: device_uuid = disk.get_partuuid(device) device_metadata['uuid'] = device_uuid device_metadata['path'] = device return device_metadata
def scan_device(self, path): device_metadata = {'path': None, 'uuid': None} if not path: return device_metadata if self.is_encrypted: encryption_metadata = encryption.legacy_encrypted(path) device_metadata['path'] = encryption_metadata['device'] device_metadata['uuid'] = disk.get_partuuid(encryption_metadata['device']) return device_metadata # cannot read the symlink if this is tmpfs if os.path.islink(path): device = os.readlink(path) else: device = path lvm_device = lvm.get_lv_from_argument(device) if lvm_device: device_uuid = lvm_device.lv_uuid else: device_uuid = disk.get_partuuid(device) device_metadata['uuid'] = device_uuid device_metadata['path'] = device return device_metadata
def main(self): sub_command_help = dedent(""" Scan running OSDs, an OSD directory (or data device) for files and configurations that will allow to take over the management of the OSD. Scanned OSDs will get their configurations stored in /etc/ceph/osd/<id>-<fsid>.json For an OSD ID of 0 with fsid of ``a9d50838-e823-43d6-b01f-2f8d0a77afc2`` that could mean a scan command that looks like:: ceph-volume lvm scan /var/lib/ceph/osd/ceph-0 Which would store the metadata in a JSON file at:: /etc/ceph/osd/0-a9d50838-e823-43d6-b01f-2f8d0a77afc2.json To scan all running OSDs: ceph-volume simple scan To a scan a specific running OSD: ceph-volume simple scan /var/lib/ceph/osd/{cluster}-{osd id} And to scan a device (mounted or unmounted) that has OSD data in it, for example /dev/sda1 ceph-volume simple scan /dev/sda1 Scanning a device or directory that belongs to an OSD not created by ceph-disk will be ingored. """) parser = argparse.ArgumentParser( prog='ceph-volume simple scan', formatter_class=argparse.RawDescriptionHelpFormatter, description=sub_command_help, ) parser.add_argument( '-f', '--force', action='store_true', help='If OSD has already been scanned, the JSON file will be overwritten' ) parser.add_argument( '--stdout', action='store_true', help='Do not save to a file, output metadata to stdout' ) parser.add_argument( 'osd_path', metavar='OSD_PATH', type=arg_validators.OSDPath(), nargs='?', default=None, help='Path to an existing OSD directory or OSD data partition' ) args = parser.parse_args(self.argv) paths = [] if args.osd_path: paths.append(args.osd_path) else: osd_ids = systemctl.get_running_osd_ids() for osd_id in osd_ids: paths.append("/var/lib/ceph/osd/{}-{}".format( conf.cluster, osd_id, )) # Capture some environment status, so that it can be reused all over self.device_mounts = system.get_mounts(devices=True) self.path_mounts = system.get_mounts(paths=True) for path in paths: args.osd_path = path device = Device(args.osd_path) if device.is_partition: if device.ceph_disk.type != 'data': label = device.ceph_disk.partlabel msg = 'Device must be the ceph data partition, but PARTLABEL reported: "%s"' % label raise RuntimeError(msg) self.encryption_metadata = encryption.legacy_encrypted(args.osd_path) self.is_encrypted = self.encryption_metadata['encrypted'] device = Device(self.encryption_metadata['device']) if not device.is_ceph_disk_member: terminal.warning("Ignoring %s because it's not a ceph-disk created osd." % path) else: self.scan(args)
def main(self): sub_command_help = dedent(""" Scan running OSDs, an OSD directory (or data device) for files and configurations that will allow to take over the management of the OSD. Scanned OSDs will get their configurations stored in /etc/ceph/osd/<id>-<fsid>.json For an OSD ID of 0 with fsid of ``a9d50838-e823-43d6-b01f-2f8d0a77afc2`` that could mean a scan command that looks like:: ceph-volume lvm scan /var/lib/ceph/osd/ceph-0 Which would store the metadata in a JSON file at:: /etc/ceph/osd/0-a9d50838-e823-43d6-b01f-2f8d0a77afc2.json To scan all running OSDs: ceph-volume simple scan To a scan a specific running OSD: ceph-volume simple scan /var/lib/ceph/osd/{cluster}-{osd id} And to scan a device (mounted or unmounted) that has OSD data in it, for example /dev/sda1 ceph-volume simple scan /dev/sda1 Scanning a device or directory that belongs to an OSD not created by ceph-disk will be ingored. """) parser = argparse.ArgumentParser( prog='ceph-volume simple scan', formatter_class=argparse.RawDescriptionHelpFormatter, description=sub_command_help, ) parser.add_argument( '-f', '--force', action='store_true', help='If OSD has already been scanned, the JSON file will be overwritten' ) parser.add_argument( '--stdout', action='store_true', help='Do not save to a file, output metadata to stdout' ) parser.add_argument( 'osd_path', metavar='OSD_PATH', type=arg_validators.OSDPath(), nargs='?', default=None, help='Path to an existing OSD directory or OSD data partition' ) args = parser.parse_args(self.argv) paths = [] if args.osd_path: paths.append(args.osd_path) else: osd_ids = systemctl.get_running_osd_ids() for osd_id in osd_ids: paths.append("/var/lib/ceph/osd/{}-{}".format( conf.cluster, osd_id, )) # Capture some environment status, so that it can be reused all over self.device_mounts = system.get_mounts(devices=True) self.path_mounts = system.get_mounts(paths=True) for path in paths: args.osd_path = path device = Device(args.osd_path) if device.is_partition: if device.ceph_disk.type != 'data': label = device.ceph_disk.partlabel msg = 'Device must be the ceph data partition, but PARTLABEL reported: "%s"' % label raise RuntimeError(msg) self.encryption_metadata = encryption.legacy_encrypted(args.osd_path) self.is_encrypted = self.encryption_metadata['encrypted'] device = Device(self.encryption_metadata['device']) if not device.is_ceph_disk_member: terminal.warning("Ignoring %s because it's not a ceph-disk created osd." % path) else: self.scan(args)
def main(self): sub_command_help = dedent(""" Scan an OSD directory (or data device) for files and configurations that will allow to take over the management of the OSD. Scanned OSDs will get their configurations stored in /etc/ceph/osd/<id>-<fsid>.json For an OSD ID of 0 with fsid of ``a9d50838-e823-43d6-b01f-2f8d0a77afc2`` that could mean a scan command that looks like:: ceph-volume lvm scan /var/lib/ceph/osd/ceph-0 Which would store the metadata in a JSON file at:: /etc/ceph/osd/0-a9d50838-e823-43d6-b01f-2f8d0a77afc2.json To a scan an existing, running, OSD: ceph-volume simple scan /var/lib/ceph/osd/{cluster}-{osd id} And to scan a device (mounted or unmounted) that has OSD data in it, for example /dev/sda1 ceph-volume simple scan /dev/sda1 """) parser = argparse.ArgumentParser( prog='ceph-volume simple scan', formatter_class=argparse.RawDescriptionHelpFormatter, description=sub_command_help, ) parser.add_argument( '-f', '--force', action='store_true', help='If OSD has already been scanned, the JSON file will be overwritten' ) parser.add_argument( '--stdout', action='store_true', help='Do not save to a file, output metadata to stdout' ) parser.add_argument( 'osd_path', metavar='OSD_PATH', type=arg_validators.OSDPath(), nargs='?', help='Path to an existing OSD directory or OSD data partition' ) if len(self.argv) == 0: print(sub_command_help) return args = parser.parse_args(self.argv) if disk.is_partition(args.osd_path): label = disk.lsblk(args.osd_path)['PARTLABEL'] if 'data' not in label: raise RuntimeError('Device must be the data partition, but got: %s' % label) # Capture some environment status, so that it can be reused all over self.device_mounts = system.get_mounts(devices=True) self.path_mounts = system.get_mounts(paths=True) self.encryption_metadata = encryption.legacy_encrypted(args.osd_path) self.is_encrypted = self.encryption_metadata['encrypted'] self.scan(args)
def main(self): sub_command_help = dedent(""" Scan an OSD directory (or data device) for files and configurations that will allow to take over the management of the OSD. Scanned OSDs will get their configurations stored in /etc/ceph/osd/<id>-<fsid>.json For an OSD ID of 0 with fsid of ``a9d50838-e823-43d6-b01f-2f8d0a77afc2`` that could mean a scan command that looks like:: ceph-volume lvm scan /var/lib/ceph/osd/ceph-0 Which would store the metadata in a JSON file at:: /etc/ceph/osd/0-a9d50838-e823-43d6-b01f-2f8d0a77afc2.json To a scan an existing, running, OSD: ceph-volume simple scan /var/lib/ceph/osd/{cluster}-{osd id} And to scan a device (mounted or unmounted) that has OSD data in it, for example /dev/sda1 ceph-volume simple scan /dev/sda1 """) parser = argparse.ArgumentParser( prog='ceph-volume simple scan', formatter_class=argparse.RawDescriptionHelpFormatter, description=sub_command_help, ) parser.add_argument( '-f', '--force', action='store_true', help= 'If OSD has already been scanned, the JSON file will be overwritten' ) parser.add_argument( '--stdout', action='store_true', help='Do not save to a file, output metadata to stdout') parser.add_argument( 'osd_path', metavar='OSD_PATH', type=arg_validators.OSDPath(), nargs='?', help='Path to an existing OSD directory or OSD data partition') if len(self.argv) == 0: print(sub_command_help) return args = parser.parse_args(self.argv) if disk.is_partition(args.osd_path): label = disk.lsblk(args.osd_path)['PARTLABEL'] if 'data' not in label: raise RuntimeError( 'Device must be the data partition, but got: %s' % label) # Capture some environment status, so that it can be reused all over self.device_mounts = system.get_mounts(devices=True) self.path_mounts = system.get_mounts(paths=True) self.encryption_metadata = encryption.legacy_encrypted(args.osd_path) self.is_encrypted = self.encryption_metadata['encrypted'] self.scan(args)