summaryrefslogtreecommitdiffstats
path: root/config.d
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2013-03-05 11:36:16 +1100
committerMartin Schwenke <martin@meltin.net>2013-03-05 15:07:36 +1100
commit0a6d897bdaf009f6e441dd8cb282624c3e05a975 (patch)
treeafa9e2a6cf8b1b397d1000c8372cdf5fd24eadcb /config.d
parenta5f51d7274c8ce32905b05a4ff99f810f768e1c0 (diff)
downloadautocluster-0a6d897bdaf009f6e441dd8cb282624c3e05a975.tar.gz
autocluster-0a6d897bdaf009f6e441dd8cb282624c3e05a975.tar.xz
autocluster-0a6d897bdaf009f6e441dd8cb282624c3e05a975.zip
New configuration variable NETWORKS - IPBASE, IPNET* no longer used
Much more flexible network configuration. Replace canned host_setup/etc/libvirt/qemu/networks/*.xml with setup_networks.sh script. Signed-off-by: Martin Schwenke <martin@meltin.net>
Diffstat (limited to 'config.d')
-rw-r--r--config.d/00base.defconf93
-rw-r--r--config.d/10shareddisk.defconf2
2 files changed, 83 insertions, 12 deletions
diff --git a/config.d/00base.defconf b/config.d/00base.defconf
index 3b72fe0..c7fe312 100644
--- a/config.d/00base.defconf
+++ b/config.d/00base.defconf
@@ -224,25 +224,96 @@ defconf NAMESERVER "10.0.0.1" \
defconf DNSSEARCH "$DOMAIN" \
"<dom>" "extra domains for DNS search list"
-# set the first two octets of the IPs we will use
-# the 3rd and 4th octets are controlled by the node setup scripts
-defconf IPBASE "10.0" \
- "<n>.<n>" "first 2 octets of IP for each node"
+# Networks:
+# * First network is private and contains the CTDB node addresses.
+# * Items look like: net/bits,dev[, nat|bridge=host_iface]
-defconf IPNET0 "0" \
- "<n>" "3rd octet of IP for each node for network 0"
+# * Right now autocluster only supported 24 bit networks. This will
+# be improved in the future.
+defconf NETWORKS "10.0.0.0/24,eth0 10.0.1.0/24,eth1 10.0.2.0/24,eth2" \
+ "<list>" "description of IP networks"
-defconf IPNET1 "1" \
- "<n>" "3rd octet of IP for each node for network 1"
+has_public_addresses_DEFAULT ()
+{
+ false
+}
+
+make_public_addresses()
+{
+ local firstip="${1:-$[${FIRSTIP} + ${PUBLIC_IP_OFFSET}]}"
+ local num_addrs="${2:-${NUMNODES}}"
+
+ if [ $(( $firstip + $num_addrs - 1 )) -gt 254 ]; then
+ die "make_public_addresses: last octet > 254 - change PUBLIC_IP_OFFSET"
+ fi
+
+ local n
+ for n in $NETWORKS_PUBLIC ; do
+ local dev="${n#*,}" # Strip address, comma
+ dev="${dev%,*}" # Strip comma, interface
+ echo -ne "${n%.*}.${firstip},${num_addrs},${dev} "
+ done
+ echo
+}
+
+networks_post_config_hook ()
+{
+ local n
+ for n in $NETWORKS ; do
+ local ip_mask="${n%%,*}"
+ local mask="${ip_mask#*/}"
+
+ [ "$mask" = "24" ] || \
+ die "Network maskbits other than 24 unsupported in \"$n\""
+ done
-defconf IPNET2 "2" \
- "<n>" "3rd octet of IP for each node for network 2"
+ [ -z "$IPBASE" -a -z "$IPNET0" -a -z "$IPNET1" -a -z "$IPNET2" ] || \
+ die "Configuration variables IPBASE, IPNET0/1/2 unsupported - please use NETWORKS"
+
+ # Convenience variables
+ set -- $NETWORKS
+ NETWORK_PRIVATE="$1"
+ NETWORK_PRIVATE_PREFIX="${NETWORK_PRIVATE%.*}"
+ NETWORKS_PUBLIC="$2"
+}
+
+register_hook post_config_hooks networks_post_config_hook
+
+defconf NETWORK_TEMPLATE "|network_template" \
+ "<file>" "libvirt template fragment for networks"
+
+network_template ()
+{
+ if [ -n "$CLUSTER" ] ; then
+ local md5=$(echo "$CLUSTER" | md5sum)
+ local nh=$(printf "%02x" $ip_offset)
+ local mac_prefix="02:${md5:0:2}:${md5:2:2}:00:${nh}:"
+ else
+ local mac_prefix="02:42:42:00:00:"
+ fi
+
+ local n
+ local count=1
+ for n in $NETWORKS ; do
+ local ch=$(printf "%02x" $count)
+ net="${n%/*}"
+ name="acnet_${net//./_}"
+ cat <<EOF
+ <interface type='network'>
+ <mac address='${mac_prefix}${ch}'/>
+ <model type='@@NICMODEL@@'/>
+ <source network='${name}'/>
+ </interface>
+EOF
+ count=$(($count + 1))
+ done
+}
# the nodes will get IPs starting at this number
# the TSM server will get $FIRSTIP, then the first node will get
# the next IP etc
-# so if IPBASE is 10.0, IPNET0 is 0 and FIRSTIP is 20 then
+# so if the private network is 10.0.0.0/24,eth0 and FIRSTIP is 20 then
# you will get nodes like this:
# tsmserver 10.0.0.20
# 1st node 10.0.0.21
diff --git a/config.d/10shareddisk.defconf b/config.d/10shareddisk.defconf
index 7a62004..7d80465 100644
--- a/config.d/10shareddisk.defconf
+++ b/config.d/10shareddisk.defconf
@@ -210,7 +210,7 @@ shared_disk_iscsi_setup_base()
# Override this if you use a different scheme for IP addresses.
shared_disk_iscsi_setup_base_get_ip ()
{
- echo "${IPBASE}.${IPNET0}.${IPNUM}"
+ echo "${NETWORK_PRIVATE_PREFIX}.${IPNUM}"
}
shared_disk_iscsi_setup_base_internal ()