@@ -31,11 +31,11 @@ TEMPEST_DIR=$DEST/tempest
3131NOVA_CONF=/etc/nova/nova.conf
3232IMAGE_NAME=${IMAGE_NAME:- " cirros-0.3.5-x86_64-disk" }
3333VM_NAME=${VM_NAME:- " testVM" }
34+ SNAPSHOT_NAME=${SNAPSHOT_NAME:- " testSnapshot" }
3435JOURNAL_DIR=/var/log/journal
35- VGPU_TEST_LOG_DIR =${VGPU_TEST_LOG_DIR :- " /opt/stack/workspace/test_vgpu/logs" }
36+ OPENSTACK_LOGS =${OPENSTACK_LOGS :- " /opt/stack/workspace/test_vgpu/logs" }
3637TMP_LOG_DIR=/tmp/openstack
3738
38-
3939SLEEP_TIME_GAP=3
4040SLEEP_MAX_TRIES=40
4141
@@ -56,17 +56,42 @@ on_exit()
5656 do
5757 sudo journalctl --unit $service > $TMP_LOG_DIR /$service " .log" ;
5858 done
59- cp $TMP_LOG_DIR /* $VGPU_TEST_LOG_DIR /
59+ cp $TMP_LOG_DIR /* $OPENSTACK_LOGS /
6060 echo " ###################Clean environment if requested#####################"
6161 if [ $keep_env != " true" ]; then
6262 pushd $DEVSTACK_PATH /
6363 nova delete $VM_NAME
64+ openstack image delete $SNAPSHOT_NAME
6465 ./clean.sh
6566 popd
67+ rm $DEVSTACK_PATH -rf
68+
6669 fi
6770 set +x
6871}
6972
73+ until_vm_active ()
74+ {
75+ count=0
76+ vm_name = $1
77+ while :
78+ do
79+ echo " Waitting to VM active"
80+ sleep $SLEEP_TIME_GAP
81+ count=$(( count + 1 ))
82+ vm_state=$( nova show $vm_name | grep -w ' status' | awk ' {print $4}' )
83+ if [ $vm_state = " ERROR" ]; then
84+ error_log=$error_log " \n\tVM create failed"
85+ exit 1
86+ elif [ $vm_state = " ACTIVE" ]; then
87+ break
88+ elif [ $count -gt $SLEEP_MAX_TRIES ]; then
89+ error_log=$error_log " \n\tVM can not reach active status"
90+ exit 1
91+ fi
92+ done
93+ }
94+
7095trap on_exit EXIT
7196
7297error_log=" VGPU test failed with the following errors: "
@@ -77,6 +102,15 @@ _SSH_OPTIONS="\
77102 -o UserKnownHostsFile=/dev/null \
78103 -i /opt/stack/.ssh/id_rsa"
79104
105+ pushd $ROOT_DIR
106+ rm $DEVSTACK_PATH -rf
107+ git clone https://github.com/openstack-dev/devstack.git
108+
109+ sed -i ' /iniset $NOVA_CONF DEFAULT flat_injected \"False\"/a\ iniset $NOVA_CONF xenserver image_handler "$vdi_remote_stream"' $DEVSTACK_PATH /lib/nova_plugins/hypervisor-xenserver
110+ popd
111+
112+ cp $ROOT_DIR /local.conf $DEVSTACK_PATH
113+
80114DOM0_IP=$( grep XENAPI_CONNECTION_URL ${DEVSTACK_PATH} /local.conf | cut -d' =' -f2 | sed ' s/[^0-9,.]*//g' )
81115
82116echo " Dom0 IP is: $DOM0_IP "
114148 pushd ${dir}
115149 if [ -d .git ]; then
116150 echo " update repository ${dir} "
117- git checkout master
151+ cur_branch=$( git branch | grep \* | cut -d ' ' -f2)
152+ if [ $cur_branch != ' master' ]; then
153+ git checkout master
154+ git branch -D $cur_branch
155+ fi
118156 if ! git diff-index --quiet HEAD --; then
119157 git checkout *
120158 fi
@@ -155,14 +193,18 @@ done
155193END_OF_REQ_VGPU_TYPE
156194)
157195
158- echo " ###################Devstack start stack#####################"
159196pushd $DEVSTACK_PATH /
160197if ! grep " enabled_vgpu_types=" ${DEVSTACK_PATH} /local.conf; then
161198 echo " [devices]" >> ${DEVSTACK_PATH} /local.conf
162199 echo " enabled_vgpu_types = $first_vgpu_type " >> ${DEVSTACK_PATH} /local.conf
163200fi
201+ echo " ###################Set image handler to remote stream#####################"
202+ echo " [xenserver]" >> ${DEVSTACK_PATH} /local.conf
203+ echo " image_handler = vdi_remote_stream" >> ${DEVSTACK_PATH} /local.conf
204+
164205sudo find $JOURNAL_DIR -name " *.journal" -exec rm {} \;
165206sudo systemctl restart systemd-journald
207+ echo " ###################Devstack start stack#####################"
166208./stack.sh
167209popd
168210
@@ -182,23 +224,7 @@ prv_net=$(openstack network list | grep "private" | awk '{print $2}')
182224nova boot --image $IMAGE_NAME --flavor 1 --nic net-id=$prv_net $VM_NAME
183225
184226nova_vm_id=$( nova show $VM_NAME | grep -w ' id' | awk ' {print $4}' )
185- count=0
186- while :
187- do
188- echo " Waitting to VM active"
189- sleep $SLEEP_TIME_GAP
190- count=$(( count + 1 ))
191- vm_state=$( nova show $VM_NAME | grep -w ' status' | awk ' {print $4}' )
192- if [ $vm_state = " ERROR" ]; then
193- error_log=$error_log " \n\tVM create failed"
194- break
195- elif [ $vm_state = " ACTIVE" ]; then
196- break
197- elif [ $count -gt $SLEEP_MAX_TRIES ]; then
198- error_log=$error_log " \n\tVM can not reach active status"
199- break
200- fi
201- done
227+ until_vm_active $VM_NAME
202228
203229echo " ###################Check VGPU create status#####################"
204230if [ $vm_state = " ACTIVE" ]; then
@@ -215,10 +241,22 @@ END_OF_VGPU_CONFIRM
215241fi
216242
217243if [ -n " $result " ]; then
218- echo " VGPU create success"
244+ echo $VGPU_CREATE_SUCCESS_FLAG
245+ echo " ###################Check LVM image upload status#####################"
246+ nova image-create --poll $VM_NAME $SNAPSHOT_NAME
247+ if ! openstack image show $SNAPSHOT_NAME ; then
248+ error_log=$error_log " \n\tImage create failed!"
249+ echo $error_log
250+ exit 1
251+ fi
252+ nova boot --image $SNAPSHOT_NAME --flavor 1 --nic net-id=$prv_net $VM_NAME
253+ until_vm_active $VM_NAME
219254else
220- error_log=$error_log " \n\tVGPU create failed"
255+ error_log=$error_log " \n\tVGPU create failed! "
221256 echo $error_log
257+ exit 1
222258fi
223259
260+
261+
224262set +ex
0 commit comments