| #------------------------------------------------------------------------------- |
| # Utility to repair cell slave by destroying all cell-related containers and |
| # by cancelling all cell reservations hosted by that slave. Intended for use |
| # after the cell slave has been rebooted as a result of some H/W or OS issues. |
| #------------------------------------------------------------------------------- |
| [ -z "$slave" -o "$slave" = "-h" -o "$slave" = "-?" ] \ |
| && echo "usage: $(basename $0) slaveIp" && exit 1 |
| # Destroy all cell-related containers on the specified slave; do not touch |
| # the base-* template images though. |
| containers=\$(sudo lxc-ls --fancy | grep -E '[a-z]*-[0-9cn]' | cut -d\ -f1) |
| for c in \$containers; do |
| # Cancel all reservations hosted on the specified slave |
| # Also, kill any warden spawned processes |
| cells=\$(grep -l $slave warden/cells/supported/* | xargs -n1 basename) |
| [ -f warden/cells/reserved/\$c ] && rm warden/cells/reserved/\$c |
| pids=\$(ps -ef | grep warden | grep -Ev 'grep|java' | cut -c10-15) |
| [ -n \"\$pids\" ] && kill -9 \$pids |