修改 ceph-volume lvm api 函数未定义问题2

This commit is contained in:
yangxiaoliang 2022-07-18 16:44:22 +08:00
parent 070aa3ad0d
commit e38a529796
2 changed files with 45 additions and 1 deletions

View File

@ -0,0 +1,40 @@
From 9780d28028a40ecbfc327dab779e8a37c9aaed51 Mon Sep 17 00:00:00 2001
From: Guillaume Abrioux <gabrioux@redhat.com>
Date: Mon, 8 Mar 2021 09:59:26 +0100
Subject: [PATCH] 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 | 54 +++--
diff --git a/src/ceph-volume/ceph_volume/api/lvm.py b/src/ceph-volume/ceph_volume/api/lvm.py
index e5551206e16..bbafa06831b 100644
--- a/src/ceph-volume/ceph_volume/api/lvm.py
+++ b/src/ceph-volume/ceph_volume/api/lvm.py
@@ -1144,7 +1144,7 @@ def get_lv_by_fullname(full_name):
"""
try:
vg_name, lv_name = full_name.split('/')
- res_lv = get_first_lv(filters={'lv_name': lv_name,
+ res_lv = get_single_lv(filters={'lv_name': lv_name,
'vg_name': vg_name})
except ValueError:
res_lv = None

View File

@ -125,7 +125,7 @@
#################################################################################
Name: ceph
Version: 16.2.7
Release: 3
Release: 4
%if 0%{?fedora} || 0%{?rhel} || 0%{?openEuler}
Epoch: 2
%endif
@ -147,6 +147,7 @@ Patch1: 0001-fix-error-transform-is-not-a-member-of-std.patch
Patch2: 0002-enable-install-deps-in-openEuler.patch
Patch3: 0003-isa-l-update.patch
Patch4: 0004-cmake-add-support-python-3.10.patch
Patch5: 0005-ceph-volume-lvm-api-function-no-undefined.patch
%if 0%{?suse_version}
# _insert_obs_source_lines_here
ExclusiveArch: x86_64 aarch64 ppc64le s390x
@ -2485,6 +2486,9 @@ exit 0
%config %{_sysconfdir}/prometheus/ceph/ceph_default_alerts.yml
%changelog
* Mon Jul 18 2022 yangxiaoliang <yangxiaoliang07@163.com> - 2:16.2.7-4
- fix ceph-volume lvm api function undefined error
* Fri Mar 11 2022 wangzengliang <wangzengliang1@huawei.com> - 2:16.2.7-3
- cmake: add support python 3.10