]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
storage_deploy: now with autotest image provisioning
authorThilo Fromm <thilo.fromm@profitbricks.com>
Fri, 3 May 2013 12:45:28 +0000 (14:45 +0200)
committerThilo Fromm <thilo.fromm@profitbricks.com>
Fri, 3 May 2013 12:47:45 +0000 (14:47 +0200)
Signed-off-by: Thilo Fromm <thilo.fromm@profitbricks.com>
storage_deploy.sh

index 378d2858001334e46f6ce9d4c69ace1ad9588212..c789681990e71e1232ecc9b72bea322f38df0970 100755 (executable)
@@ -4,6 +4,16 @@
 # Storage server auto-deploy script
 #
 
+set -x
+# Globals
+
+# must be two at minimum
+system_blockdevs="sda sdb"
+
+# must be four at minimum
+storage_blockdevs="sdc sdd sde sdf sdg sdh sdi sdj sdk"
+
+
 log() {
     echo -n "###### `date --rfc-3339=seconds`  STORAGE AUTO-DEPLOY "
     echo $@
@@ -151,12 +161,12 @@ main() {
         || return 1
 
     log "    Creating Storage root FS partitions and disk array"
-    rexec "$storage_ip" "cd /tmp/pb-overlay/scripts && ./storage-create-root sda sdb" \
+    rexec "$storage_ip" "cd /tmp/pb-overlay/scripts && ./storage-create-root $system_blockdevs" \
         || return 1
 
     log "    Installing root system (gentoo) from tarball"
-    rexec "$storage_ip" "\
-     cd /tmp/pb-overlay/scripts && \
+    rexec "$storage_ip" "           \
+     cd /tmp/pb-overlay/scripts &&  \
      sed -i 's:{INSTANCE_NAME}\.last\.tar\.xz:{INSTANCE_NAME}.auto-deploy.last.tar.xz:' install-gentoo-storage" \
         || return 1
     rexec "$storage_ip" "cd /tmp/pb-overlay/scripts && ./install-gentoo-storage" \
@@ -171,14 +181,38 @@ main() {
     rexec "$storage_ip" "cd /tmp && git clone git://git/so/pb-overlay.git" \
         || return 1
 
+    log "    Checking for SSDs and TRIMming those, if found."
+    rexec "$storage_ip" "\
+        for drive in $storage_blockdevs; do
+            hdparm -I /dev/\$drive | grep -q 'Data Set Management TRIM supported' &&  {
+                sectors=\`hdparm -I /dev/\$drive | grep \"LBA48  user addressable sectors:\" | awk '{ print \$5 }'\`
+                for (( i=0; i < \$sectors; i=i+65535 )); do
+                    range=65535
+                    [ \$((i + 65535)) -ge \$sectors ] && range=\$((sectors - i))
+                    echo \"\$i:\$range\"
+                done | hdparm --trim-sector-ranges-stdin --please-destroy-my-drive /dev/\$drive
+                hdparm -z /dev/\$drive; }
+        done"
+
     log "    Creating storage disk array"
-    rexec "$storage_ip" "cd /tmp/pb-overlay/scripts && ./storage-create-storage 'sdc sdd sde sdf' /storage/mdraid.start" \
+    rexec "$storage_ip" "cd /tmp/pb-overlay/scripts && ./storage-create-storage '$storage_blockdevs' /storage/mdraid.start" \
         || return 1
 
     log "    Rebooting"
     rexec "$storage_ip" "reboot" ||  return 1
     wait_for_reboot 600 $storage_ip || { log "    ABORT"; return 1; }
 
+    log "    Setting up autotest client VM images."
+    rexec "$storage_ip" "                           \
+        cd /tmp                                     \
+        && git clone git://git/so/pb-overlay.git    \
+        && cd pb-overlay/scripts                    \
+        && ./storage_provisioning.sh 10.250.131.238 storage1302 \
+                                     10.250.131.239 storage1301 \
+                                     pserver1301 0x0002c903000d3a9f 0x0002c90300108a75 \
+                                     http://riserver/kvm/storage-auto-provisioning/client-image.raw" \
+        || return 1
+   
     cleanup "$storage_ip" || return 1
 
     log "                     S U C C E S S"