diff --git a/common/generate_bundle_base b/common/generate_bundle_base index 8b7e1090..4688c0ba 100644 --- a/common/generate_bundle_base +++ b/common/generate_bundle_base @@ -137,7 +137,9 @@ if ((${#MOD_OVERLAYS[@]})); then unset subdir fi cp $MOD_DIR/overlays/$overlay $bundles_dir/o/${subdir:-""} - ((${#overlay_opts[@]}==0)) && overlay_opts+=("") # left padding + if ((${#overlay_opts[@]}==0)); then + overlay_opts+=("") # left padding + fi overlay_opts+=( --overlay $bundles_dir/o/$overlay ) overlay_list+=( "$bundles_dir/o/$overlay" ) render $bundles_dir/o/$overlay @@ -223,7 +225,9 @@ if ${MASTER_OPTS[HYPERCONVERGED_DEPLOYMENT]}; then xargs -l sed -i -r "/^\s+charm:.+/a$bindings" fi -((${#overlay_opts[@]})) && overlay_opts+=("") # right padding +if ((${#overlay_opts[@]})); then + overlay_opts+=("") # right padding +fi echo -e "juju deploy${JUJU_DEPLOY_OPTS} \ ${base_bundle}${overlay_opts[@]:- }\n " > ${bundles_dir}/command diff --git a/openstack/tools/allocate_vips.sh b/openstack/tools/allocate_vips.sh index efe9677c..814473e8 100644 --- a/openstack/tools/allocate_vips.sh +++ b/openstack/tools/allocate_vips.sh @@ -16,10 +16,9 @@ net_pre=$(echo $cidr| sed -r 's/([0-9]+\.[0-9]+\.[0-9]+).+/\1/g') j=1 -for i in $(seq ${vip_start_suffix} ${net_end}) -do +for i in $(seq ${vip_start_suffix} ${net_end}); do echo openstack port create --network net_${OS_USERNAME}-psd \ --fixed-ip subnet=subnet_${OS_USERNAME}-psd,ip-address=${net_pre}.$i \ --disable --os-cloud ps6 ps6-vip-ip$( printf "%02d" $j ) - ((j++)) -done + j=$((j+1)) +done \ No newline at end of file diff --git a/openstack/tools/charmed_openstack_functest_runner.sh b/openstack/tools/charmed_openstack_functest_runner.sh index b3acba1b..9845f5b6 100755 --- a/openstack/tools/charmed_openstack_functest_runner.sh +++ b/openstack/tools/charmed_openstack_functest_runner.sh @@ -47,38 +47,37 @@ OPTIONS: EOF } -while (($# > 0)) -do +while (($# > 0)); do case "$1" in --debug) - set -x - ;; + set -x + ;; --func-test-target) - FUNC_TEST_TARGET=$2 - shift - ;; + FUNC_TEST_TARGET=$2 + shift + ;; --func-test-pr) - FUNC_TEST_PR=$2 - shift - ;; + FUNC_TEST_PR=$2 + shift + ;; --no-wait) - WAIT_ON_DESTROY=false - ;; + WAIT_ON_DESTROY=false + ;; --skip-modify-bundle-constraints) - MODIFY_BUNDLE_CONSTRAINTS=false - ;; + MODIFY_BUNDLE_CONSTRAINTS=false + ;; --skip-build) - SKIP_BUILD=true - ;; + SKIP_BUILD=true + ;; --help|-h) - usage - exit 0 - ;; + usage + exit 0 + ;; *) - echo "ERROR: invalid input '$1'" - usage - exit 1 - ;; + echo "ERROR: invalid input '$1'" + usage + exit 1 + ;; esac shift done diff --git a/openstack/tools/create_ipv4_octavia.sh b/openstack/tools/create_ipv4_octavia.sh index 063179c2..0f3803e3 100755 --- a/openstack/tools/create_ipv4_octavia.sh +++ b/openstack/tools/create_ipv4_octavia.sh @@ -6,8 +6,8 @@ set -u -e -x while true; do [[ `juju status keystone --format json | jq -r '.applications.keystone.units."keystone/0"."workload-status".current'` = active ]] \ && break - if [[ `juju status keystone --format json | jq -r '.applications.keystone.units."keystone/0"."workload-status".current'` = error ]] - then + if [[ `juju status keystone --format json | \ + jq -r '.applications.keystone.units."keystone/0"."workload-status".current'` = error ]]; then echo "ERROR: Octavia deployment failed" break fi diff --git a/openstack/tools/create_nova_az_aggregates.sh b/openstack/tools/create_nova_az_aggregates.sh index 654ee817..cc08cd68 100755 --- a/openstack/tools/create_nova_az_aggregates.sh +++ b/openstack/tools/create_nova_az_aggregates.sh @@ -2,7 +2,9 @@ for az in az1 az2; do readarray ids<<<"`juju status nova-compute-$az --format=yaml| grep instance-id| awk '{print $2}'`" machines=() - for id in ${ids[@]}; do machines+=( `source ~/novarc; openstack server show $id| grep " name "| awk '{print $4}'` ); done + for id in ${ids[@]}; do + machines+=( `source ~/novarc; openstack server show $id| grep " name "| awk '{print $4}'` ) + done echo "Creating aggregate ${az^^}" openstack aggregate show ${az^^} &>/dev/null || openstack aggregate create --zone $az ${az^^}; for m in ${machines[@]}; do diff --git a/openstack/tools/create_octavia_lb.sh b/openstack/tools/create_octavia_lb.sh index 56e1d3ee..e4345fe9 100755 --- a/openstack/tools/create_octavia_lb.sh +++ b/openstack/tools/create_octavia_lb.sh @@ -54,9 +54,9 @@ while (( $# > 0 )); do echo "missing protocol for healthmonitor" exit 1 fi - hm_protocol=$2 - shift - ;; + hm_protocol=$2 + shift + ;; -h|--help) cat < sp-metadata.json @@ -60,14 +60,14 @@ if [ $JUJU_VERSION -eq 2 ]; then cat sp-metadata.json | jq -r '."unit-keystone-saml-mellon-0".results.output' > sp-metadata.xml else cat sp-metadata.json | jq -r '."keystone-saml-mellon/0".results.output' > sp-metadata.xml -fi +fi juju attach-resource test-saml-idp1 sp-metadata=./sp-metadata.xml status='foo' while [[ $status != 'active' ]]; do - sleep 3 - status=$(juju status test-saml-idp1 --format json | jq -r '."applications"."test-saml-idp1"."application-status"."current"') + sleep 3 + status=$(juju status test-saml-idp1 --format json | jq -r '."applications"."test-saml-idp1"."application-status"."current"') done ENTITY_ID=$(egrep -o "entityID=\"(.*)\"" idp-metadata.xml | cut -d "=" -f2 | cut -d '"' -f2) diff --git a/openstack/tools/float_all.sh b/openstack/tools/float_all.sh index e40ef704..0a1cd5ae 100755 --- a/openstack/tools/float_all.sh +++ b/openstack/tools/float_all.sh @@ -4,7 +4,7 @@ echo " + Floating all instances." -function get_ip_f() { +function get_ip_f { # Get first unallocated floating IP openstack floating ip list | awk '/None/ { print $4; exit }' } diff --git a/openstack/tools/install_local_ca.sh b/openstack/tools/install_local_ca.sh index 79ef0807..32e68bbd 100755 --- a/openstack/tools/install_local_ca.sh +++ b/openstack/tools/install_local_ca.sh @@ -18,12 +18,12 @@ if ((`juju status --format=json| jq -r '.applications[]| select(."charm-name"==" model_ca_cert_path=/tmp/stsstack-bundles.ssl.$model_uuid if ! validate_or_remove_ca ${model_ca_cert_path}; then - echo "Fetching CA cert from vault" 1>&2 - juju $JUJU_RUN_CMD --format=json vault/leader get-root-ca| jq -r .[].results.output > $model_ca_cert_path - if ! validate_or_remove_ca $model_ca_cert_path; then - echo "Didn't get a certificate from vault, check it's status and if necessary use ./tools/vault-unseal-and-authorise.sh" 1>&2 - exit 1 - fi + echo "Fetching CA cert from vault" 1>&2 + juju $JUJU_RUN_CMD --format=json vault/leader get-root-ca| jq -r .[].results.output > $model_ca_cert_path + if ! validate_or_remove_ca $model_ca_cert_path; then + echo "Didn't get a certificate from vault, check it's status and if necessary use ./tools/vault-unseal-and-authorise.sh" 1>&2 + exit 1 + fi fi elif [ -n "`juju config keystone ssl_cert`" ]; then MOD_DIR=$(dirname $0)/.. diff --git a/openstack/tools/instance_launch.sh b/openstack/tools/instance_launch.sh index ada9e523..918559e1 100755 --- a/openstack/tools/instance_launch.sh +++ b/openstack/tools/instance_launch.sh @@ -126,9 +126,9 @@ done # Determining flavor to use if [[ "${image_name}" =~ cirros ]]; then - flavor="m1.cirros" + flavor="m1.cirros" else - flavor="m1.small" + flavor="m1.small" fi # Create instances diff --git a/tools/stack-manager/mark-vms-managed.sh b/tools/stack-manager/mark-vms-managed.sh index 722c3c79..d69ac5b8 100755 --- a/tools/stack-manager/mark-vms-managed.sh +++ b/tools/stack-manager/mark-vms-managed.sh @@ -2,7 +2,9 @@ . `dirname $0`/common.sh vms=( $@ ) -(("${#vms[@]}")) || { echo "ERROR: no vms provided"; exit 1; } +if (("${#vms[@]}" == 0)); then + echo "ERROR: no vms provided"; exit 1; +fi openstack object save stack-manager-${OS_PROJECT_NAME} --file $STAGING_DIR/managed_vms.json managed_vms.json echo "Marking ${#vms[@]} vms as managed=true" diff --git a/tools/stack-manager/mark-vms-unmanaged.sh b/tools/stack-manager/mark-vms-unmanaged.sh index d52c1820..c7470bde 100755 --- a/tools/stack-manager/mark-vms-unmanaged.sh +++ b/tools/stack-manager/mark-vms-unmanaged.sh @@ -2,7 +2,9 @@ . `dirname $0`/common.sh vms=( $@ ) -(("${#vms[@]}")) || { echo "ERROR: no vms provided"; exit 1; } +if (("${#vms[@]}" == 0)); then + echo "ERROR: no vms provided"; exit 1; +fi openstack object save stack-manager-${OS_PROJECT_NAME} --file $STAGING_DIR/managed_vms.json managed_vms.json echo "Marking ${#vms[@]} vms as managed=false" diff --git a/tox.ini b/tox.ini index b67d6dc3..c152f6d0 100644 --- a/tox.ini +++ b/tox.ini @@ -24,26 +24,50 @@ pyfiles = {toxinidir}/tools/juju-bundle-applications.py bashfiles = - {toxinidir}/common/generate-bundle.sh - {toxinidir}/common/generate_bundle_base - {toxinidir}/openstack/tools/create-microceph-vm.sh {toxinidir}/tools/juju-lnav + # find tools -name \*.sh {toxinidir}/tools/vault-unseal-and-authorise.sh - {toxinidir}/tools/model-poweron.sh - {toxinidir}/tools/model-poweroff.sh + {toxinidir}/tools/mongo-access.sh {toxinidir}/tools/lint-git-messages.sh + {toxinidir}/tools/model-poweron.sh + {toxinidir}/tools/stack-manager/mark-model-vms-unmanaged.sh {toxinidir}/tools/stack-manager/show-all.sh - {toxinidir}/tools/stack-manager/show-managed.sh - {toxinidir}/tools/stack-manager/mark-vms-managed.sh + {toxinidir}/tools/stack-manager/common.sh + {toxinidir}/tools/stack-manager/show-unmanaged.sh {toxinidir}/tools/stack-manager/mark-vms-unmanaged.sh + {toxinidir}/tools/stack-manager/mark-vms-managed.sh {toxinidir}/tools/stack-manager/mark-model-vms-managed.sh - {toxinidir}/tools/stack-manager/show-unmanaged.sh - {toxinidir}/tools/stack-manager/common.sh - {toxinidir}/tools/stack-manager/mark-model-vms-unmanaged.sh - {toxinidir}/tools/mongo-access.sh + {toxinidir}/tools/stack-manager/show-managed.sh + {toxinidir}/tools/model-poweroff.sh + + {toxinidir}/common/generate_bundle_base + # find common -name \*.sh {toxinidir}/common/ch_channel_map/test-channel-map.sh {toxinidir}/common/ch_channel_map/test-all.sh + {toxinidir}/common/generate-bundle.sh + {toxinidir}/openstack/novarc + # find openstack/tools/ -name \*.sh + {toxinidir}/openstack/tools/create-microceph-vm.sh + {toxinidir}/openstack/tools/float_all.sh + {toxinidir}/openstack/tools/create_nova_az_aggregates.sh + {toxinidir}/openstack/tools/vault-unseal-and-authorise.sh + {toxinidir}/openstack/tools/create_sg_log.sh + {toxinidir}/openstack/tools/enable_samltestid.sh + {toxinidir}/openstack/tools/create_ipv4_octavia.sh + {toxinidir}/openstack/tools/allocate_vips.sh + {toxinidir}/openstack/tools/upload_octavia_amphora_image.sh + {toxinidir}/openstack/tools/install_local_ca.sh + {toxinidir}/openstack/tools/charmed_openstack_functest_runner.sh + {toxinidir}/openstack/tools/instance_launch.sh + {toxinidir}/openstack/tools/setup_tempest.sh + {toxinidir}/openstack/tools/create_octavia_lb.sh + {toxinidir}/openstack/tools/sec_groups.sh + {toxinidir}/openstack/tools/configure_octavia.sh + {toxinidir}/openstack/tools/delete_project.sh + {toxinidir}/openstack/tools/create_project.sh + {toxinidir}/openstack/tools/upload_image.sh + setenv = PYTHONHASHSEED=0 deps =