Last active
May 9, 2017 07:17
-
-
Save nailgun/b3d05265762c2746dccda5b37cbc7622 to your computer and use it in GitHub Desktop.
Utility to interactively edit Ceph CRUSH map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
original_bin=$(mktemp) | |
original_src=${original_bin}.src | |
new_bin=$(mktemp) | |
new_src=${new_bin}.src | |
cleanup () { | |
rm -f "$original_bin" "$original_src" "$new_bin" "$new_src" | |
} | |
trap cleanup EXIT | |
ceph osd getcrushmap -o "$original_bin" | |
crushtool -d "$original_bin" -o "$original_src" | |
cp "$original_src" "$new_src" | |
while true; do | |
${EDITOR:-${VISUAL:-/usr/bin/vi}} "$new_src" | |
if crushtool -c "$new_src" -o "$new_bin"; then | |
break | |
else | |
read | |
fi | |
done | |
if cmp -s "$new_bin" "$original_bin"; then | |
echo "No changes in CRUSH map detected, skipping install" | |
else | |
ceph osd setcrushmap -i "$new_bin" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment