Skip to content

Commit eee8e2d

Browse files
committed
vdi-streaming: add lvm streaming support
Add code to check vdi streaming on LVM
1 parent b4caf02 commit eee8e2d

File tree

1 file changed

+57
-23
lines changed

1 file changed

+57
-23
lines changed

test_vgpu.sh

Lines changed: 57 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ TEMPEST_DIR=$DEST/tempest
3131
NOVA_CONF=/etc/nova/nova.conf
3232
IMAGE_NAME=${IMAGE_NAME:-"cirros-0.3.5-x86_64-disk"}
3333
VM_NAME=${VM_NAME:-"testVM"}
34+
SNAPSHOT_NAME=${SNAPSHOT_NAME:-"testSnapshot"}
3435
JOURNAL_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"}
3637
TMP_LOG_DIR=/tmp/openstack
3738

38-
3939
SLEEP_TIME_GAP=3
4040
SLEEP_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+
7095
trap on_exit EXIT
7196

7297
error_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+
80114
DOM0_IP=$(grep XENAPI_CONNECTION_URL ${DEVSTACK_PATH}/local.conf | cut -d'=' -f2 | sed 's/[^0-9,.]*//g')
81115

82116
echo "Dom0 IP is: $DOM0_IP"
@@ -155,14 +189,18 @@ done
155189
END_OF_REQ_VGPU_TYPE
156190
)
157191

158-
echo "###################Devstack start stack#####################"
159192
pushd $DEVSTACK_PATH/
160193
if ! grep "enabled_vgpu_types=" ${DEVSTACK_PATH}/local.conf; then
161194
echo "[devices]" >> ${DEVSTACK_PATH}/local.conf
162195
echo "enabled_vgpu_types = $first_vgpu_type" >> ${DEVSTACK_PATH}/local.conf
163196
fi
197+
echo "###################Set image handler to remote stream#####################"
198+
echo "[xenserver]" >> ${DEVSTACK_PATH}/local.conf
199+
echo "image_handler = vdi_remote_stream" >> ${DEVSTACK_PATH}/local.conf
200+
164201
sudo find $JOURNAL_DIR -name "*.journal" -exec rm {} \;
165202
sudo systemctl restart systemd-journald
203+
echo "###################Devstack start stack#####################"
166204
./stack.sh
167205
popd
168206

@@ -182,23 +220,7 @@ prv_net=$(openstack network list | grep "private" | awk '{print $2}')
182220
nova boot --image $IMAGE_NAME --flavor 1 --nic net-id=$prv_net $VM_NAME
183221

184222
nova_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
223+
until_vm_active $VM_NAME
202224

203225
echo "###################Check VGPU create status#####################"
204226
if [ $vm_state = "ACTIVE" ]; then
@@ -215,10 +237,22 @@ END_OF_VGPU_CONFIRM
215237
fi
216238

217239
if [ -n "$result" ]; then
218-
echo "VGPU create success"
240+
echo $VGPU_CREATE_SUCCESS_FLAG
241+
echo "###################Check LVM image upload status#####################"
242+
nova image-create --poll $VM_NAME $SNAPSHOT_NAME
243+
if ! openstack image show $SNAPSHOT_NAME; then
244+
error_log=$error_log"\n\tImage create failed!"
245+
echo $error_log
246+
exit 1
247+
fi
248+
nova boot --image $SNAPSHOT_NAME --flavor 1 --nic net-id=$prv_net $VM_NAME
249+
until_vm_active $VM_NAME
219250
else
220-
error_log=$error_log"\n\tVGPU create failed"
251+
error_log=$error_log"\n\tVGPU create failed!"
221252
echo $error_log
253+
exit 1
222254
fi
223255

256+
257+
224258
set +ex

0 commit comments

Comments
 (0)