From a1f811540f16e7a27023ecd0a21f0cc1a467b6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Tue, 26 Nov 2019 09:53:30 +0100 Subject: [PATCH] New script to get the next OSD ID --- ceph/new.osd-id.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 ceph/new.osd-id.sh diff --git a/ceph/new.osd-id.sh b/ceph/new.osd-id.sh new file mode 100755 index 0000000..b8e6d93 --- /dev/null +++ b/ceph/new.osd-id.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# Vars {{{ +debug="0" + +osd_id_start="0" +osd_id_end=$(sudo ceph osd getmaxosd | cut -d" " -f3) +# }}} + +# Functions +# Check if an OSD exists {{{ +check_osd() { + _osd_id="${1}" + + [ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : check_osd func − OSD ID to check : ${_osd_id}." + + sudo ceph osd find "${_osd_id}" > /dev/null 2>&1 + return $? +} +# }}} + +osd_id="${osd_id_start}" + +while [ "${osd_id}" -lt "${osd_id_end}" ]; do + + [ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Check if OSD ${osd_id} exists." + + check_osd "${osd_id}" + if [ "${?}" = 0 ]; then + printf '%b\n' "True" + else + printf '%b\n' "False" + fi + + ## Increment OSD ID + osd_id=$((osd_id+1)) +done + +exit 0