+crossmigratemany() {
+ me=$(hostname -f)
+ if ! grep -q --line-regexp --fixed-strings "$me" "$nodelist"; then
+ echo >&2 "my hostname ($me) not found in nodelist"
+ exit 1
+ fi
+
+ # move ourselves last
+ newlist="$(tempfile)"
+ cleanup+=("rm -f '$newlist'")
+ grep -v --line-regexp --fixed-strings "$me" "$nodelist" > "$newlist"
+ echo "$me" >> "$newlist"
+
+ while read node ; do
+ if ! hbal -L -C -v -v --no-disk-moves --offline="$node" -X; then
+ echo >&2 "hbal failed at node $node. Bailing out."
+ exit 1
+ fi
+ if ! gnt-node migrate -f "$node"; then
+ echo >&2 "gnt-node migrate failed for node $node. Bailing out."
+ exit 1
+ fi
+ if [ "$node" = "$me" ] ; then
+ break
+ fi
+ reboot_host "$node"
+ # bring back disks
+ echo "Bringing back disks using the watcher"
+ ganeti-watcher
+ # wait for a cron-launched ganeti-watcher to finish
+ while pgrep ganeti-watcher > /dev/null ; do
+ echo -n "."
+ sleep 5
+ done
+ echo
+ done < "$newlist"
+
+ at 'now + 5 min' << 'EOF'
+screen -S hbal -d -m sh -c '
+ echo "Activating disks using the watcher.."
+ ganeti-watcher
+ while pgrep ganeti-watcher > /dev/null ; do
+ sleep 5
+ done
+ hbal -L -C -v -v --no-disk-moves -X
+ echo "done."
+ sleep 1h
+'
+EOF
+ reboot_host "$me"
+}
+