Rename cluster "configure" action to "setup"
authorMartin Schwenke <martin@meltin.net>
Mon, 30 Jun 2014 06:37:25 +0000 (16:37 +1000)
committerMartin Schwenke <martin@meltin.net>
Wed, 2 Jul 2014 10:26:52 +0000 (20:26 +1000)
Rewrite cluster_setup() to factor out the common SSH bits.

Signed-off-by: Martin Schwenke <martin@meltin.net>
autocluster

index 3c8219f..e885037 100755 (executable)
@@ -54,7 +54,7 @@ EOF
   commands:
      base [ create | boot ] ...
 
-     cluster [ build | destroy | create | update_hosts | boot | configure ] ...
+     cluster [ build | destroy | create | update_hosts | boot | setup ] ...
 
      create base
            create a base image
@@ -596,38 +596,46 @@ cluster_boot ()
     echo ""
 }
 
-cluster_configure ()
+cluster_setup ()
 {
-    announce "cluster configure \"${CLUSTER}\""
+    announce "cluster setup \"${CLUSTER}\""
     [ -n "$CLUSTER" ] || die "\$CLUSTER not set"
 
-    local n1="${CLUSTER}n1"
-    local ssh="ssh -o StrictHostKeyChecking=no"
+    local install_tasks=""
+    local setup_tasks=""
 
     case "$CLUSTER_TYPE" in
        "build")
-           $ssh "$n1" ./scripts/install_packages.sh clusterfs build
-           $ssh "$n1" ./scripts/setup_cluster.sh build
+           install_tasks="clusterfs build"
+           setup_tasks="build"
            ;;
-
        "ad")
-           $ssh "$n1" ./scripts/install_packages.sh ad_server
-           $ssh "$n1" ./scripts/configure_cluster.sh ad_server
+           install_tasks="ad_server"
+           setup_tasks="ad_server"
            ;;
-
        "samba")
-           [ -n "$CLUSTER_PATTERN" ] || CLUSTER_PATTERN="$CLUSTER"
+           install_tasks="clusterfs nas"
+           setup_tasks="clusterfs nas"
+           ;;
+    esac
 
-           local nodes=$(vircmd dominfo "$CLUSTER_PATTERN" 2>/dev/null | \
-               sed -n -e 's/Name: *//p')
+    local ssh="ssh -o StrictHostKeyChecking=no"
 
-           for i in $nodes ; do
-               $ssh "$i" ./scripts/install_packages.sh clusterfs nas
-           done
+    if [ -n "$install_tasks" ] ; then
+       [ -n "$CLUSTER_PATTERN" ] || CLUSTER_PATTERN="$CLUSTER"
 
-           $ssh "$n1" ./scripts/setup_cluster.sh clusterfs nas
-           ;;
-    esac
+       local nodes=$(vircmd dominfo "$CLUSTER_PATTERN" 2>/dev/null | \
+           sed -n -e 's/Name: *//p')
+
+       for i in $nodes ; do
+           $ssh "$i" ./scripts/install_packages.sh $install_tasks
+       done
+    fi
+
+    if [ -n "$setup_tasks" ] ; then
+       local n1="${CLUSTER}n1"
+       $ssh "$n1" ./scripts/setup_cluster.sh $setup_tasks
+    fi
 }
 
 create_one_node ()
@@ -1416,10 +1424,10 @@ case "$t" in
        actions_init
        for t in "$@" ; do
            case "$t" in
-               destroy|create|update_hosts|boot|configure)
+               destroy|create|update_hosts|boot|setup)
                    actions_add "cluster_${t}" ;;
                build)
-                   for t in destroy create update_hosts boot configure ; do
+                   for t in destroy create update_hosts boot setup ; do
                        actions_add "cluster_${t}"
                    done
                    ;;