From b01cd219b0aee55be2e18ef9b66cd58b2c89134a Mon Sep 17 00:00:00 2001 From: davidplunkett Date: Wed, 20 Nov 2019 18:37:46 +0000 Subject: [PATCH] add containerized openstack cli Signed-off-by: davidplunkett Change-Id: I046661f9cdd9b1784b6f5663670743b16ccc0025 --- tools/1prom-gen.sh | 2 ++ tools/2genesis.sh | 1 + tools/run_openstack_cli.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100755 tools/run_openstack_cli.sh diff --git a/tools/1prom-gen.sh b/tools/1prom-gen.sh index dfac5e6..0d00bb7 100755 --- a/tools/1prom-gen.sh +++ b/tools/1prom-gen.sh @@ -145,6 +145,8 @@ echo "# Copying scripts to $AIRSHIP_TREASUREMAP/${SITE}_bundle" cp $YAML_BUILDS/tools/cleanup.sh $AIRSHIP_TREASUREMAP/${SITE}_bundle cp $YAML_BUILDS/tools/openrc $AIRSHIP_TREASUREMAP/${SITE}_bundle + + cp $YAML_BUILDS/tools/run_openstack_cli.sh $AIRSHIP_TREASUREMAP/${SITE}_bundle ) ( diff --git a/tools/2genesis.sh b/tools/2genesis.sh index d602b93..70c3ba2 100755 --- a/tools/2genesis.sh +++ b/tools/2genesis.sh @@ -68,6 +68,7 @@ ssh $GENESIS_HOST << EOF mv configs/promenade-bundle/deploy_site.sh . mv configs/promenade-bundle/update_software.sh . mv configs/promenade-bundle/openrc . + cp configs/run_openstack_cli.sh /usr/local/bin/openstack EOF echo "# Waiting for BIOS updates to finish on master and worker nodes" diff --git a/tools/run_openstack_cli.sh b/tools/run_openstack_cli.sh new file mode 100755 index 0000000..daf8b26 --- /dev/null +++ b/tools/run_openstack_cli.sh @@ -0,0 +1,49 @@ +#!/bin/bash +# Copyright 2018-2019 AT&T Intellectual Property. All other rights reserved. +# +# 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. + +set -e + +# Define variables +COMMAND='openstack' +OPENSTACK_CLI_IMAGE="${OPENSTACK_CLI_IMAGE:-docker.io/openstackhelm/heat:ocata}" +NAMESPACE="${NAMESPACE:-openstack}" + +# Define Base Docker Command +base_docker_command=$(cat << EndOfCommand +sudo docker run -it --rm --net=host +-e http_proxy=${HTTP_PROXY} +-e https_proxy=${HTTPS_PROXY} +-e OS_AUTH_URL=${OS_AUTH_URL:-http://keystone.${NAMESPACE}.svc.cluster.local:80/v3} +-e OS_USERNAME=${OS_USERNAME:-admin} +-e OS_USER_DOMAIN_NAME=${OS_USER_DOMAIN_NAME:-default} +-e OS_PASSWORD=${OS_PASSWORD:-password123} +-e OS_PROJECT_DOMAIN_NAME=${OS_PROJECT_DOMAIN_NAME:-default} +-e OS_PROJECT_NAME=${OS_PROJECT_NAME:-admin} +-e OS_REGION_NAME=${OS_REGION_NAME:-RegionOne} +-e OS_IDENTITY_API_VERSION=${OS_IDENTITY_API_VERSION:-3} +-w /host/$(pwd) +-v /:/host:rshared +EndOfCommand +) + +# Warn about absolute references +if echo "$@" | grep ' /' ; then + echo "WARNING: Any absolute file references should start with /host// because openstack cli is running in a container" 1>&2 + echo "WARNING: For example: 'openstack image create --file /host/tmp/ubuntu.img ubuntu' would create a new image with the file /tmp/ubuntu.img" 1>&2 +fi + +# Execute OpenStack CLI +${base_docker_command} ${OPENSTACK_CLI_IMAGE} ${COMMAND} $@ + -- 2.16.6