blob: 80d79e382270be2644b60aa89f0d12800798d09f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/bin/bash
##############################################################################
# Copyright (c) 2016 ZTE Coreporation and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
IMAGE_NAME=TestVM
# Sanitize language settings to avoid commands bailing out
# with "unsupported locale setting" errors.
unset LANG
unset LANGUAGE
LC_ALL=C
export LC_ALL
for i in curl openstack; do
if [[ ! $(type ${i} 2>/dev/null) ]]; then
if [ "${i}" == 'curl' ]; then
echo "Please install ${i} before proceeding"
else
echo "Please install python-${i}client before proceeding"
fi
exit
fi
done
# Move to top level directory
REAL_PATH=$(python -c "import os,sys;print os.path.realpath('$0')")
cd "$(dirname "$REAL_PATH")/.."
# Test for credentials set
if [[ "${OS_USERNAME}" == "" ]]; then
echo "No Keystone credentials specified. Try running source openrc"
exit
fi
echo "Configuring tenant network."
openstack network create --provider-network-type vxlan demo-net
openstack subnet create --subnet-range 10.0.0.0/24 --network demo-net \
--gateway 10.0.0.1 --dns-nameserver 8.8.8.8 demo-subnet
DEMO_NET_ID=$(openstack network list | awk '/ demo-net / {print $2}')
openstack router create demo-router
openstack router add subnet demo-router demo-subnet
openstack router set --external-gateway admin_external demo-router
openstack floating ip create admin_external
DEMO_FIP=$(openstack floating ip list | awk '/ None / {print $4}')
openstack server create --image ${IMAGE_NAME} --flavor m1.micro \
--nic net-id=${DEMO_NET_ID} demo1
# Wait for guest ready to accept FIP, seems need it.
sleep 10
openstack server add floating ip demo1 ${DEMO_FIP}
echo "Now you can test ping ${DEMO_FIP} from external network"
|