Add OpenStack CLI Wrapper

We will add scripts that will allow us to execute OpenStack CLI.

Sample example will be:

./run_openstack_cli.sh server list

Change-Id: I2fc1fee2686fa241e289906439265a1c017a5871
This commit is contained in:
anthony.lin 2018-05-19 02:32:30 +08:00
parent 5ea39da4dc
commit a989649ec0
2 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,39 @@
#!/bin/bash
# Copyright 2018 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
#
# NOTE: User will need to set up the required environment variables
# before executing this script if they differ from the default values.
#
NAMESPACE="${NAMESPACE:-openstack}"
# Define Base Docker Command
base_docker_command=$(cat << EndOfCommand
sudo docker run -t --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:-password}
-e OS_PROJECT_DOMAIN_NAME=${OS_PROJECT_DOMAIN_NAME:-default}
-e OS_PROJECT_NAME=${OS_PROJECT_NAME:-service}
-e OS_REGION_NAME=${OS_REGION_NAME:-RegionOne}
-e OS_IDENTITY_API_VERSION=${OS_IDENTITY_API_VERSION:-3}
EndOfCommand
)

28
tools/run_openstack_cli.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
# Copyright 2018 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:newton}"
# Get the path of the directory where the script is located
# Source Base Docker Command
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd ${DIR} && source openstack_cli_docker_base_command.sh
# Execute OpenStack CLI
${base_docker_command} ${OPENSTACK_CLI_IMAGE} ${COMMAND} $@