diff options
author | Bryan Sullivan <bryan.sullivan@att.com> | 2017-01-16 13:04:02 -0800 |
---|---|---|
committer | Bryan Sullivan <bryan.sullivan@att.com> | 2017-01-16 13:04:02 -0800 |
commit | ba748f15768078419346c620f82bf84b5dab3e17 (patch) | |
tree | 708777197e987074e04ede7e7a0e15c6d1ab68c8 | |
parent | c743276b8d64264e03d5c427de1d9208ebe6ebd2 (diff) |
Newton updates. Factor out get_external_net, etc.
JIRA: COPPER-4
Update for newton API/CLI changes.
Verify the test works under devstack as well as OPNFV.
Workaround bugs in OSC (openstack network show)
Change-Id: I5dc1c84f0f05daf1269212454aaecc284b4bd6fa
Signed-off-by: Bryan Sullivan <bryan.sullivan@att.com>
-rw-r--r-- | tests/dmz.sh | 26 | ||||
-rw-r--r-- | tests/get_external_net.sh | 48 |
2 files changed, 52 insertions, 22 deletions
diff --git a/tests/dmz.sh b/tests/dmz.sh index 5bf2ebd..1e70bae 100644 --- a/tests/dmz.sh +++ b/tests/dmz.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 2015-2016 AT&T Intellectual Property, Inc +# Copyright 2015-2017 AT&T Intellectual Property, Inc # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -34,6 +34,8 @@ # # After test, cleanup # $ bash dmz-clean.sh +trap 'fail' ERR + pass() { echo "Hooray!" set +x #echo off @@ -59,26 +61,6 @@ if [ $# -eq 1 ]; then fi fi -# Find external network if any, and details -function get_external_net () { - network_ids=($(neutron net-list|grep -v "+"|grep -v name|awk '{print $2}')) - for id in ${network_ids[@]}; do - [[ $(neutron net-show ${id}|grep 'router:external'|grep -i "true") != "" ]] && ext_net_id=${id} - done - if [[ $ext_net_id ]]; then - EXTERNAL_NETWORK_NAME=$(openstack network show $ext_net_id | awk "/ name / { print \$4 }") - EXTERNAL_SUBNET_ID=$(openstack network show $EXTERNAL_NETWORK_NAME | awk "/ subnets / { print \$4 }") - else - echo "External network not found" - echo "Create external network" - neutron net-create public --router:external - EXTERNAL_NETWORK_NAME="public" - echo "Create external subnet" - neutron subnet-create public 192.168.10.0/24 --name public --enable_dhcp=False --allocation_pool start=192.168.10.6,end=192.168.10.49 --gateway 192.168.10.1 - EXTERNAL_SUBNET_ID=$(openstack subnet show public | awk "/ id / { print \$4 }") - fi -} - echo "Create Congress policy 'test'" if [ $(openstack congress policy show test | awk "/ id / { print \$4 }") ]; then unclean; fi openstack congress policy create test @@ -105,7 +87,7 @@ IMAGE_ID=$(glance image-list | awk "/ cirros-0.3.3-x86_64-dmz / { print \$2 }") echo "Add 'dmz' image tag to the cirros dmz image" glance --os-image-api-version 2 image-tag-update $IMAGE_ID "dmz" -get_external_net +source $(dirname "$0")/get_external_net.sh echo "Create floating IP for external subnet" FLOATING_IP_ID=$(neutron floatingip-create $EXTERNAL_NETWORK_NAME | awk "/ id / { print \$4 }") diff --git a/tests/get_external_net.sh b/tests/get_external_net.sh new file mode 100644 index 0000000..10099ac --- /dev/null +++ b/tests/get_external_net.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# Copyright 2017 AT&T Intellectual Property, Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# What this is: An OpenStack client script to find the name of the external +# network, or create one if not found. +# +# Status: this is a work in progress, under test. +# +# Prequisite: +# - OpenStack CLI environment variables setup +# How to use: +# source get_external_net +# (sets two shell variables: EXTERNAL_NETWORK_NAME and EXTERNAL_SUBNET_ID) + + network_ids=($(neutron net-list|grep -v "+"|grep -v name|awk '{print $2}')) + for id in ${network_ids[@]}; do + [[ $(neutron net-show ${id}|grep 'router:external'|grep -i "true") != "" ]] && ext_net_id=${id} + done + if [[ $ext_net_id ]]; then +# Workaround for bug https://bugs.launchpad.net/manila/+bug/1652317 which +# blocks use of openstack network show +# EXTERNAL_NETWORK_NAME=$(openstack network show $ext_net_id | awk "/ name / { print \$4 }") +# EXTERNAL_SUBNET_ID=$(openstack network show $EXTERNAL_NETWORK_NAME | awk "/ subnets / { print \$4 }") + EXTERNAL_NETWORK_NAME=$(neutron net-show $ext_net_id | awk "/ name / { print \$4 }") + EXTERNAL_SUBNET_ID=$(neutron net-show $EXTERNAL_NETWORK_NAME | awk "/ subnets / { print \$4 }") + else + echo "External network not found" + echo "Create external network" + neutron net-create public --router:external + EXTERNAL_NETWORK_NAME="public" + echo "Create external subnet" + neutron subnet-create public 192.168.10.0/24 --name public --enable_dhcp=False --allocation_pool start=192.168.10.6,end=192.168.10.49 --gateway 192.168.10.1 + EXTERNAL_SUBNET_ID=$(openstack subnet show public | awk "/ id / { print \$4 }") + fi + |