# 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 $@
|| 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" \
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"