Skip to content

Commit

Permalink
ceph-volume: update simple scan to scan all running OSDs
Browse files Browse the repository at this point in the history
If no argument is passed to `ceph-volume simple scan` it will
inspect any running osds and scan them if they were created by
ceph-disk.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
(cherry picked from commit 28e454e)
  • Loading branch information
andrewschoen committed Mar 8, 2019
1 parent 242abbd commit 4ed9a28
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions src/ceph-volume/ceph_volume/devices/simple/scan.py
Expand Up @@ -7,6 +7,7 @@
from textwrap import dedent
from ceph_volume import decorators, terminal, conf
from ceph_volume.api import lvm
from ceph_volume.systemd import systemctl
from ceph_volume.util import arg_validators, system, disk, encryption
from ceph_volume.util.device import Device

Expand Down Expand Up @@ -329,25 +330,40 @@ def main(self):
metavar='OSD_PATH',
type=arg_validators.OSDPath(),
nargs='?',
default=None,
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)
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)
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)
self.encryption_metadata = encryption.legacy_encrypted(args.osd_path)
self.is_encrypted = self.encryption_metadata['encrypted']

self.scan(args)
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)

0 comments on commit 4ed9a28

Please sign in to comment.