Merge pull request #32525 from BenoitKnecht/dereference-lvm-path-symlink

ceph-volume: Dereference symlink in lvm list
This commit is contained in:
Jan Fajerski 2020-01-10 11:46:04 +01:00 committed by GitHub
commit 53fd6909f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)