summaryrefslogtreecommitdiffstats
path: root/tests/get_external_net.sh
diff options
context:
space:
mode:
authorBryan Sullivan <bryan.sullivan@att.com>2017-01-16 13:04:02 -0800
committerBryan Sullivan <bryan.sullivan@att.com>2017-01-16 13:04:02 -0800
commitba748f15768078419346c620f82bf84b5dab3e17 (patch)
tree708777197e987074e04ede7e7a0e15c6d1ab68c8 /tests/get_external_net.sh
parentc743276b8d64264e03d5c427de1d9208ebe6ebd2 (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>
Diffstat (limited to 'tests/get_external_net.sh')
-rw-r--r--tests/get_external_net.sh48
1 files changed, 48 insertions, 0 deletions
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
+