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