summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorLinda Wang <wangwulin@huawei.com>2018-01-25 04:15:51 +0000
committerLinda Wang <wangwulin@huawei.com>2018-02-01 12:41:47 +0000
commit5203913e8e39ad20c26dee453a0217bcba902785 (patch)
tree4b159a320a8e0ed321096690e0ba7d788040b02b /utils
parent280ae93b3d91bbd84db9b7aa20f7f5513b8afd7e (diff)
[Functest] Run k8s tests on Compass
Change-Id: I8e88ab0598f43be8d0c9c4ad199dba91c1561f13 Signed-off-by: Linda Wang <wangwulin@huawei.com>
Diffstat (limited to 'utils')
-rwxr-xr-xutils/fetch_k8_conf.sh63
1 files changed, 63 insertions, 0 deletions
diff --git a/utils/fetch_k8_conf.sh b/utils/fetch_k8_conf.sh
new file mode 100755
index 000000000..f82fa5497
--- /dev/null
+++ b/utils/fetch_k8_conf.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+##############################################################################
+# Copyright (c) 2018 Huawei and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+set -o errexit
+set -o nounset
+set -o pipefail
+
+info () {
+ logger -s -t "fetch_k8_conf.info" "$*"
+}
+
+
+error () {
+ logger -s -t "fetch_k8_conf.error" "$*"
+ exit 1
+}
+
+: ${DEPLOY_TYPE:=''}
+
+#Get options
+while getopts ":d:i:a:h:s:o:v" optchar; do
+ case "${optchar}" in
+ d) dest_path=${OPTARG} ;;
+ i) installer_type=${OPTARG} ;;
+ v) DEPLOY_TYPE="virt" ;;
+ *) echo "Non-option argument: '-${OPTARG}'" >&2
+ usage
+ exit 2
+ ;;
+ esac
+done
+
+# set vars from env if not provided by user as options
+dest_path=${dest_path:-$HOME/admin.conf}
+installer_type=${installer_type:-$INSTALLER_TYPE}
+
+if [ -z $dest_path ] || [ -z $installer_type ]; then
+ usage
+ exit 2
+fi
+
+# Checking if destination path is valid
+if [ -d $dest_path ]; then
+ error "Please provide the full destination path for the credentials file including the filename"
+else
+ # Check if we can create the file (e.g. path is correct)
+ touch $dest_path || error "Cannot create the file specified. Check that the path is correct and run the script again."
+fi
+
+info "Fetching admin.conf file..."
+if [ "$installer_type" == "compass" ]; then
+ sudo docker cp compass-tasks:/opt/admin.conf $dest_path &> /dev/null
+ sudo chown $(whoami):$(whoami) $dest_path
+ info "Fetch admin.conf successfully"
+else
+ error "Installer $installer is not supported by this script"
+fi
+