X-Git-Url: https://gerrit.akraino.org/r/gitweb?p=ci-management.git;a=blobdiff_plain;f=jjb%2Fshell%2Frun_bluval.sh;h=844c6110e81fa75daa9a2a1d8efe0886a323e1f9;hp=de42ca0a948fb95e602a827c70bd43efa99e3da2;hb=28f5a48f1d4d9ec4f3ac4cf0703b70c7b58f5a13;hpb=6f520e2f6db64306a799ab659e60e07a9e3cff2d diff --git a/jjb/shell/run_bluval.sh b/jjb/shell/run_bluval.sh index de42ca0..844c611 100755 --- a/jjb/shell/run_bluval.sh +++ b/jjb/shell/run_bluval.sh @@ -37,7 +37,7 @@ usage() { echo "[-n ">&2 echo "[-b blueprint definition">&2 echo "[-k k8s config dir">&2 - echo "[-j k8s master">&2 + echo "[-j cluster master IP">&2 echo "[-u ssh user">&2 echo "[-s ] path to ssh key">&2 echo "[-c ] path to variables yaml file">&2 @@ -67,7 +67,7 @@ error () { # Get options from shell while getopts "j:k:u:s:b:l:r:n:ov:" optchar; do case "${optchar}" in - j) k8s_master=${OPTARG} ;; + j) cluster_master_ip=${OPTARG} ;; k) k8s_config_dir=${OPTARG} ;; s) ssh_key=${OPTARG} ;; b) blueprint_yaml=${OPTARG} ;; @@ -95,7 +95,7 @@ fi input="$cwd/kube" # Initialize ssh key used -ssh_key=${ssh_key:-$K8S_SSH_KEY} +ssh_key=${ssh_key:-$CLUSTER_SSH_KEY} # K8s config directory k8s_config_dir=${k8s_config_dir:-$input} mkdir -p "$k8s_config_dir" @@ -103,26 +103,25 @@ mkdir -p "$k8s_config_dir" # Testing configuration version=${version:-$VERSION} results_dir=$cwd/results -k8s_master=${k8s_master:-$K8S_MASTER_IP} -ssh_user=${sh_user:-$K8S_SSH_USER} +cluster_master_ip=${cluster_master_ip:-$CLUSTER_MASTER_IP} +ssh_user=${sh_user:-$CLUSTER_SSH_USER} blueprint_layer=${blueprint_layer:-$LAYER} -# If blueprint layer is not defined use k8s by default -if [ "$blueprint_layer" == "k8s" ] +if [ "$blueprint_layer" == "k8s" ] || [ -z "$blueprint_layer" ] then - if [ -z "$k8s_master" ] + if [ -z "$cluster_master_ip" ] then usage - error "Please provide valid k8s IP address." + error "Please provide valid IP address to access the k8s cluster." fi - verify_connectivity "${k8s_master}" - if [[ -n $K8S_SSH_PASSWORD ]] + verify_connectivity "${cluster_master_ip}" + if [[ -n $CLUSTER_SSH_PASSWORD ]] then - sshpass -p "${K8S_SSH_PASSWORD}" scp -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -r\ - "${ssh_user}@${k8s_master}:~/.kube/*" "$k8s_config_dir" + sshpass -p "${CLUSTER_SSH_PASSWORD}" scp -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -r\ + "${ssh_user}@${cluster_master_ip}:~/.kube/*" "$k8s_config_dir" else scp -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -i"$ssh_key" -r\ - "${ssh_user}"@"${k8s_master}":~/.kube/* "$k8s_config_dir" + "${ssh_user}"@"${cluster_master_ip}":~/.kube/* "$k8s_config_dir" fi fi @@ -132,8 +131,27 @@ then fi volumes_path="$cwd/bluval/volumes.yaml" -#update information in volumes yaml -sed -i -e "/kube_config_dir/{n; s@local: ''@local: '$k8s_config_dir'@}" -e "/blueprint_dir/{n; s@local: ''@local: '$cwd/bluval/'@}" -e "/results_dir/{n; s@local: ''@local: '$results_dir'@}" "$volumes_path" +# update information in volumes yaml +sed -i \ + -e "/ssh_key_dir/{n; s@local: ''@local: '$cwd/ssh_key_dir'@}" \ + -e "/kube_config_dir/{n; s@local: ''@local: '$k8s_config_dir'@}" \ + -e "/custom_variables_file/{n; s@local: ''@local: '$cwd/tests/variables.yaml'@}" \ + -e "/blueprint_dir/{n; s@local: ''@local: '$cwd/bluval/'@}" \ + -e "/results_dir/{n; s@local: ''@local: '$results_dir'@}" \ + "$volumes_path" + +# create ssh_key_dir +mkdir -p $cwd/ssh_key_dir + +# copy ssh_key in ssh_key_dir +cp $ssh_key $cwd/ssh_key_dir/id_rsa + +variables_path="$cwd/tests/variables.yaml" +# update information in variables yaml +sed -i \ + -e "s@host: [0-9]*.[0-9]*.[0-9]*.[0-9]*@host: $cluster_master_ip@" \ + -e "s@username: [A-Za-z0-9_]* @username: $ssh_user@" \ + "$variables_path" if [[ -n $blueprint_layer ]] then @@ -144,8 +162,6 @@ then options+=" -o" fi -printf 'ok / PASS /\nerror / FAIL /\n' > ./bluval/rules.txt - set +e # even if the script fails we need to change the owner of results # shellcheck disable=SC2086