Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 1 | ### initial folders |
| 2 | function ewriteln() { |
| 3 | echo ${1} | tee -a $MY_PROJFOLDER/env.sh |
| 4 | } |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 5 | function qkeystone() { |
| 6 | keystone_pod=$(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml get pod -n openstack -o=custom-columns=NAME:.metadata.name | grep keystone-client) |
| 7 | # echo "# Running 'kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec {} -c keystone-client --stdin -- "${1}"'" |
| 8 | kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec ${keystone_pod} -c keystone-client --stdin -- '${1}' |
| 9 | } |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 10 | |
| 11 | export MY_PROJFOLDER=/artifacts |
| 12 | echo "# Using folder '$MY_PROJFOLDER'" |
| 13 | cd $MY_PROJFOLDER |
Alex | 2c8b880 | 2022-10-20 14:07:15 -0500 | [diff] [blame] | 14 | [ ! -d envs ] && mkdir envs |
| 15 | [ ! -d yamls ] && mkdir yamls |
| 16 | [ ! -d reports ] && mkdir reports |
| 17 | [ ! -d tmp ] && mkdir tmp |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 18 | |
| 19 | # move mcc konfig to default place |
| 20 | if [ -f $MY_PROJFOLDER/mcc-kubeconfig.yaml ]; then |
| 21 | mv $MY_PROJFOLDER/mcc-kubeconfig.yaml $MY_PROJFOLDER/envs/mcc-kubeconfig.yaml |
| 22 | fi |
Alex | 2c8b880 | 2022-10-20 14:07:15 -0500 | [diff] [blame] | 23 | if [ -f $MY_PROJFOLDER/node.key ]; then |
| 24 | mv $MY_PROJFOLDER/node.key $MY_PROJFOLDER/envs/node.key |
| 25 | fi |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 26 | if [ ! -f $MY_PROJFOLDER/envs/mcc-kubeconfig.yaml ]; then |
| 27 | echo "ERROR: MCC kubeconfig not found either at '$MY_PROJFOLDER/mcc-kubeconfig.yaml' or '$MY_PROJFOLDER/envs/mcc-kubeconfig.yaml'" |
Alex | 2c8b880 | 2022-10-20 14:07:15 -0500 | [diff] [blame] | 28 | exit 1 |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 29 | fi |
| 30 | echo " " |
| 31 | |
| 32 | ### prepare needed variables |
| 33 | echo "# Updating '$MY_PROJFOLDER/env.sh'" |
Alex | f7f0a15 | 2022-10-10 16:17:32 -0500 | [diff] [blame] | 34 | |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 35 | export KUBECONFIG=$MY_PROJFOLDER/envs/mcc-kubeconfig.yaml |
| 36 | if [ ! -f $MY_PROJFOLDER/env.sh ]; then |
| 37 | touch $MY_PROJFOLDER/env.sh |
| 38 | else |
| 39 | truncate -s 0 $MY_PROJFOLDER/env.sh |
| 40 | echo "$MY_PROJFOLDER/env.sh has been truncated" |
| 41 | fi |
Alex | f7f0a15 | 2022-10-10 16:17:32 -0500 | [diff] [blame] | 42 | ewriteln "export MY_CLIENTNAME='ClientName'" |
| 43 | ewriteln "export MY_CLIENTSHORTNAME='clname'" |
| 44 | ewriteln "export MY_PROJNAME='MOS_DEPLOY'" |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 45 | ewriteln "export MY_PROJFOLDER=/artifacts" |
Alex | f7f0a15 | 2022-10-10 16:17:32 -0500 | [diff] [blame] | 46 | |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 47 | # NS & CLUSTER |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 48 | printf "\n\n# Getting namespace and cluster" |
| 49 | nn=( $(kubectl get cluster -A --no-headers -o=custom-columns=NAME:.metadata.name,NAMESPACE:.metadata.namespace | grep -v default) ) |
| 50 | echo "# Extracted data: '${nn[@]}'" |
Alex | d1ac226 | 2023-03-31 13:53:33 -0500 | [diff] [blame] | 51 | vNS="${nn[1]}" |
| 52 | vCLUSTER="${nn[0]}" |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 53 | ewriteln "export MOS_NS=${vNS}" |
| 54 | ewriteln "export MOS_CLUSTER=${vCLUSTER}" |
| 55 | echo "# Extracted NS: '${vNS}'" |
| 56 | echo "# Extracted CLUSTER: '${vCLUSTER}'" |
| 57 | |
| 58 | printf "\n\n# Writing additional options" |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 59 | ewriteln "export SI_BINARIES_DIR=$(which helm | rev | cut -d'/' -f2- | rev)" |
| 60 | ewriteln "export HELM_BINARY_PATH=$(which helm)" |
Alex | 876e93a | 2022-12-21 12:02:13 -0600 | [diff] [blame] | 61 | ewriteln "export K8S_CONFORMANCE_CONCURRENCY=10" |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 62 | |
| 63 | # extract MOS kubeconfig |
| 64 | echo " " |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 65 | printf "\n\nExtracting mos-kubeconfig.yaml" |
| 66 | if [[ ! -z ${vCLUSTER+x} ]]; then |
| 67 | kubectl --kubeconfig $MY_PROJFOLDER/envs/mcc-kubeconfig.yaml -n ${vNS} get secrets ${vCLUSTER}-kubeconfig -o jsonpath='{.data.admin\.conf}' | base64 -d | sed 's/:5443/:443/g' | tee $MY_PROJFOLDER/envs/mos-kubeconfig.yaml |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 68 | else |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 69 | echo "MOS_CLUSTER variable empty/invalid: '${vCLUSTER}'" |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 70 | fi |
| 71 | |
| 72 | # generate additional files |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 73 | printf "\n\nPreparing additional files" |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 74 | # copy files |
| 75 | cp -v /opt/res-files/k8s/workspace/* $MY_PROJFOLDER/envs/ |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 76 | [ ! -d $MY_PROJFOLDER/scripts ] && mkdir $MY_PROJFOLDER/scripts |
| 77 | mv -v $MY_PROJFOLDER/envs/*.sh $MY_PROJFOLDER/scripts/ |
Alex | 2c8b880 | 2022-10-20 14:07:15 -0500 | [diff] [blame] | 78 | |
| 79 | cp -v /opt/res-files/k8s/yamls/qa-rally.yaml $MY_PROJFOLDER/yamls |
| 80 | cp -v /opt/res-files/k8s/yamls/qa-res.yaml $MY_PROJFOLDER/yamls |
| 81 | cp -v /opt/res-files/k8s/yamls/qa-toolset-bare.yaml $MY_PROJFOLDER/yamls |
| 82 | cp -v /opt/res-files/k8s/yamls/qa-toolset.yaml $MY_PROJFOLDER/yamls |
| 83 | |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 84 | # remove duplicate init |
| 85 | rm -v $MY_PROJFOLDER/scripts/init-workspace.sh |
Alex | f7f0a15 | 2022-10-10 16:17:32 -0500 | [diff] [blame] | 86 | # update IP Addresses |
| 87 | mccip=$(cat $MY_PROJFOLDER/envs/mcc-kubeconfig.yaml | grep server | cut -d':' -f3 | cut -d'/' -f3) |
| 88 | echo "-> MCC Server IP is: ${mccip}" |
| 89 | sed -i "s/ip_address/$mccip/g" $MY_PROJFOLDER/envs/mcc-checker.env |
| 90 | |
| 91 | if [ -f $MY_PROJFOLDER/envs/mos-kubeconfig.yaml ]; then |
| 92 | mosip=$(cat $MY_PROJFOLDER/envs/mos-kubeconfig.yaml | grep server | cut -d':' -f3 | cut -d'/' -f3) |
| 93 | echo "-> MOS Server IP is: ${mosip}" |
| 94 | sed -i "s/ip_address/$mosip/g" $MY_PROJFOLDER/envs/mos-checker.env |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 95 | |
| 96 | vSC="$(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml get sc | grep default | cut -d' ' -f1)" |
| 97 | echo "-> Storage class is ${vSC}" |
| 98 | echo "# Updating resources yaml " |
| 99 | sed -i "s/storage_class/${vSC}/g" $MY_PROJFOLDER/yamls/qa-res.yaml |
| 100 | echo " " |
| 101 | ewriteln "export MOS_SC=${vSC}" |
| 102 | |
| 103 | ewriteln "export OSH_DEPLOYMENT_NAME=$(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack get openstackdeployment --no-headers | cut -d' ' -f1)" |
| 104 | ewriteln "export SI_BINARIES_DIR=$(which helm | rev | cut -d'/' -f2- | rev)" |
| 105 | ewriteln "export HELM_BINARY_PATH=$(which helm)" |
| 106 | |
| 107 | echo " " |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 108 | keystone_pod=$(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml get pod -n openstack -o=custom-columns=NAME:.metadata.name | grep keystone-client) |
Ievgeniia Zadorozhna | bbe0f44 | 2024-01-22 23:59:05 +0100 | [diff] [blame^] | 109 | echo "# Extracting network: taking the first found external network" |
| 110 | cmd="openstack network list --external -c Name -f value | head -n1" |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 111 | echo "# Running 'kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec ${keystone_pod} -c keystone-client --stdin -- "${cmd}"'" |
| 112 | vPUBNET=$(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec ${keystone_pod} -c keystone-client --stdin -- ${cmd}) |
Ievgeniia Zadorozhna | bbe0f44 | 2024-01-22 23:59:05 +0100 | [diff] [blame^] | 113 | echo "-> 'openstack network list --external -c Name -f value | head -n1': '${vPUBNET}'" |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 114 | ewriteln "export TEMPEST_CUSTOM_PUBLIC_NET=${vPUBNET}" |
Alex | 3594573 | 2023-04-07 10:03:59 -0500 | [diff] [blame] | 115 | |
| 116 | echo "# Extracting volume types" |
| 117 | cmd_all="openstack volume type list -f value -c Name" |
| 118 | vVOLTYPES=( $(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec ${keystone_pod} -c keystone-client --stdin -- ${cmd_all}) ) |
| 119 | echo "# Volume types available: ${vVOLTYPES[@]}" |
| 120 | cmd_default="openstack volume type list -f value -c Name --default" |
| 121 | vVOLTYPE=$(kubectl --kubeconfig $MY_PROJFOLDER/envs/mos-kubeconfig.yaml -n openstack exec ${keystone_pod} -c keystone-client --stdin -- ${cmd_default}) |
| 122 | echo "# Default volume type used: ${vVOLTYPE}" |
| 123 | ewriteln "export TEMPEST_CUSTOM_VOLUME_TYPE=${vVOLTYPE}" |
| 124 | # hardcoded values |
Alex | 876e93a | 2022-12-21 12:02:13 -0600 | [diff] [blame] | 125 | ewriteln "export TEMPEST_CUSTOM_FLAVOR=cvp.tiny" |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 126 | ewriteln "export TEMPEST_CUSTOM_IMAGE=cvp.cirros.51" |
| 127 | ewriteln "export TEMPEST_CUSTOM_IMAGE_ALT=cvp.cirros.52" |
Alex | f7f0a15 | 2022-10-10 16:17:32 -0500 | [diff] [blame] | 128 | #prepare tempest custom yaml |
| 129 | cp /opt/res-files/k8s/yamls/tempest_custom.yaml.clean $MY_PROJFOLDER/yamls/tempest_custom.yaml |
| 130 | ewriteln 'export TEMPEST_CUSTOM_PARAMETERS=$(cat $MY_PROJFOLDER/yamls/tempest_custom.yaml)' |
| 131 | fi |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 132 | |
Alex | a0053b9 | 2022-10-14 16:38:28 -0500 | [diff] [blame] | 133 | # Aliases |
| 134 | ewriteln 'alias k=kubectl' |
| 135 | |
Alex | e67127e | 2022-10-03 14:42:30 -0500 | [diff] [blame] | 136 | # end |
| 137 | echo " " |
| 138 | echo "# Done!" |