]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: don't use api.lvm.get_lv
authorRishabh Dave <ridave@redhat.com>
Mon, 30 Dec 2019 14:56:22 +0000 (20:26 +0530)
committerRishabh Dave <ridave@redhat.com>
Tue, 30 Jun 2020 08:51:12 +0000 (14:21 +0530)
Use api.lvm.get_lvs() and api.lvm.get_first_lv() instead and update the
tests.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
src/ceph-volume/ceph_volume/devices/lvm/prepare.py
src/ceph-volume/ceph_volume/devices/lvm/zap.py
src/ceph-volume/ceph_volume/tests/devices/lvm/test_prepare.py
src/ceph-volume/ceph_volume/util/device.py

index 284f3c43ac1a4e05fad6d556a5e4e0ffc87838bf..2e07d15ec0a034cf2a0ad2ac4e48354d03b915fe 100644 (file)
@@ -135,6 +135,7 @@ class Prepare(object):
             raise RuntimeError('unable to use device')
         return uuid
 
+    # TODO: get rid of this method?
     def get_lv(self, argument):
         """
         Perform some parsing of the command-line value so that the process
@@ -148,7 +149,8 @@ class Prepare(object):
             vg_name, lv_name = argument.split('/')
         except (ValueError, AttributeError):
             return None
-        return api.get_lv(lv_name=lv_name, vg_name=vg_name)
+        return api.get_first_lv(filters={'lv_name': lv_name, 'vg_name':
+                                         vg_name})
 
     def setup_device(self, device_type, device_name, tags, size):
         """
index 9d09713ecf477ed9626cc09d6cadd7e4d81d5452..0e51d1edb706fce9b14d7618e1a7d2dda5f94679 100644 (file)
@@ -165,7 +165,8 @@ class Zap(object):
         Device examples: vg-name/lv-name, /dev/vg-name/lv-name
         Requirements: Must be a logical volume (LV)
         """
-        lv = api.get_lv(lv_name=device.lv_name, vg_name=device.vg_name)
+        lv = api.get_first_lv(filters={'lv_name': device.lv_name, 'vg_name':
+                                       device.vg_name})
         self.unmount_lv(lv)
 
         wipefs(device.abspath)
index f16b2ffffce63a2085bc96097fd86407762b5839..6a2c3fc72f8b44f4e9e40393adb8aa392e8b83bd 100644 (file)
@@ -1,4 +1,5 @@
 import pytest
+from ceph_volume.api import lvm as api
 from ceph_volume.devices import lvm
 from mock.mock import patch, Mock
 
@@ -119,13 +120,13 @@ class TestGetJournalLV(object):
 
     @pytest.mark.parametrize('arg', ['', '///', None, '/dev/sda1'])
     def test_no_journal_on_invalid_path(self, monkeypatch, arg):
-        monkeypatch.setattr(lvm.prepare.api, 'get_lv', lambda **kw: False)
+        monkeypatch.setattr(api, '_get_lv', lambda **kw: False)
         prepare = lvm.prepare.Prepare([])
         assert prepare.get_lv(arg) is None
 
     def test_no_journal_lv_found(self, monkeypatch):
         # patch it with 0 so we know we are getting to get_lv
-        monkeypatch.setattr(lvm.prepare.api, 'get_lv', lambda **kw: 0)
+        monkeypatch.setattr(api, '_get_lv', lambda **kw: 0)
         prepare = lvm.prepare.Prepare([])
         assert prepare.get_lv('vg/lv') == 0
 
index c72dfe89666e92f341b66849213505c9d1dc6cac..8ea83c30e711aab058980dc15d5e5aa3453f87ef 100644 (file)
@@ -252,7 +252,6 @@ class Device(object):
                     # actually unused (not 100% sure) and can simply be removed
                     self.vg_name = vgs[0]
                     self._is_lvm_member = True
-
                     self.lvs.extend(lvm.get_device_lvs(path))
         return self._is_lvm_member