invoke remote site as root, use /etc/ganeti.hosts
[gnt-info] / emulator / gnt-cluster
1 #!/bin/sh -e
2
3 op=$1 ; shift
4
5 test -z "$1" && echo "Usage: $0 command id" && exit 1
6
7 if [ "$op" = "command" ] ; then
8
9         show_machine=0
10         if [ $1 = '-M' ] ; then # FIXME --machine
11                 shift
12                 show_machine=1
13         fi
14
15         for host in $(cat /etc/ganeti.hosts) ; do
16
17                 prefix=''
18                 test $show_machine && prefix="$host: "
19                 #echo "# ssh $host $*"
20                 ssh root@$host $* | sed "s/^/$prefix/"
21
22         done
23
24 elif [ "$op" = "copyfile" ] ; then
25
26         my_hostname=$(hostname -s)
27         for host in $(cat /etc/ganeti.hosts | grep -v $my_hostname) ; do
28                 rsync $1 root@$host:$1
29         done
30
31 elif [ "$op" = "install" ] ; then # use as "install it" since needs install command and arg
32
33         ln -sfv `pwd`/gnt-cluster /usr/local/bin/
34
35 else
36         echo "UNKNOWN [$op] $*"
37         exit 1
38 fi