Adds a simple overcloud tenant vm ping test to tripleo.sh
As discussed at [1] this adds a simple overcloud tenant vm startup, with a floating ip attached, which is then pinged. The goal is to eventually add tempest support though consensus seems to be we should carry at least a ping test. This has now been re-implemented with a heat template, which we carry here for now (but can be moved to a better place if necessary) The aim here is to add this to tripleo.sh to it primarily will be consumed by toci_instack for ci [1] https://trello.com/c/OQlIbGoK/19-toci-start-a-user-instance-and-ping-it Change-Id: Ifbbaf0a84dd9e0530fa8b9a42a0f66793e0df94d
This commit is contained in:
@@ -62,6 +62,7 @@ function show_options {
|
||||
echo " --overcloud-delete -- Delete the overcloud."
|
||||
echo " --use-containers -- Use a containerized compute node."
|
||||
echo " --enable-check -- Enable checks on update."
|
||||
echo " --overcloud-pingtest -- Run a tenant vm, attach and ping floating IP."
|
||||
echo " --all, -a -- Run all of the above commands."
|
||||
echo " -x -- enable tracing"
|
||||
echo " --help, -h -- Print this help message."
|
||||
@@ -75,7 +76,7 @@ if [ ${#@} = 0 ]; then
|
||||
fi
|
||||
|
||||
TEMP=$(getopt -o ,h \
|
||||
-l,help,repo-setup,delorean-setup,delorean-build,undercloud,overcloud-images,register-nodes,introspect-nodes,overcloud-deploy,overcloud-update,overcloud-delete,use-containers,all,enable-check \
|
||||
-l,help,repo-setup,delorean-setup,delorean-build,undercloud,overcloud-images,register-nodes,introspect-nodes,overcloud-deploy,overcloud-update,overcloud-delete,use-containers,overcloud-pingtest,all,enable-check \
|
||||
-o,x,h,a \
|
||||
-n $SCRIPT_NAME -- "$@")
|
||||
|
||||
@@ -121,6 +122,7 @@ OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF=${OVERCLOUD_IMAGES_DIB_YUM_REPO_CONF:-"\
|
||||
/etc/yum.repos.d/delorean-deps.repo"}
|
||||
OVERCLOUD_IMAGES_ARGS=${OVERCLOUD_IMAGES_ARGS='--all'}
|
||||
OVERCLOUD_NAME=${OVERCLOUD_NAME:-"overcloud"}
|
||||
OVERCLOUD_PINGTEST=${OVERCLOUD_PINGTEST:-""}
|
||||
REPO_SETUP=${REPO_SETUP:-""}
|
||||
DELOREAN_SETUP=${DELOREAN_SETUP:-""}
|
||||
DELOREAN_BUILD=${DELOREAN_BUILD:-""}
|
||||
@@ -146,6 +148,7 @@ while true ; do
|
||||
--overcloud-update) OVERCLOUD_UPDATE="1"; shift 1;;
|
||||
--overcloud-delete) OVERCLOUD_DELETE="1"; shift 1;;
|
||||
--overcloud-images) OVERCLOUD_IMAGES="1"; shift 1;;
|
||||
--overcloud-pingtest) OVERCLOUD_PINGTEST="1"; shift 1;;
|
||||
--repo-setup) REPO_SETUP="1"; shift 1;;
|
||||
--delorean-setup) DELOREAN_SETUP="1"; shift 1;;
|
||||
--delorean-build) DELOREAN_BUILD="1"; shift 1;;
|
||||
@@ -165,14 +168,20 @@ function log {
|
||||
echo "#################"
|
||||
}
|
||||
|
||||
function source_rc {
|
||||
if [ $1 = "stackrc" ] ; then cloud="Undercloud"; else cloud="Overcloud"; fi
|
||||
echo "You must source a $1 file for the $cloud."
|
||||
echo "Attempting to source $HOME/$1"
|
||||
source $HOME/$1
|
||||
echo "Done"
|
||||
}
|
||||
|
||||
function stackrc_check {
|
||||
OS_AUTH_URL=${OS_AUTH_URL:-""}
|
||||
if [ -z "$OS_AUTH_URL" ]; then
|
||||
echo "You must source a stackrc file for the Undercloud."
|
||||
echo "Attempting to source stackrc at $HOME/stackrc"
|
||||
source $HOME/stackrc
|
||||
echo "Done."
|
||||
fi
|
||||
source_rc "stackrc"
|
||||
}
|
||||
|
||||
function overcloudrc_check {
|
||||
source_rc "overcloudrc"
|
||||
}
|
||||
|
||||
function repo_setup {
|
||||
@@ -504,6 +513,77 @@ function overcloud_delete {
|
||||
fi
|
||||
}
|
||||
|
||||
function cleanup_pingtest {
|
||||
|
||||
log "Overcloud pingtest, starting cleanup"
|
||||
overcloudrc_check
|
||||
heat stack-delete tenant-stack
|
||||
if $(tripleo wait_for -w 300 -d 10 -s "Stack not found" -- "heat stack-show tenant-stack" ); then
|
||||
log "Overcloud pingtest - deleted the tenant-stack heat stack"
|
||||
else
|
||||
log "Overcloud pingtest - time out waiting to delete tenant heat stack, please check manually"
|
||||
fi
|
||||
log "Overcloud pingtest - cleaning demo network 'nova' and 'pingtest_image' image"
|
||||
glance image-delete pingtest_image
|
||||
neutron net-delete nova
|
||||
log "Overcloud pingtest - DONE"
|
||||
}
|
||||
|
||||
|
||||
function overcloud_pingtest {
|
||||
|
||||
log "Overcloud pingtest"
|
||||
exitval=0
|
||||
|
||||
overcloudrc_check
|
||||
|
||||
version=`curl http://download.cirros-cloud.net/version/released`
|
||||
cirros_latest=cirros-$version-x86_64-disk.img
|
||||
if [ ! -e $OVERCLOUD_IMAGES_PATH/$cirros_latest ]; then
|
||||
log "Overcloud pingtest, trying to download latest $cirros_latest"
|
||||
curl -o $OVERCLOUD_IMAGES_PATH/$cirros_latest http://download.cirros-cloud.net/$version/$cirros_latest
|
||||
fi
|
||||
log "Overcloud pingtest, uploading demo tenant image to glance"
|
||||
glance image-create --progress --name pingtest_image --is-public True --disk-format qcow2 --container-format bare --file $OVERCLOUD_IMAGES_PATH/$cirros_latest
|
||||
|
||||
log "Overcloud pingtest, creating demo tenant keypair and external network"
|
||||
if ! nova keypair-show default 2>/dev/null; then tripleo user-config; fi
|
||||
neutron net-create nova --shared --router:external=True --provider:network_type flat \
|
||||
--provider:physical_network datacentre
|
||||
FLOATING_IP_CIDR=${FLOATING_IP_CIDR:-"192.0.2.0/24"}
|
||||
FLOATING_IP_START=${FLOATING_IP_START:-"192.0.2.50"}
|
||||
FLOATING_IP_END=${FLOATING_IP_END:-"192.0.2.64"}
|
||||
EXTERNAL_NETWORK_GATEWAY=${EXTERNAL_NETWORK_GATEWAY:-"192.0.2.1"}
|
||||
neutron subnet-create --name ext-subnet --allocation-pool start=$FLOATING_IP_START,end=$FLOATING_IP_END --disable-dhcp --gateway $EXTERNAL_NETWORK_GATEWAY nova $FLOATING_IP_CIDR
|
||||
TENANT_PINGTEST_TEMPLATE=/usr/share/tripleo-common/tenantvm_floatingip.yaml
|
||||
if [ ! -e $TENANT_PINGTEST_TEMPLATE ]; then
|
||||
TENANT_PINGTEST_TEMPLATE=$(dirname `readlink -f -- $0`)/../templates/tenantvm_floatingip.yaml
|
||||
fi
|
||||
log "Overcloud pingtest, creating tenant-stack heat stack:"
|
||||
heat stack-create -f $TENANT_PINGTEST_TEMPLATE tenant-stack || exitval=1
|
||||
if tripleo wait_for -w 180 -d 10 -s "CREATE_COMPLETE" -- "heat stack-list | grep tenant-stack"; then
|
||||
log "Overcloud pingtest, heat stack CREATE_COMPLETE";
|
||||
|
||||
vm1_ip=`heat output-show tenant-stack server1_public_ip -F raw`
|
||||
|
||||
log "Overcloud pingtest, trying to ping the floating IPs $vm1_ip"
|
||||
|
||||
if tripleo wait_for -w 180 -d 10 -s "bytes from $vm1_ip" -- "ping -c 1 $vm1_ip" ; then
|
||||
ping -c 1 $vm1_ip
|
||||
log "Overcloud pingtest, SUCCESS"
|
||||
else
|
||||
ping -c 1 $vm1_ip || :
|
||||
log "Overloud pingtest, FAIL"
|
||||
exitval=1
|
||||
fi
|
||||
else
|
||||
log "Overcloud pingtest, failed to create heat stack, trying cleanup"
|
||||
exitval=1
|
||||
fi
|
||||
cleanup_pingtest
|
||||
exit $exitval
|
||||
}
|
||||
|
||||
if [ "$REPO_SETUP" = 1 ]; then
|
||||
repo_setup
|
||||
fi
|
||||
@@ -554,6 +634,10 @@ if [[ "$USE_CONTAINERS" == 1 && "$OVERCLOUD_DEPLOY" != 1 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$OVERCLOUD_PINGTEST" = 1 ]; then
|
||||
overcloud_pingtest
|
||||
fi
|
||||
|
||||
if [ "$ALL" = 1 ]; then
|
||||
repo_setup
|
||||
undercloud
|
||||
|
||||
@@ -22,6 +22,9 @@ classifier =
|
||||
packages =
|
||||
tripleo_common
|
||||
|
||||
data_files =
|
||||
share/tripleo-common/templates = templates/*
|
||||
|
||||
[build_sphinx]
|
||||
source-dir = doc/source
|
||||
build-dir = doc/build
|
||||
|
||||
121
templates/tenantvm_floatingip.yaml
Normal file
121
templates/tenantvm_floatingip.yaml
Normal file
@@ -0,0 +1,121 @@
|
||||
heat_template_version: 2013-05-23
|
||||
|
||||
# TODO(bnemec): Something with Cinder to verify it is working too.
|
||||
|
||||
description: >
|
||||
HOT template to create a new neutron network plus a router to the public
|
||||
network, and for deploying a server into the new network. The template also
|
||||
assigns a floating IP address and sets security group rules. ADAPTED FROM
|
||||
https://raw.githubusercontent.com/openstack/heat-templates/master/hot/servers_in_new_neutron_net.yaml
|
||||
parameters:
|
||||
key_name:
|
||||
type: string
|
||||
description: Name of keypair to assign to servers
|
||||
default: 'default'
|
||||
image:
|
||||
type: string
|
||||
description: Name of image to use for servers
|
||||
default: 'pingtest_image'
|
||||
flavor:
|
||||
type: string
|
||||
description: Flavor to use for servers
|
||||
default: 'm1.demo'
|
||||
public_net_name:
|
||||
type: string
|
||||
default: 'nova'
|
||||
description: >
|
||||
ID or name of public network for which floating IP addresses will be allocated
|
||||
private_net_name:
|
||||
type: string
|
||||
description: Name of private network to be created
|
||||
default: 'default-net'
|
||||
private_net_cidr:
|
||||
type: string
|
||||
description: Private network address (CIDR notation)
|
||||
default: '10.0.0.0/8'
|
||||
private_net_gateway:
|
||||
type: string
|
||||
description: Private network gateway address
|
||||
default: '10.0.0.1'
|
||||
private_net_pool_start:
|
||||
type: string
|
||||
description: Start of private network IP address allocation pool
|
||||
default: '10.0.0.10'
|
||||
private_net_pool_end:
|
||||
type: string
|
||||
default: '10.0.0.20'
|
||||
description: End of private network IP address allocation pool
|
||||
|
||||
resources:
|
||||
|
||||
private_net:
|
||||
type: OS::Neutron::Net
|
||||
properties:
|
||||
name: { get_param: private_net_name }
|
||||
|
||||
private_subnet:
|
||||
type: OS::Neutron::Subnet
|
||||
properties:
|
||||
network_id: { get_resource: private_net }
|
||||
cidr: { get_param: private_net_cidr }
|
||||
gateway_ip: { get_param: private_net_gateway }
|
||||
allocation_pools:
|
||||
- start: { get_param: private_net_pool_start }
|
||||
end: { get_param: private_net_pool_end }
|
||||
|
||||
router:
|
||||
type: OS::Neutron::Router
|
||||
properties:
|
||||
external_gateway_info:
|
||||
network: { get_param: public_net_name }
|
||||
|
||||
router_interface:
|
||||
type: OS::Neutron::RouterInterface
|
||||
properties:
|
||||
router_id: { get_resource: router }
|
||||
subnet_id: { get_resource: private_subnet }
|
||||
|
||||
server1:
|
||||
type: OS::Nova::Server
|
||||
properties:
|
||||
name: Server1
|
||||
image: { get_param: image }
|
||||
flavor: { get_param: flavor }
|
||||
key_name: { get_param: key_name }
|
||||
networks:
|
||||
- port: { get_resource: server1_port }
|
||||
|
||||
server1_port:
|
||||
type: OS::Neutron::Port
|
||||
properties:
|
||||
network_id: { get_resource: private_net }
|
||||
fixed_ips:
|
||||
- subnet_id: { get_resource: private_subnet }
|
||||
security_groups: [{ get_resource: server_security_group }]
|
||||
|
||||
server1_floating_ip:
|
||||
type: OS::Neutron::FloatingIP
|
||||
properties:
|
||||
floating_network: { get_param: public_net_name }
|
||||
port_id: { get_resource: server1_port }
|
||||
|
||||
server_security_group:
|
||||
type: OS::Neutron::SecurityGroup
|
||||
properties:
|
||||
description: Add security group rules for server
|
||||
name: pingtest-security-group
|
||||
rules:
|
||||
- remote_ip_prefix: 0.0.0.0/0
|
||||
protocol: tcp
|
||||
port_range_min: 22
|
||||
port_range_max: 22
|
||||
- remote_ip_prefix: 0.0.0.0/0
|
||||
protocol: icmp
|
||||
|
||||
outputs:
|
||||
server1_private_ip:
|
||||
description: IP address of server1 in private network
|
||||
value: { get_attr: [ server1, first_address ] }
|
||||
server1_public_ip:
|
||||
description: Floating IP address of server1 in public network
|
||||
value: { get_attr: [ server1_floating_ip, floating_ip_address ] }
|
||||
Reference in New Issue
Block a user