summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Sullivan <bryan.sullivan@att.com>2018-02-06 20:49:10 -0500
committerBryan Sullivan <bryan.sullivan@att.com>2018-02-06 20:49:10 -0500
commitf0532d88072253ca9c5902f4cefcde61f8b0d787 (patch)
treeae80eaf3098212cbcd7d4a6274d6557fbc9c4a11
parent7e5a754211998b00023762b6ff90d70a501cdbd8 (diff)
Fix anteater issue with use of /tmp
JIRA: MODELS-2 Change-Id: Ia24b89710633191066a89c70b981486e71d6a5fd Signed-off-by: Bryan Sullivan <bryan.sullivan@att.com>
-rw-r--r--tests/utils/osclient.sh156
1 files changed, 68 insertions, 88 deletions
diff --git a/tests/utils/osclient.sh b/tests/utils/osclient.sh
index eab5b90..839aa29 100644
--- a/tests/utils/osclient.sh
+++ b/tests/utils/osclient.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2017 AT&T Intellectual Property, Inc
+# Copyright 2017-2018 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.
@@ -13,58 +13,56 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# What this is: Setup script for OpenStack Clients (OSC) running in
-# an Unbuntu Xenial docker container. You can use this script to isolate the
-# OSC from your host, so that the OSC and related install pre-reqs do not
-# pollute your host environment. You can then then modify your tests scripts on
-# your host and run them using the OSC container rather than moving the test
-# scripts to DevStack or an OpenStack installation (see below). You can also
-# attach to the OSC container. Enter "sudo docker attach osclient" then hit enter
-# twice and you will be in the container as root (there are no other users).
-# Once in the container, you can "source /tmp/osclient/admin-openrc.sh" and use
-# any OSC commands you want.
-#
-# Status: this is a work in progress, under test.
-#
-# How to use:
-# 1) Obtain the credential script for your OpenStack installation by logging
-# into the OpenStack Dashboard and downloading the OpenStack RD file from
-# Project -> Access & Security -> API Access
-# 2) Edit the *-openrc.sh file:
-# * remove the following lines:
-# echo "Please enter your OpenStack Password for project $OS_TENANT_NAME as user $OS_USERNAME: "
-# read -sr OS_PASSWORD_INPUT
-# * replace $OS_PASSWORD_INPUT with the password
-# 3) execute this command: $ bash osclient.sh setup <path to credential script> [branch]
-# * setup: install the OpenStack CLI clients in a container on the host.
-# * <path to credential script> location of the *-openrc.sh file you edited in step 2
-# * branch: git repo branch to install (e.g. stable/newton) OPTIONAL; if you want the master branch,
-# do not include this parameter
-# * Example:
-# If the admin-openrc.sh file is in the same directory as osclient.sh and you want to use stable/newton:
-# $ bash osclient.sh setup admin-openrc.sh stable/newton
-# If the admin-openrc.sh file is in a different directory and you want to use master:
-# $ bash osclient.sh setup ~/Downloads/admin-openrc.sh
-#
-# Once the Docker container has been created and is running, you can run your scripts
-# $ bash osclient.sh run <command>
-# * run: run a command in the container
-# * <command>: command to run, in quotes e.g.
-# bash osclient.sh run 'openstack service list'
-# bash osclient.sh run 'bash mytest.sh'
-# To run tests in the container:
-# 1) Copy the tests to the shared folder for the container (/tmp/osclient)
-# 2) Run your tests; for example, if you want to run Copper tests:
-# $ bash ~/git/models/tests/utils/osclient.sh run "bash /tmp/osclient/copper/tests/network_bridging.sh"
-# $ bash ~/git/models/tests/utils/osclient.sh run "bash /tmp/osclient/copper/tests/network_bridging-clean.sh"
-# 3) Due to a (?) Docker quirk, you need to remove and re-copy the tests each time you change them, e.g. as you edit the tests during development
-# $ rm -rf /tmp/osclient/copper/tests/; cp -R ~/git/copper/tests/ /tmp/osclient/copper/tests/
-#
-# To stop and then remove the Docker container
-# $ bash osclient.sh clean
-# * clean: remove the osclient container and shared folder
-# Note: you may have to run as sudo in order to delete the files in /tmp/osclient
-
+#.What this is: Setup script for OpenStack Clients (OSC) running in
+#.an Unbuntu Xenial docker container. You can use this script to isolate the
+#.OSC from your host, so that the OSC and related install pre-reqs do not
+#.pollute your host environment. You can then then modify your tests scripts on
+#.your host and run them using the OSC container rather than moving the test
+#.scripts to DevStack or an OpenStack installation (see below). You can also
+#.attach to the OSC container. Enter "sudo docker attach osclient" then hit enter
+#.twice and you will be in the container as root (there are no other users).
+#.Once in the container, you can "source ~/admin-openrc.sh" and use
+#.any OSC commands you want.
+#.
+#.Status: this is a work in progress, under test.
+#.
+#.How to use:
+#. 1) Obtain the credential script for your OpenStack installation by logging
+#. into the OpenStack Dashboard and downloading the OpenStack RD file from
+#. Project -> Access & Security -> API Access
+#. 2) Edit the *-openrc.sh file:
+#. * remove the following lines:
+#. echo "Please enter your OpenStack Password for project $OS_TENANT_NAME as user $OS_USERNAME: "
+#. read -sr OS_PASSWORD_INPUT
+#. * replace $OS_PASSWORD_INPUT with the password
+#. 3) execute this command: $ bash osclient.sh setup <path to credential script> [branch]
+#. * setup: install the OpenStack CLI clients in a container on the host.
+#. * <path to credential script> location of the *-openrc.sh file you edited in step 2
+#. * branch: git repo branch to install (e.g. stable/newton) OPTIONAL; if you want the master branch,
+#. do not include this parameter
+#. * Example:
+#. If the admin-openrc.sh file is in the same directory as osclient.sh and you want to use stable/newton:
+#. $ bash osclient.sh setup admin-openrc.sh stable/newton
+#. If the admin-openrc.sh file is in a different directory and you want to use master:
+#. $ bash osclient.sh setup ~/Downloads/admin-openrc.sh
+#.
+#.Once the Docker container has been created and is running, you can run your scripts
+#. $ bash osclient.sh run <command>
+#. * run: run a command in the container
+#. * <command>: command to run, in quotes e.g.
+#. bash osclient.sh run 'openstack service list'
+#. bash osclient.sh run 'bash mytest.sh'
+#.To run tests in the container:
+#. 1) Copy the tests to the shared folder for the container (/home/ubuntu)
+#. 2) Run your tests; for example, if you want to run Copper tests:
+#. $ bash ~/git/models/tests/utils/osclient.sh run "bash copper/tests/network_bridging.sh"
+#. $ bash ~/git/models/tests/utils/osclient.sh run "bash copper/tests/network_bridging-clean.sh"
+#. 3) Due to a (?) Docker quirk, you need to remove and re-copy the tests each time you change them, e.g. as you edit the tests during development
+#. $ rm -rf ~/tmp/osclient/copper/tests/; cp -R ~/git/copper/tests/ ~/tmp/osclient/copper/tests/
+#.
+#.To stop and then remove the Docker container
+#. $ bash osclient.sh clean
+#. * clean: remove the osclient container and shared folder
trap 'fail' ERR
@@ -103,10 +101,10 @@ function create_container() {
# xenial is needed for python 3.5
sudo docker pull ubuntu:xenial
sudo service docker start
- sudo docker run -i -t -d -v /tmp/osclient/:/tmp/osclient --name osclient \
+ sudo docker run -i -t -d -v ~/tmp/osclient/:/home/ubuntu/ --name osclient \
ubuntu:xenial /bin/bash
- sudo docker exec osclient /bin/bash /tmp/osclient/osclient-setup.sh \
- setup /tmp/osclient/admin-openrc.sh $branch
+ sudo docker exec osclient /bin/bash osclient-setup.sh \
+ setup admin-openrc.sh $branch
else
# Centos
echo "Centos-based install"
@@ -122,10 +120,10 @@ EOF
# xenial is needed for python 3.5
sudo service docker start
sudo docker pull ubuntu:xenial
- sudo docker run -i -t -d -v /tmp/osclient/:/tmp/osclient --name osclient \
+ sudo docker run -i -t -d -v ~/tmp/osclient/:/home/ubuntu/ --name osclient \
ubuntu:xenial /bin/bash
- sudo docker exec osclient /bin/bash /tmp/osclient/osclient-setup.sh setup \
- /tmp/osclient/admin-openrc.sh $branch
+ sudo docker exec osclient /bin/bash osclient-setup.sh setup \
+ admin-openrc.sh $branch
fi
}
@@ -150,7 +148,7 @@ function setup () {
apt-get install -y libffi-dev
apt-get install -y libssl-dev
- cd /tmp/osclient
+ cd ~
echo "$0: $(date) Upgrage pip"
pip install --upgrade pip
@@ -181,47 +179,29 @@ case "$1" in
setup $openrc $branch
else
echo "$0: $(date) Setup shared virtual folder and save $1 script there"
- if [[ ! -d /tmp/osclient ]]; then mkdir /tmp/osclient; fi
- cp $0 /tmp/osclient/osclient-setup.sh
- cp $openrc /tmp/osclient/admin-openrc.sh
- chmod 755 /tmp/osclient/*.sh
+ if [[ ! -d ~/tmp/osclient ]]; then mkdir ~/tmp/osclient; fi
+ cp $0 ~/tmp/osclient/osclient-setup.sh
+ cp $openrc ~/tmp/osclient/admin-openrc.sh
+ chmod 755 ~/tmp/osclient/*.sh
create_container
fi
pass
;;
run)
- cat >/tmp/osclient/command.sh <<EOF
-source /tmp/osclient/admin-openrc.sh
+ cat >~/tmp/osclient/command.sh <<EOF
+source admin-openrc.sh
$2
exit
EOF
- sudo docker exec osclient /bin/bash /tmp/osclient/command.sh "$0"
+ sudo docker exec osclient /bin/bash command.sh "$0"
;;
clean)
sudo docker stop osclient
sudo docker rm -v osclient
- rm -rf /tmp/osclient
+ rm -rf ~/tmp/osclient
pass
;;
*)
-echo " $ bash osclient.sh setup|run|clean (see detailed parameters below)"
-echo " setup: install the OpenStack CLI clients in a container on the host."
-echo " $ bash osclient.sh setup <path to credential script> [branch]"
-echo " <path to credential script>: OpenStack CLI env setup script (e.g."
-echo " admin-openrc.sh), obtained from the OpenStack Dashboard via"
-echo " Project->Access->Security->API. It's also recommended that you set the"
-echo " OpenStack password explicitly in that script rather than take the"
-echo " default which will prompt you on every command you pass to the container."
-echo " For example, if the admin-openrc.sh file is in the same directory as "
-echo " osclient.sh and you want to use stable/newton:"
-echo " $ bash osclient.sh setup admin-openrc.sh stable/newton"
-echo " branch: git repo branch to install (e.g. stable/newton)"
-echo " run: run a command in the container"
-echo " $ bash osclient.sh run <command>"
-echo " <command>: command to run, in quotes e.g."
-echo " bash osclient.sh run 'openstack service list'"
-echo " bash osclient.sh run 'bash mytest.sh'"
-echo " clean: remove the osclient container and shared folder"
-echo " $ bash osclient.sh clean"
-fail
+ grep '#. ' $0
+ ;;
esac