]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: move get_lvs_from_path() to api/lvm.py 47018/head
authorRishabh Dave <ridave@redhat.com>
Mon, 30 Nov 2020 09:40:30 +0000 (15:10 +0530)
committerGuillaume Abrioux <gabrioux@redhat.com>
Thu, 7 Jul 2022 20:22:52 +0000 (22:22 +0200)
This makes this method reusable across ceph-volume codebase.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
(cherry picked from commit 0ea399c01143673f0225b1b4a48136af75b0b6c5)

src/ceph-volume/ceph_volume/api/lvm.py
src/ceph-volume/ceph_volume/devices/lvm/listing.py

index 68e3204add09511890e0fda6f3021ac50cc85a01..4d0262f3aee8557703578df34d2984e1614846b1 100644 (file)
@@ -1188,3 +1188,14 @@ def get_lv_by_fullname(full_name):
     except ValueError:
         res_lv = None
     return res_lv
+
+def get_lvs_from_path(devpath):
+    lvs = []
+    if os.path.isabs(devpath):
+        # we have a block device
+        lvs = get_device_lvs(devpath)
+        if not lvs:
+            # maybe this was a LV path /dev/vg_name/lv_name or /dev/mapper/
+            lvs = get_lvs(filters={'path': devpath})
+
+    return lvs
index de19790511bfe9220a7b36425e83a0f7c518dad4..44d5063ce37e09c559d4258bac5975b4f9954d1b 100644 (file)
@@ -2,7 +2,6 @@ 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.api import lvm as api
@@ -140,22 +139,6 @@ class List(object):
         """
         return self.create_report(api.get_lvs())
 
-    def get_lvs_from_path(self, device):
-        lvs = []
-        if os.path.isabs(device):
-            # we have a block device
-            lvs = api.get_device_lvs(device)
-            if not lvs:
-                # maybe this was a LV path /dev/vg_name/lv_name or /dev/mapper/
-                lvs = api.get_lvs(filters={'path': device})
-        else:
-            # vg_name/lv_name was passed
-            vg_name, lv_name = device.split('/')
-            lvs = api.get_lvs(filters={'lv_name': lv_name,
-                                       'vg_name': vg_name})
-
-        return lvs
-
     def single_report(self, arg):
         """
         Generate a report for a single device. This can be either a logical
@@ -167,7 +150,7 @@ class List(object):
         if isinstance(arg, int) or arg.isdigit():
             lv = api.get_lvs_from_osd_id(arg)
         elif arg[0] == '/':
-            lv = self.get_lvs_from_path(arg)
+            lv = api.get_lvs_from_path(arg)
         else:
             lv = [api.get_single_lv(filters={'lv_name': arg.split('/')[1]})]