update exercise to boot a server, ping it, then destroy it
This commit is contained in:
parent
4e8847cd6a
commit
d888e1cdcb
43
exercise.sh
43
exercise.sh
@ -70,9 +70,6 @@ TOKEN=`curl -s -d "{\"auth\":{\"passwordCredentials\": {\"username\": \"$NOVA_U
|
|||||||
# List servers for tenant:
|
# List servers for tenant:
|
||||||
nova list
|
nova list
|
||||||
|
|
||||||
# List of flavors:
|
|
||||||
nova flavor-list
|
|
||||||
|
|
||||||
# Images
|
# Images
|
||||||
# ------
|
# ------
|
||||||
|
|
||||||
@ -82,8 +79,38 @@ nova image-list
|
|||||||
# But we recommend using glance directly
|
# But we recommend using glance directly
|
||||||
glance -A $TOKEN index
|
glance -A $TOKEN index
|
||||||
|
|
||||||
# show details of the active servers::
|
# Let's grab the id of the first AMI image to launch
|
||||||
#
|
IMAGE=`glance -A $TOKEN index | egrep ami | cut -d" " -f1`
|
||||||
# nova show 1234
|
|
||||||
#
|
|
||||||
nova list | grep ACTIVE | cut -d \| -f2 | xargs -n1 nova show
|
# Flavors
|
||||||
|
# -------
|
||||||
|
|
||||||
|
# List of flavors:
|
||||||
|
nova flavor-list
|
||||||
|
|
||||||
|
# and grab the first flavor in the list to launch
|
||||||
|
FLAVOR=`nova flavor-list | head -n 4 | tail -n 1 | cut -d"|" -f2`
|
||||||
|
|
||||||
|
NAME="firstpost"
|
||||||
|
|
||||||
|
nova boot --flavor $FLAVOR --image $IMAGE $NAME
|
||||||
|
|
||||||
|
# let's give it 10 seconds to launch
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
# check that the status is active
|
||||||
|
nova show $NAME | grep status | grep -q ACTIVE
|
||||||
|
|
||||||
|
# get the IP of the server
|
||||||
|
IP=`nova show $NAME | grep "private network" | cut -d"|" -f3`
|
||||||
|
|
||||||
|
# ping it once (timeout of a second)
|
||||||
|
ping -c1 -w1 $IP
|
||||||
|
|
||||||
|
# shutdown the server
|
||||||
|
nova delete $NAME
|
||||||
|
|
||||||
|
# FIXME: validate shutdown within 5 seconds
|
||||||
|
# (nova show $NAME returns 1 or status != ACTIVE)?
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user