]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume: Remove refs to get_block_devs_lsblk 46375/head
authorZack Cerza <zack@redhat.com>
Tue, 21 Jun 2022 17:37:49 +0000 (11:37 -0600)
committerZack Cerza <zack@redhat.com>
Tue, 12 Jul 2022 19:07:58 +0000 (13:07 -0600)
It's been replaced by get_block_devs_sysfs

Signed-off-by: Zack Cerza <zack@redhat.com>
src/ceph-volume/ceph_volume/tests/conftest.py
src/ceph-volume/ceph_volume/tests/util/test_disk.py
src/ceph-volume/ceph_volume/util/disk.py

index 9645ba632bcf1593291314dda56fe1257db28415..d44c5c09c671b7e0739c77addbecb8bc48fca1e3 100644 (file)
@@ -268,8 +268,8 @@ def device_info_not_ceph_disk_member(monkeypatch, request):
                                       'PARTLABEL': request.param[1]})
 
 @pytest.fixture
-def patched_get_block_devs_lsblk():
-    with patch('ceph_volume.util.disk.get_block_devs_lsblk') as p:
+def patched_get_block_devs_sysfs():
+    with patch('ceph_volume.util.disk.get_block_devs_sysfs') as p:
         yield p
 
 @pytest.fixture
index 217bb81fad06df97843e1a890917dcd3eb62003e..ab652c22e6ddf5618d60ceaa580e692552cf91a1 100644 (file)
@@ -1,6 +1,5 @@
 import os
 import pytest
-from mock.mock import patch
 from ceph_volume.util import disk
 
 
@@ -218,33 +217,6 @@ class TestSizeParse(object):
         assert result == disk.Size(tb=1.8)
 
 
-class TestGetBlockDevsLsblk(object):
-
-    @patch('ceph_volume.process.call')
-    def test_return_structure(self, patched_call):
-        lsblk_stdout = [
-                       '/dev/dm-0 /dev/mapper/ceph--8b2684eb--56ff--49e4--8f28--522e04cbd6ab-osd--data--9fc29fbf--3b5b--4066--be10--61042569b5a7 lvm',
-                       '/dev/vda  /dev/vda                                                                                                       disk',
-                       '/dev/vda1 /dev/vda1                                                                                                      part',
-                       '/dev/vdb  /dev/vdb                                                                                                       disk',]
-        patched_call.return_value = (lsblk_stdout, '', 0)
-        disks = disk.get_block_devs_lsblk()
-        assert len(disks) == len(lsblk_stdout)
-        assert len(disks[0]) == 3
-
-    @patch('ceph_volume.process.call')
-    def test_empty_lsblk(self, patched_call):
-        patched_call.return_value = ([], '', 0)
-        disks = disk.get_block_devs_lsblk()
-        assert len(disks) == 0
-
-    @patch('ceph_volume.process.call')
-    def test_raise_on_failure(self, patched_call):
-        patched_call.return_value = ([], 'error', 1)
-        with pytest.raises(OSError):
-            disk.get_block_devs_lsblk()
-
-
 class TestGetDevices(object):
 
     def setup_path(self, tmpdir):
@@ -252,14 +224,14 @@ class TestGetDevices(object):
         os.makedirs(path)
         return path
 
-    def test_no_devices_are_found(self, tmpdir, patched_get_block_devs_lsblk):
-        patched_get_block_devs_lsblk.return_value = []
+    def test_no_devices_are_found(self, tmpdir, patched_get_block_devs_sysfs):
+        patched_get_block_devs_sysfs.return_value = []
         result = disk.get_devices(_sys_block_path=str(tmpdir))
         assert result == {}
 
-    def test_sda_block_is_found(self, tmpdir, patched_get_block_devs_lsblk):
+    def test_sda_block_is_found(self, tmpdir, patched_get_block_devs_sysfs):
         sda_path = '/dev/sda'
-        patched_get_block_devs_lsblk.return_value = [[sda_path, sda_path, 'disk']]
+        patched_get_block_devs_sysfs.return_value = [[sda_path, sda_path, 'disk']]
         block_path = self.setup_path(tmpdir)
         os.makedirs(os.path.join(block_path, 'sda'))
         result = disk.get_devices(_sys_block_path=block_path)
@@ -269,9 +241,9 @@ class TestGetDevices(object):
         assert result[sda_path]['partitions'] == {}
 
 
-    def test_sda_size(self, tmpfile, tmpdir, patched_get_block_devs_lsblk):
+    def test_sda_size(self, tmpfile, tmpdir, patched_get_block_devs_sysfs):
         sda_path = '/dev/sda'
-        patched_get_block_devs_lsblk.return_value = [[sda_path, sda_path, 'disk']]
+        patched_get_block_devs_sysfs.return_value = [[sda_path, sda_path, 'disk']]
         block_path = self.setup_path(tmpdir)
         block_sda_path = os.path.join(block_path, 'sda')
         os.makedirs(block_sda_path)
@@ -280,10 +252,10 @@ class TestGetDevices(object):
         assert list(result.keys()) == [sda_path]
         assert result[sda_path]['human_readable_size'] == '512.00 KB'
 
-    def test_sda_sectorsize_fallsback(self, tmpfile, tmpdir, patched_get_block_devs_lsblk):
+    def test_sda_sectorsize_fallsback(self, tmpfile, tmpdir, patched_get_block_devs_sysfs):
         # if no sectorsize, it will use queue/hw_sector_size
         sda_path = '/dev/sda'
-        patched_get_block_devs_lsblk.return_value = [[sda_path, sda_path, 'disk']]
+        patched_get_block_devs_sysfs.return_value = [[sda_path, sda_path, 'disk']]
         block_path = self.setup_path(tmpdir)
         block_sda_path = os.path.join(block_path, 'sda')
         sda_queue_path = os.path.join(block_sda_path, 'queue')
@@ -294,9 +266,9 @@ class TestGetDevices(object):
         assert list(result.keys()) == [sda_path]
         assert result[sda_path]['sectorsize'] == '1024'
 
-    def test_sda_sectorsize_from_logical_block(self, tmpfile, tmpdir, patched_get_block_devs_lsblk):
+    def test_sda_sectorsize_from_logical_block(self, tmpfile, tmpdir, patched_get_block_devs_sysfs):
         sda_path = '/dev/sda'
-        patched_get_block_devs_lsblk.return_value = [[sda_path, sda_path, 'disk']]
+        patched_get_block_devs_sysfs.return_value = [[sda_path, sda_path, 'disk']]
         block_path = self.setup_path(tmpdir)
         block_sda_path = os.path.join(block_path, 'sda')
         sda_queue_path = os.path.join(block_sda_path, 'queue')
@@ -306,9 +278,9 @@ class TestGetDevices(object):
         result = disk.get_devices(_sys_block_path=block_path)
         assert result[sda_path]['sectorsize'] == '99'
 
-    def test_sda_sectorsize_does_not_fallback(self, tmpfile, tmpdir, patched_get_block_devs_lsblk):
+    def test_sda_sectorsize_does_not_fallback(self, tmpfile, tmpdir, patched_get_block_devs_sysfs):
         sda_path = '/dev/sda'
-        patched_get_block_devs_lsblk.return_value = [[sda_path, sda_path, 'disk']]
+        patched_get_block_devs_sysfs.return_value = [[sda_path, sda_path, 'disk']]
         block_path = self.setup_path(tmpdir)
         block_sda_path = os.path.join(block_path, 'sda')
         sda_queue_path = os.path.join(block_sda_path, 'queue')
@@ -319,9 +291,9 @@ class TestGetDevices(object):
         result = disk.get_devices(_sys_block_path=block_path)
         assert result[sda_path]['sectorsize'] == '99'
 
-    def test_is_rotational(self, tmpfile, tmpdir, patched_get_block_devs_lsblk):
+    def test_is_rotational(self, tmpfile, tmpdir, patched_get_block_devs_sysfs):
         sda_path = '/dev/sda'
-        patched_get_block_devs_lsblk.return_value = [[sda_path, sda_path, 'disk']]
+        patched_get_block_devs_sysfs.return_value = [[sda_path, sda_path, 'disk']]
         block_path = self.setup_path(tmpdir)
         block_sda_path = os.path.join(block_path, 'sda')
         sda_queue_path = os.path.join(block_sda_path, 'queue')
@@ -331,9 +303,9 @@ class TestGetDevices(object):
         result = disk.get_devices(_sys_block_path=block_path)
         assert result[sda_path]['rotational'] == '1'
 
-    def test_is_ceph_rbd(self, tmpfile, tmpdir, patched_get_block_devs_lsblk):
+    def test_is_ceph_rbd(self, tmpfile, tmpdir, patched_get_block_devs_sysfs):
         rbd_path = '/dev/rbd0'
-        patched_get_block_devs_lsblk.return_value = [[rbd_path, rbd_path, 'disk']]
+        patched_get_block_devs_sysfs.return_value = [[rbd_path, rbd_path, 'disk']]
         block_path = self.setup_path(tmpdir)
         block_rbd_path = os.path.join(block_path, 'rbd0')
         os.makedirs(block_rbd_path)
index 7acc3a90d4b0ad1e2842ff2cebd60d74335d13b3..0a11d217907f83c43546835069f7e471f53fc68f 100644 (file)
@@ -743,25 +743,6 @@ def is_locked_raw_device(disk_path):
     return 0
 
 
-def get_block_devs_lsblk(device=''):
-    '''
-    This returns a list of lists with 3 items per inner list.
-    KNAME - reflects the kernel device name , for example /dev/sda or /dev/dm-0
-    NAME - the device name, for example /dev/sda or
-           /dev/mapper/<vg_name>-<lv_name>
-    TYPE - the block device type: disk, partition, lvm and such
-
-    '''
-    cmd = ['lsblk', '-plno', 'KNAME,NAME,TYPE']
-    if device:
-        cmd.extend(['--nodeps', device])
-    stdout, stderr, rc = process.call(cmd)
-    # lsblk returns 1 on failure
-    if rc == 1:
-        raise OSError('lsblk returned failure, stderr: {}'.format(stderr))
-    return [re.split(r'\s+', line) for line in stdout]
-
-
 class AllowLoopDevices(object):
     allow = False
     warned = False