Merge "Added ping_check and ssh_check functions and use it in exercise.sh"
This commit is contained in:
commit
1a9cdd3ecd
@ -139,16 +139,10 @@ fi
|
||||
nova add-floating-ip $VOL_VM_UUID $FLOATING_IP
|
||||
|
||||
# Test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds
|
||||
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
|
||||
echo "Couldn't ping volume-backed server with floating ip"
|
||||
exit 1
|
||||
fi
|
||||
ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT
|
||||
|
||||
# Make sure our volume-backed instance launched
|
||||
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! ssh -o StrictHostKeyChecking=no -i $KEY_FILE ${DEFAULT_INSTANCE_USER}@$FLOATING_IP echo success ; do sleep 1; done"; then
|
||||
echo "server didn't become ssh-able!"
|
||||
exit 1
|
||||
fi
|
||||
ssh_check "$PUBLIC_NETWORK_NAME" $KEY_FILE $FLOATING_IP $DEFAULT_INSTANCE_USER $ACTIVE_TIMEOUT
|
||||
|
||||
# Remove floating ip from volume-backed instance
|
||||
nova remove-floating-ip $VOL_VM_UUID $FLOATING_IP
|
||||
|
@ -130,10 +130,7 @@ euca-authorize -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP || \
|
||||
die "Failure authorizing rule in $SECGROUP"
|
||||
|
||||
# Test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds
|
||||
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
|
||||
echo "Couldn't ping server with floating ip"
|
||||
exit 1
|
||||
fi
|
||||
ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT
|
||||
|
||||
# Revoke pinging
|
||||
euca-revoke -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP || \
|
||||
|
@ -118,23 +118,10 @@ if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | g
|
||||
fi
|
||||
|
||||
# get the IP of the server
|
||||
IP=`nova show $VM_UUID | grep "private network" | get_field 2`
|
||||
IP=`nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2`
|
||||
die_if_not_set IP "Failure retrieving IP address"
|
||||
|
||||
# for single node deployments, we can ping private ips
|
||||
MULTI_HOST=`trueorfalse False $MULTI_HOST`
|
||||
if [ "$MULTI_HOST" = "False" ]; then
|
||||
# sometimes the first ping fails (10 seconds isn't enough time for the VM's
|
||||
# network to respond?), so let's ping for a default of 15 seconds with a
|
||||
# timeout of a second for each ping.
|
||||
if ! timeout $BOOT_TIMEOUT sh -c "while ! ping -c1 -w1 $IP; do sleep 1; done"; then
|
||||
echo "Couldn't ping server"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# On a multi-host system, without vm net access, do a sleep to wait for the boot
|
||||
sleep $BOOT_TIMEOUT
|
||||
fi
|
||||
ping_check "$PRIVATE_NETWORK_NAME" $IP $BOOT_TIMEOUT
|
||||
|
||||
# Security Groups & Floating IPs
|
||||
# ------------------------------
|
||||
@ -166,10 +153,7 @@ nova add-floating-ip $VM_UUID $FLOATING_IP || \
|
||||
die "Failure adding floating IP $FLOATING_IP to $NAME"
|
||||
|
||||
# test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds
|
||||
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
|
||||
echo "Couldn't ping server with floating ip"
|
||||
exit 1
|
||||
fi
|
||||
ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT
|
||||
|
||||
# Allocate an IP from second floating pool
|
||||
TEST_FLOATING_IP=`nova floating-ip-create $TEST_FLOATING_POOL | grep $TEST_FLOATING_POOL | get_field 1`
|
||||
@ -187,19 +171,16 @@ nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0 || die "Failure deletin
|
||||
# FIXME (anthony): make xs support security groups
|
||||
if [ "$VIRT_DRIVER" != "xenserver" -a "$VIRT_DRIVER" != "openvz" ]; then
|
||||
# test we can aren't able to ping our floating ip within ASSOCIATE_TIMEOUT seconds
|
||||
if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then
|
||||
print "Security group failure - ping should not be allowed!"
|
||||
echo "Couldn't ping server with floating ip"
|
||||
exit 1
|
||||
fi
|
||||
ping_check "$PUBLIC_NETWORK_NAME" $FLOATING_IP $ASSOCIATE_TIMEOUT
|
||||
fi
|
||||
|
||||
# de-allocate the floating ip
|
||||
nova floating-ip-delete $FLOATING_IP || die "Failure deleting floating IP $FLOATING_IP"
|
||||
|
||||
# Delete second floating IP
|
||||
nova floating-ip-delete $TEST_FLOATING_IP || die "Failure deleting floating IP $TEST_FLOATING_IP"
|
||||
|
||||
|
||||
# de-allocate the floating ip
|
||||
nova floating-ip-delete $FLOATING_IP || die "Failure deleting floating IP $FLOATING_IP"
|
||||
|
||||
# Shutdown the server
|
||||
nova delete $VM_UUID || die "Failure deleting instance $NAME"
|
||||
|
||||
|
@ -119,23 +119,11 @@ if ! timeout $ACTIVE_TIMEOUT sh -c "while ! nova show $VM_UUID | grep status | g
|
||||
fi
|
||||
|
||||
# get the IP of the server
|
||||
IP=`nova show $VM_UUID | grep "private network" | get_field 2`
|
||||
IP=`nova show $VM_UUID | grep "$PRIVATE_NETWORK_NAME" | get_field 2`
|
||||
die_if_not_set IP "Failure retrieving IP address"
|
||||
|
||||
# for single node deployments, we can ping private ips
|
||||
MULTI_HOST=`trueorfalse False $MULTI_HOST`
|
||||
if [ "$MULTI_HOST" = "False" ]; then
|
||||
# sometimes the first ping fails (10 seconds isn't enough time for the VM's
|
||||
# network to respond?), so let's ping for a default of 15 seconds with a
|
||||
# timeout of a second for each ping.
|
||||
if ! timeout $BOOT_TIMEOUT sh -c "while ! ping -c1 -w1 $IP; do sleep 1; done"; then
|
||||
echo "Couldn't ping server"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
# On a multi-host system, without vm net access, do a sleep to wait for the boot
|
||||
sleep $BOOT_TIMEOUT
|
||||
fi
|
||||
ping_check "$PRIVATE_NETWORK_NAME" $IP $BOOT_TIMEOUT
|
||||
|
||||
# Volumes
|
||||
# -------
|
||||
|
36
functions
36
functions
@ -849,6 +849,42 @@ function yum_install() {
|
||||
yum install -y "$@"
|
||||
}
|
||||
|
||||
# ping check
|
||||
# Uses globals ``ENABLED_SERVICES``
|
||||
function ping_check() {
|
||||
_ping_check_novanet "$1" $2 $3
|
||||
}
|
||||
|
||||
# ping check for nova
|
||||
# Uses globals ``MULTI_HOST``, ``PRIVATE_NETWORK``
|
||||
function _ping_check_novanet() {
|
||||
local from_net=$1
|
||||
local ip=$2
|
||||
local boot_timeout=$3
|
||||
MULTI_HOST=`trueorfalse False $MULTI_HOST`
|
||||
if [[ "$MULTI_HOST" = "True" && "$from_net" = "$PRIVATE_NETWORK_NAME" ]]; then
|
||||
sleep $boot_timeout
|
||||
return
|
||||
fi
|
||||
if ! timeout $boot_timeout sh -c "while ! ping -c1 -w1 $ip; do sleep 1; done"; then
|
||||
echo "Couldn't ping server"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# ssh check
|
||||
function ssh_check() {
|
||||
local NET_NAME=$1
|
||||
local KEY_FILE=$2
|
||||
local FLOATING_IP=$3
|
||||
local DEFAULT_INSTANCE_USER=$4
|
||||
local ACTIVE_TIMEOUT=$5
|
||||
local probe_cmd = ""
|
||||
if ! timeout $ACTIVE_TIMEOUT sh -c "while ! ssh -o StrictHostKeyChecking=no -i $KEY_FILE ${DEFAULT_INSTANCE_USER}@$FLOATING_IP echo success ; do sleep 1; done"; then
|
||||
echo "server didn't become ssh-able!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Restore xtrace
|
||||
$XTRACE
|
||||
|
3
openrc
3
openrc
@ -72,3 +72,6 @@ export COMPUTE_API_VERSION=${COMPUTE_API_VERSION:-$NOVA_VERSION}
|
||||
# set log level to DEBUG (helps debug issues)
|
||||
# export KEYSTONECLIENT_DEBUG=1
|
||||
# export NOVACLIENT_DEBUG=1
|
||||
|
||||
# set qunatum debug command
|
||||
export TEST_CONFIG_FILE=/etc/quantum/debug.ini
|
||||
|
8
stack.sh
8
stack.sh
@ -1953,14 +1953,14 @@ if is_service_enabled q-svc; then
|
||||
# Create a small network
|
||||
# Since quantum command is executed in admin context at this point,
|
||||
# ``--tenant_id`` needs to be specified.
|
||||
NET_ID=$(quantum net-create --tenant_id $TENANT_ID net1 | grep ' id ' | get_field 2)
|
||||
NET_ID=$(quantum net-create --tenant_id $TENANT_ID "$PRIVATE_NETWORK_NAME" | grep ' id ' | get_field 2)
|
||||
SUBNET_ID=$(quantum subnet-create --tenant_id $TENANT_ID --ip_version 4 --gateway $NETWORK_GATEWAY $NET_ID $FIXED_RANGE | grep ' id ' | get_field 2)
|
||||
if is_service_enabled q-l3; then
|
||||
# Create a router, and add the private subnet as one of its interfaces
|
||||
ROUTER_ID=$(quantum router-create --tenant_id $TENANT_ID router1 | grep ' id ' | get_field 2)
|
||||
quantum router-interface-add $ROUTER_ID $SUBNET_ID
|
||||
# Create an external network, and a subnet. Configure the external network as router gw
|
||||
EXT_NET_ID=$(quantum net-create ext_net -- --router:external=True | grep ' id ' | get_field 2)
|
||||
EXT_NET_ID=$(quantum net-create "$PUBLIC_NETWORK_NAME" -- --router:external=True | grep ' id ' | get_field 2)
|
||||
EXT_GW_IP=$(quantum subnet-create --ip_version 4 $EXT_NET_ID $FLOATING_RANGE -- --enable_dhcp=False | grep 'gateway_ip' | get_field 2)
|
||||
quantum router-gateway-set $ROUTER_ID $EXT_NET_ID
|
||||
if is_quantum_ovs_base_plugin "$Q_PLUGIN" && [[ "$Q_USE_NAMESPACE" = "True" ]]; then
|
||||
@ -1978,10 +1978,10 @@ if is_service_enabled q-svc; then
|
||||
|
||||
elif is_service_enabled mysql && is_service_enabled nova; then
|
||||
# Create a small network
|
||||
$NOVA_BIN_DIR/nova-manage network create private $FIXED_RANGE 1 $FIXED_NETWORK_SIZE $NETWORK_CREATE_ARGS
|
||||
$NOVA_BIN_DIR/nova-manage network create "$PRIVATE_NETWORK_NAME" $FIXED_RANGE 1 $FIXED_NETWORK_SIZE $NETWORK_CREATE_ARGS
|
||||
|
||||
# Create some floating ips
|
||||
$NOVA_BIN_DIR/nova-manage floating create $FLOATING_RANGE
|
||||
$NOVA_BIN_DIR/nova-manage floating create $FLOATING_RANGE --pool=$PUBLIC_NETWORK
|
||||
|
||||
# Create a second pool
|
||||
$NOVA_BIN_DIR/nova-manage floating create --ip_range=$TEST_FLOATING_RANGE --pool=$TEST_FLOATING_POOL
|
||||
|
Loading…
Reference in New Issue
Block a user