Skip to content

Instantly share code, notes, and snippets.

@dosaboy
Created June 3, 2016 13:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dosaboy/ea66eaeae945c6ed07e285b17602bb87 to your computer and use it in GitHub Desktop.
Save dosaboy/ea66eaeae945c6ed07e285b17602bb87 to your computer and use it in GitHub Desktop.
#!/bin/bash -eux
#
# Test for SRU of https://bugs.launchpad.net/os-brick/+bug/1524989
#
#!/bin/bash -eux
read -aVMS<<<`nova list| awk '$6=="ACTIVE" {print $2}'`
NUM=${#VMS[@]}
for ((i=0;i<$NUM;i++)); do
for ((j=0;j<5;j++)); do
((`cinder list| grep vm${i}-vol| wc -l` < 5)) || break
cinder create --display-name vm${i}-vol 1
done
done
gotest ()
{
local vm=$1
local i=$2
local vols
read -avols<<<`cinder list| grep vm$i-vol| awk '$4=="available" {print $2}'`
# Attach all volumes
for v in ${vols[@]}; do (echo "Attaching $v to $vm"; nova volume-attach $vm $v) & done
wait
while true; do cinder list| grep -q available || break; done
# Ensure all volumes attached (in-use) from VM
nova show $vm| grep os-extended-volumes:volumes_attached
cinder list
# Detach all volumes
for v in ${vols[@]}; do (echo "Detaching $v from $vm"; nova volume-detach $vm $v) & done
wait
while true; do cinder list| grep -q "in-use" || break; done
# Ensure all volumes detached (available) from VM
nova show $vm| grep os-extended-volumes:volumes_attached
cinder list
}
i=0
for vm in ${VMS[@]}; do
index=$((i++))
gotest $vm $index &
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment