summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2009-12-10 15:18:26 +1100
committerMartin Schwenke <martin@meltin.net>2009-12-10 15:18:26 +1100
commitfbce6cb4e28bb1de61bf45fd139246d1fa0c4ff8 (patch)
treeb768d21c6ae06ee83a261ab3cfcc1617d0996872
parent743bdb8a06d226031b04326aeccea99ba3bd9e2d (diff)
Reinstate "autocluster create node" functionality.
This was removed several months ago when the node types were generalised and it didn't seem to make sense at the time. The new version takes an IP offset as its second argument and creates the corresponding node. It doesn't run the create cluster hooks, since they may do cluster-wide things. Note that creating a single node can result in an inconsistent cluster. For example, the when creating a node that is part of a CTDB or GPFS cluster the behaviour is not well specified. However, this function may be very useful for (re)creating rhel_base and tsm_server nodes. Signed-off-by: Martin Schwenke <martin@meltin.net>
-rwxr-xr-xautocluster68
1 files changed, 53 insertions, 15 deletions
diff --git a/autocluster b/autocluster
index 18599a4..73cb44b 100755
--- a/autocluster
+++ b/autocluster
@@ -271,21 +271,15 @@ register_create_cluster_hook ()
create_cluster_hooks="${create_cluster_hooks}${create_cluster_hooks:+ }${hook}"
}
-create_cluster() {
- CLUSTER="$1"
-
- [ -n "${CLUSTER//[A-Za-z0-9]}" ] && \
+sanity_check_cluster_name ()
+{
+ [ -z "${CLUSTER//[A-Za-z0-9]}" ] || \
die "Cluster names should be restricted to the characters A-Za-z0-9. \
Some cluster filesystems have problems with other characters."
+}
- mkdir -p $VIRTBASE/$CLUSTER $KVMLOG tmp
-
- # Run hooks before doing anything else.
- local n
- for n in $create_cluster_hooks ; do
- $n
- done
-
+common_nodelist_hacking ()
+{
# Rework the NODES list
expand_nodes
@@ -343,8 +337,24 @@ Some cluster filesystems have problems with other characters."
local num_nodes=0
hack_all_nodes_with ctdb_nodes_line >$nodes_file
: "${NUMNODES:=${num_nodes}}" # Set $NUMNODES if necessary
+}
+
+create_cluster ()
+{
+ CLUSTER="$1"
+
+ sanity_check_cluster_name
+
+ mkdir -p $VIRTBASE/$CLUSTER $KVMLOG tmp
+
+ # Run hooks before doing anything else.
+ local n
+ for n in $create_cluster_hooks ; do
+ $n
+ done
+
+ common_nodelist_hacking
- # Create the actual nodes
for_each_node call_func create_node
echo "Cluster $CLUSTER created"
@@ -352,6 +362,30 @@ Some cluster filesystems have problems with other characters."
cat $hosts_file
}
+create_one_node ()
+{
+ CLUSTER="$1"
+ local single_node_ip_offset="$2"
+
+ sanity_check_cluster_name
+
+ mkdir -p $VIRTBASE/$CLUSTER $KVMLOG tmp
+
+ common_nodelist_hacking
+
+ for n in $NODES ; do
+ set -- $(IFS=: ; echo $n)
+ [ $single_node_ip_offset -eq $2 ] || continue
+ call_func create_node "$@"
+
+ echo "Requested node created"
+ echo "You may want to update your /etc/hosts file:"
+ cat $hosts_file
+
+ break
+ done
+}
+
###############################
# test the proxy setup
test_proxy() {
@@ -1083,11 +1117,15 @@ case $command in
case $type in
base)
[ $# != 0 ] && usage
- create_base;
+ create_base
;;
cluster)
[ $# != 1 ] && usage
- create_cluster "$1";
+ create_cluster "$1"
+ ;;
+ node)
+ [ $# != 2 ] && usage
+ create_one_node "$1" "$2"
;;
*)
usage;