diff options
| author | Martin Schwenke <martin@meltin.net> | 2009-07-24 14:37:34 +1000 |
|---|---|---|
| committer | Martin Schwenke <martin@meltin.net> | 2009-07-24 14:37:34 +1000 |
| commit | a357fe2df0e86d751bbb5743be338fc80baf3635 (patch) | |
| tree | 4dc5b2b67e6d7d17cfd9464dca0b637ec448c8af | |
| parent | 7b8d81265cfc31206f130a96b7a8ed4ecd87b31f (diff) | |
Fix SoFS public address generation.
New configuration variable PUBLIC_IP_OFFSET indicates where first
public IP address is relative to FIRSTIP. Default is 100, so we
suggest a convention where static IPs (as indicated by FIRSTIP) are
below 100 and public IPs are between 100 and 200.
make_public_addresses() should once again do the right thing by
default, so the default value of PUBLIC_ADDRESSES now works again.
Public addresses are now generated according to the NODES list. A
function has_public_addresses_<node_type> is defined for each node
type that might have public addresses, and returns true if that node
type should have public addresses. A default function handles all of
the other node types.
The 2nd argument to make_public_addresses() is now a list of IP
offsets rather than node numbers, since node numbers no longer exist
in any useful way.
To help with this create_cluster() now sets NUMNODES if it isn't set.
Signed-off-by: Martin Schwenke <martin@meltin.net>
| -rwxr-xr-x | autocluster | 52 | ||||
| -rw-r--r-- | config.d/00base.defconf | 4 | ||||
| -rw-r--r-- | config.d/50sofs.defconf | 16 |
3 files changed, 58 insertions, 14 deletions
diff --git a/autocluster b/autocluster index 4bf689c..06e2ee6 100755 --- a/autocluster +++ b/autocluster @@ -321,9 +321,12 @@ Some cluster filesystems have problems with other characters." { [ "$ctdb_node" = 1 ] || return 0 echo "$IPBASE.0.$(($FIRSTIP + $ip_offset))" + num_nodes=$(($num_nodes + 1)) } nodes_file="tmp/nodes.$CLUSTER" + local num_nodes=0 hack_all_nodes_with ctdb_nodes_line >$nodes_file + : "${NUMNODES:=${num_nodes}}" # Set $NUMNODES if necessary mkdir -p $VIRTBASE/$CLUSTER $KVMLOG @@ -915,27 +918,50 @@ with_release () { } +has_public_addresses_DEFAULT () +{ + false +} + +# Build public address configuration. +# * 1st public IP: unless specified, last octet is $FIRSTIP + $PUBLIC_IP_OFFSET +# * Excluded nodes: unless specified via comma-separated list of IP offsets, +# nodes are excluded via their node types +# * Number of public addresses per interface is either specified or $NUMNODES. make_public_addresses () { - local firstip="${1:-$(($FIRSTIP + 1))}" # Default is $FIRSTIP + 1 - local excluded_nodes="${2:-1}" # Comma separated, default = 1 - local num_addrs="${3:-${NUMNODES}}" # Default is $NUMNODES + local firstip="${1:-$(($FIRSTIP + $PUBLIC_IP_OFFSET))}" + local excluded_nodes="$2" + local num_addrs="${3:-${NUMNODES}}" + + # For delimiting matches. + excluded_nodes="${excluded_nodes:+,}${excluded_nodes}${excluded_nodes:+,}" + # Avoid spaces + excluded_nodes="${excluded_nodes// /}" + + make_public_addresses_for_node () + { + [ "$ctdb_node" = 1 ] || return 0 - excluded_nodes=",${excluded_nodes}," # For delimiting matches. + echo "[/etc/ctdb/public_addresses:${name}.${DOMAIN}]" - local n e i - for n in $(seq 1 $num_addrs) ; do - echo "[/etc/ctdb/public_addresses:@@CLUSTER@@n${n}.@@DOMAIN@@]" + if [ -n "$excluded_nodes" -a \ + "${excluded_nodes/,${ip_offset},}" = "$excluded_nodes" ] || + ([ -z "$excluded_nodes" ] && + call_func has_public_addresses "$node_type") ; then - if [ "${excluded_nodes/,${n},}" = "$excluded_nodes" ] ; then + local e i for e in "1" "2" ; do for i in $(seq $firstip $(($firstip + $num_addrs - 1))) ; do - printf "\t@@IPBASE@@.${e}.${i}/24 eth${e}\n" + if [ $i -gt 254 ] ; then + die "make_public_addresses: octet > 256 - consider setting PUBLIC_IP_OFFSET" + fi + printf "\t${IPBASE}.${e}.${i}/24 eth${e}\n" done - done + done fi - - echo - done + echo + } + hack_all_nodes_with make_public_addresses_for_node } ###################################################################### diff --git a/config.d/00base.defconf b/config.d/00base.defconf index cb61934..0e06dbd 100644 --- a/config.d/00base.defconf +++ b/config.d/00base.defconf @@ -249,3 +249,7 @@ create_node_rhel_base () create_node_COMMON "$name" "$ip_offset" } +has_public_addresses_rhel_base () +{ + true +} diff --git a/config.d/50sofs.defconf b/config.d/50sofs.defconf index 334215c..c17740f 100644 --- a/config.d/50sofs.defconf +++ b/config.d/50sofs.defconf @@ -32,8 +32,11 @@ defconf JAVA_MIN_SIZE "200M" \ defconf JAVA_MAX_SIZE "400M" \ "<n>M" "maximum size of Java heap for SoFS GUI" +defconf PUBLIC_IP_OFFSET 100 \ + "<n>" "offset from FIRSTIP of public IP addresses" + defconf PUBLIC_ADDRESSES "|make_public_addresses" \ - "<file>" "template for public address entries in conf.base-SoFS" + "<cmd>" "template for public address entries in conf.base-SoFS" ############################## @@ -148,3 +151,14 @@ create_node_sofs_storage () create_node_COMMON "$name" "$ip_offset" } + +has_public_addresses_rhel_base () +{ + # rhel_base nodes have public addresses if there are no sofs_* nodes. + [ "${NODES/sofs_*:/}" = "$NODES" ] +} + +has_public_addresses_sofs_front () +{ + true +} |
