Revision d9eefcfa

b/INSTALL
44 44
- `ElementTree Python module <http://effbot.org/zone/element-index.htm>`_,
45 45
  if running python 2.4 (optional, used by ovfconverter tool)
46 46
- `qemu-img <http://qemu.org/>`_, if you want to use ovfconverter
47
- `fping <http://fping.sourceforge.net/>`_
47 48

  
48 49
These programs are supplied as part of most Linux distributions, so
49 50
usually they can be installed via the standard package manager. Also
b/Makefile.am
537 537
dist_tools_SCRIPTS = \
538 538
	$(dist_tools_PYTHON) \
539 539
	tools/kvm-console-wrapper \
540
	tools/xm-console-wrapper
540
	tools/xm-console-wrapper \
541
	tools/master-ip-setup
541 542

  
542 543
pkglib_python_scripts = \
543 544
	daemons/import-export \
b/tools/master-ip-setup
1
#!/bin/bash
2
#
3

  
4
# Copyright (C) 2011 Google Inc.
5
#
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
# General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
# 02110-1301, USA.
20

  
21
set -e -u
22

  
23
USAGE_MSG="Usage: $0 {start|stop}"
24
PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
25

  
26
# Start the master IP
27
start() {
28
  case $CLUSTER_IP_VERSION in
29
    4)
30
      ARP_COMMAND="arping -q -U -c 3 -I $MASTER_NETDEV -s $MASTER_IP $MASTER_IP"
31
      ;;
32
    6)
33
      ARP_COMMAND="ndisc6 -q r 3 $MASTER_IP $MASTER_NETDEV"
34
      ;;
35
    *)
36
      echo "Invalid cluster IP version specified: $CLUSTER_IP_VERSION" >&2
37
      exit 1
38
      ;;
39
  esac
40

  
41
  # Check if the master IP address is already configured on this machine
42
  if fping -S 127.0.0.1 $MASTER_IP >/dev/null 2>&1; then
43
    echo "Master IP address already configured on this machine. Doing nothing."
44
    exit 0
45
  fi
46

  
47
  # Check if the master IP address is already configured on another machine
48
  if fping $MASTER_IP >/dev/null 2>&1; then
49
    echo "Error: master IP address configured on another machine." >&2
50
    exit 1
51
  fi
52

  
53
  if ! ip addr add $MASTER_IP/$MASTER_NETMASK \
54
     dev $MASTER_NETDEV label $MASTER_NETDEV:0; then
55
    echo "Error during the activation of the master IP address" >&2
56
    exit 1
57
  fi
58

  
59
  # Send gratuituous ARP to update neighbours' ARP cache
60
  $ARP_COMMAND || :
61
}
62

  
63
# Stop the master IP
64
stop() {
65
  if ! ip addr del $MASTER_IP/$MASTER_NETMASK dev $MASTER_NETDEV; then
66
    echo "Error during the deactivation of the master IP address" >&2
67
    exit 1
68
  fi
69
}
70

  
71
if (( $# < 1 )); then
72
  echo $USAGE_MSG >&2
73
  exit 1
74
fi
75

  
76
case "$1" in
77
  start)
78
    start
79
    ;;
80
  stop)
81
    stop
82
    ;;
83
  *)
84
    echo $USAGE_MSG >&2
85
    exit 1
86
    ;;
87
esac
88

  
89
exit 0

Also available in: Unified diff