From eb0c52a3120be53a02aa5846740f9aec7e60fff5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Knecht?= Date: Thu, 2 Jan 2020 08:07:21 +0100 Subject: [PATCH] ceph-volume: Dereference symlink in lvm list MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This allows for a symlink to be passed to ``` ceph-volume lvm list ``` which makes it possible to use `/dev/disk/by-path/*` devices, for instance. Fixes: https://tracker.ceph.com/issues/43497 Signed-off-by: Benoît Knecht (cherry picked from commit 09fa3df8a39d361f2af11bded8aab9e0da334d51) --- src/ceph-volume/ceph_volume/devices/lvm/listing.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ceph-volume/ceph_volume/devices/lvm/listing.py b/src/ceph-volume/ceph_volume/devices/lvm/listing.py index f3416472a0b9c..1bb50c1d592a6 100644 --- a/src/ceph-volume/ceph_volume/devices/lvm/listing.py +++ b/src/ceph-volume/ceph_volume/devices/lvm/listing.py @@ -2,6 +2,7 @@ from __future__ import print_function import argparse import json import logging +import os.path from textwrap import dedent from ceph_volume import decorators from ceph_volume.util import disk @@ -162,7 +163,14 @@ class List(object): this tool before and contain enough metadata. """ if args.device: - return self.single_report(args.device, lvs) + # The `args.device` argument can be a logical volume name or a + # device path. If it's a path that exists, use the canonical path + # (in particular, dereference symlinks); otherwise, assume it's a + # logical volume name and use it as-is. + device = args.device + if os.path.exists(device): + device = os.path.realpath(device) + return self.single_report(device, lvs) else: return self.full_report(lvs) -- 2.39.5