From 778231eff55ce6ac546e3c87af493120771bae0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Tue, 26 Nov 2019 10:32:46 +0100 Subject: [PATCH] Add a function to get osd's host --- ceph/new.osd-id.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ceph/new.osd-id.sh b/ceph/new.osd-id.sh index 4b267e6..82aa361 100755 --- a/ceph/new.osd-id.sh +++ b/ceph/new.osd-id.sh @@ -18,6 +18,16 @@ check_osd() { return $? } # }}} +# Check if an OSD exists {{{ +get_osd_host() { + _osd_id="${1}" + osd_id_host="" + + [ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : get_osd_host func − OSD ID to check : ${_osd_id}." + + osd_id_host=$(sudo ceph osd find "${_osd_id}" | awk -F\" '$2 ~ /host/ {print $4}') +} +# }}} osd_id="${osd_id_start}" @@ -27,11 +37,14 @@ while [ "${osd_id}" -lt "${osd_id_end}" ]; do if check_osd "${osd_id}" then - printf '%b\n' "True" + get_osd_host "${osd_id}" + [ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : OSD ${osd_id} exists on ${osd_id_host}." else - printf '%b\n' "False" + [ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ! OSD ${osd_id} does exists !" fi + [ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "-----------------------------------------------" + ## Increment OSD ID osd_id=$((osd_id+1)) done