]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
ceph-volume: `get_first_*()` refactor 43959/head
authorGuillaume Abrioux <gabrioux@redhat.com>
Mon, 8 Mar 2021 08:59:26 +0000 (09:59 +0100)
committerGuillaume Abrioux <gabrioux@redhat.com>
Thu, 18 Nov 2021 13:14:46 +0000 (14:14 +0100)
commit9780d28028a40ecbfc327dab779e8a37c9aaed51
treef392c857c906a0b5715652b46a1a9d350add590f
parent911bc85f89d5c4ff92555237a37b5b774d7b1332
ceph-volume: `get_first_*()` refactor

As indicated by commit 17957d9beb42a04b8f180ccb7ba07d43179a41d3 those
fuctions were meant to avoid writing something like following:

```
lvs = get_lvs()
if len(lvs) >= 1:
lvs = lv[0]
```

Those functions should return `None` if 0 or more than 1 item is returned.
The current name of these functions are confusing and can lead to thinking that
we just want the first item returned, even though it returns more than 1
item, let's rename them to `get_single_pv()`, `get_single_vg()` and
`get_single_lv()`

Closes: https://tracker.ceph.com/issues/49643
Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
(cherry picked from commit a5e4216b49704783c55fb83b3ae6dde35b0082ad)
src/ceph-volume/ceph_volume/api/lvm.py
src/ceph-volume/ceph_volume/devices/lvm/prepare.py
src/ceph-volume/ceph_volume/devices/lvm/zap.py
src/ceph-volume/ceph_volume/devices/simple/scan.py
src/ceph-volume/ceph_volume/tests/api/test_lvm.py
src/ceph-volume/ceph_volume/tests/conftest.py
src/ceph-volume/ceph_volume/tests/devices/lvm/test_activate.py
src/ceph-volume/ceph_volume/tests/devices/lvm/test_listing.py
src/ceph-volume/ceph_volume/tests/devices/lvm/test_migrate.py
src/ceph-volume/ceph_volume/tests/devices/lvm/test_prepare.py
src/ceph-volume/ceph_volume/util/device.py