Move shared disk presence logic from nodes into shared disk code
[autocluster.git] / autocluster
index a4f6d709df1386b70daa101e59e8fcf8f3f595a9..3c8219f150cc338d394da426d31690e207a94449 100755 (executable)
@@ -54,7 +54,7 @@ EOF
   commands:
      base [ create | boot ] ...
 
-     cluster [ destroy | create | update_hosts | boot | configure ] ...
+     cluster [ build | destroy | create | update_hosts | boot | configure ] ...
 
      create base
            create a base image
@@ -96,6 +96,31 @@ announce ()
     echo ""
 }
 
+waitfor ()
+{
+    local file="$1"
+    local msg="$2"
+    local timeout="$3"
+
+    local tmpfile=$(mktemp)
+
+    cat <<EOF >"$tmpfile"
+spawn tail -n 10000 -f $file
+expect -timeout $timeout -re "$msg"
+EOF
+
+    export LANG=C
+    expect "$tmpfile"
+    rm -f "$tmpfile"
+
+    if ! grep -E "$msg" "$file" > /dev/null; then
+       echo "Failed to find \"$msg\" in \"$file\""
+       return 1
+    fi
+
+    return 0
+}
+
 ###############################
 
 # Indirectly call a function named by ${1}_${2}
@@ -581,14 +606,13 @@ cluster_configure ()
 
     case "$CLUSTER_TYPE" in
        "build")
-           # Build node doesn't really need CTDB/Samba to be
-           # installed, if the packages are not present in the repo,
-           # they're skipped.
-           $ssh "$n1" "./scripts/setup_build.sh || true"
+           $ssh "$n1" ./scripts/install_packages.sh clusterfs build
+           $ssh "$n1" ./scripts/setup_cluster.sh build
            ;;
 
        "ad")
-           $ssh "$n1" ./scripts/setup_ad_server.sh
+           $ssh "$n1" ./scripts/install_packages.sh ad_server
+           $ssh "$n1" ./scripts/configure_cluster.sh ad_server
            ;;
 
        "samba")
@@ -598,16 +622,10 @@ cluster_configure ()
                sed -n -e 's/Name: *//p')
 
            for i in $nodes ; do
-               $ssh "$i" ./scripts/install_gpfs_nas.sh
+               $ssh "$i" ./scripts/install_packages.sh clusterfs nas
            done
-           $ssh "$n1" ./scripts/setup_gpfs.sh
 
-           if [ "$AUTH_METHOD" = "winbind" ]; then
-               args="-UAdministrator%${AD_ADMIN_PASS}"
-           else
-               args=""
-           fi
-           $ssh "$n1" ./scripts/setup_cluster.sh "$args"
+           $ssh "$n1" ./scripts/setup_cluster.sh clusterfs nas
            ;;
     esac
 }
@@ -1400,6 +1418,11 @@ case "$t" in
            case "$t" in
                destroy|create|update_hosts|boot|configure)
                    actions_add "cluster_${t}" ;;
+               build)
+                   for t in destroy create update_hosts boot configure ; do
+                       actions_add "cluster_${t}"
+                   done
+                   ;;
                *) usage ;;
            esac
        done