From da7047562e8fbbffdc24154619ff48c6b7d87815 Mon Sep 17 00:00:00 2001 From: Thilo Fromm Date: Fri, 3 May 2013 14:45:28 +0200 Subject: [PATCH] storage_deploy: now with autotest image provisioning Signed-off-by: Thilo Fromm --- storage_deploy.sh | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/storage_deploy.sh b/storage_deploy.sh index 378d285..c789681 100755 --- a/storage_deploy.sh +++ b/storage_deploy.sh @@ -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" -- 2.39.5