summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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;