Skip to content

Commit

Permalink
Merge pull request kubernetes#5436 from lhuard1A/ssh-to-node_libvirt-…
Browse files Browse the repository at this point in the history
…coreos

Implement ssh-to-node, restart-kube-proxy and restart-apiserver functions in libvirt-coreos.
  • Loading branch information
vishh committed Mar 13, 2015
2 parents 5d65847 + 8cd105a commit 967f8df
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions cluster/libvirt-coreos/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,40 @@ function get-password {
echo "TODO get-password"
}

# SSH to a node by name or IP ($1) and run a command ($2).
function ssh-to-node {
local node="$1"
local cmd="$2"
local machine

if [[ "$node" == "$MASTER_IP" ]] || [[ "$node" =~ ^"$MINION_IP_BASE" ]]; then
machine="$node"
elif [[ "$node" == "$MASTER_NAME" ]]; then
machine="$MASTER_IP"
else
for ((i=0; i < NUM_MINIONS; i++)); do
if [[ "$node" == "${MINION_NAMES[$i]}" ]]; then
machine="${MINION_IPS[$i]}"
break
fi
done
fi
if [[ -z "$machine" ]]; then
echo "$node is an unknown machine to ssh to" >&2
fi
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ControlMaster=no "core@$machine" "$cmd"
}

# Restart the kube-proxy on a node ($1)
function restart-kube-proxy {
ssh-to-node "$1" "sudo systemctl restart kube-proxy"
}

# Restart the apiserver
function restart-apiserver {
ssh-to-node "$1" "sudo systemctl restart kube-apiserver"
}

# Perform preparations required to run e2e tests
function prepare-e2e() {
echo "libvirt-coreos doesn't need special preparations for e2e tests" 1>&2
Expand Down

0 comments on commit 967f8df

Please sign in to comment.