error_out() {
echo "An error was encountered while running '$1'. Aborting."
+ if [ $# -gt 2 ] ;then
+ echo "Error: $3"
+ fi
if [ $# -gt 1 ] ;then
echo "Review file '$2' for details."
fi
echo "Note: output files produced will be tagged with the current timestamp -- ${timestamp}."
echo "running 'rados ls' at $(date)"
-rados ls --pool="$pool" >"$rados_out" 2>"$rados_err"
+rados ls --pool="$pool" --format=json-pretty --all >"$rados_out" 2>"$rados_err"
if [ "$?" -ne 0 ] ;then
error_out "rados ls" "$rados_err"
fi
+
+# check for namespaces and error out if any found
+grep '^[[:blank:]]*"namespace":' "$rados_out" | grep --silent '[^:]*: "[^"]'
+if [ "${PIPESTATUS[1]}" -eq 0 ] ;then
+ error_out "rados ls" "$rados_out" "Found one or more RADOS objects existing in a namespace."
+fi
+
+# move from json to list of oids
+grep '^[[:blank:]]*"name":' "$rados_out" | sed 's/[^:]*: "\(.*\)"$/\1/' >"$temp_file"
+mv -f "$temp_file" "$rados_out"
+
sort -u "$rados_out" >"$temp_file"
mv -f "$temp_file" "$rados_out"