[ceph-osd] Helper function clean-up

Fix a bug in get_lvm_tag_from_volume when no logical volume is
provided and remove unnecessary echo commands from helper
functions.

Change-Id: I8e89d1f8e5a3c7c8148a7cd46ef3fcdf4f6f82bd
This commit is contained in:
Steve Taylor 2020-05-08 09:39:00 -06:00 committed by chinasubbareddy mallavarapu
parent 8f05761ee5
commit b1658e7033

View File

@ -256,15 +256,16 @@ function get_lvm_tag_from_volume {
logical_volume="$1"
tag="$2"
if [[ -z "${logical_volume}" ]]; then
if [[ "$#" -lt 2 ]] || [[ -z "${logical_volume}" ]]; then
# Return an empty string if the logical volume doesn't exist
echo
else
# Get and return the specified tag from the logical volume
echo "$(lvs -o lv_tags ${logical_volume} | tr ',' '\n' | grep ${tag} | cut -d'=' -f2)"
lvs -o lv_tags ${logical_volume} | tr ',' '\n' | grep ${tag} | cut -d'=' -f2
fi
}
# Helper function to get an lvm tag from a physical device
function get_lvm_tag_from_device {
device="$1"
tag="$2"
@ -272,15 +273,15 @@ function get_lvm_tag_from_device {
logical_volume="$(pvdisplay -m ${device} | awk '/Logical volume/{print $3}')"
# Use get_lvm_tag_from_volume to get the specified tag from the logical volume
echo "$(get_lvm_tag_from_volume ${logical_volume} ${tag})"
get_lvm_tag_from_volume ${logical_volume} ${tag}
}
# Helper function get a cluster FSID from a physical device
# Helper function to get a cluster FSID from a physical device
function get_cluster_fsid_from_device {
device="$1"
# Use get_lvm_tag_from_device to get the cluster FSID from the device
echo "$(get_lvm_tag_from_device ${device} ceph.cluster_fsid)"
get_lvm_tag_from_device ${device} ceph.cluster_fsid
}
# Helper function to get an OSD ID from a logical volume
@ -288,7 +289,7 @@ function get_osd_id_from_volume {
logical_volume="$1"
# Use get_lvm_tag_from_volume to get the OSD ID from the logical volume
echo "$(get_lvm_tag_from_volume ${logical_volume} ceph.osd_id)"
get_lvm_tag_from_volume ${logical_volume} ceph.osd_id
}
# Helper function get an OSD ID from a physical device
@ -296,7 +297,7 @@ function get_osd_id_from_device {
device="$1"
# Use get_lvm_tag_from_device to get the OSD ID from the device
echo "$(get_lvm_tag_from_device ${device} ceph.osd_id)"
get_lvm_tag_from_device ${device} ceph.osd_id
}
# Helper function get an OSD FSID from a physical device
@ -304,7 +305,7 @@ function get_osd_fsid_from_device {
device="$1"
# Use get_lvm_tag_from_device to get the OSD FSID from the device
echo "$(get_lvm_tag_from_device ${device} ceph.osd_fsid)"
get_lvm_tag_from_device ${device} ceph.osd_fsid
}
# Helper function get an OSD DB device from a physical device
@ -312,7 +313,7 @@ function get_osd_db_device_from_device {
device="$1"
# Use get_lvm_tag_from_device to get the OSD DB device from the device
echo "$(get_lvm_tag_from_device ${device} ceph.db_device)"
get_lvm_tag_from_device ${device} ceph.db_device
}
# Helper function get an OSD WAL device from a physical device
@ -320,5 +321,5 @@ function get_osd_wal_device_from_device {
device="$1"
# Use get_lvm_tag_from_device to get the OSD WAL device from the device
echo "$(get_lvm_tag_from_device ${device} ceph.wal_device)"
get_lvm_tag_from_device ${device} ceph.wal_device
}