
Currently, devtest_testenv will write the BM networks stanza into the TE_DATAFILE, and since you can not run devtest_testenv inside a test environment since it plays with VMs and so on, it makes it impossible to change the network topology described by bm-networks. To make it easy to update in a test environment, move the population call to a separate script. Change-Id: Iccc562ad16bf73118739cd4535abfac099834e3e
59 lines
1.5 KiB
Bash
Executable File
59 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -eu
|
|
set -o pipefail
|
|
SCRIPT_NAME=$(basename $0)
|
|
|
|
function show_options () {
|
|
echo "Usage: $SCRIPT_NAME [options] {JSON-filename}"
|
|
echo
|
|
echo "Updates the BM network description for a TripleO devtest environment."
|
|
echo
|
|
echo "Options:"
|
|
echo " -h -- This help."
|
|
echo " --bm-networks NETFILE -- You are supplying your own network layout."
|
|
echo " The schema for baremetal-network can be found in"
|
|
echo " the devtest_setup documentation."
|
|
echo
|
|
echo "JSON-filename -- the path to write the environment description to."
|
|
echo
|
|
exit $1
|
|
}
|
|
|
|
NETS_PATH=
|
|
|
|
TEMP=$(getopt -o h -l bm-networks: -n $SCRIPT_NAME -- "$@")
|
|
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
|
|
|
# Note the quotes around `$TEMP': they are essential!
|
|
eval set -- "$TEMP"
|
|
|
|
while true ; do
|
|
case "$1" in
|
|
--bm-networks) NETS_PATH="$2"; shift 2;;
|
|
-h) show_options 0;;
|
|
--) shift ; break ;;
|
|
*) echo "Error: unsupported option $1." ; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
### --include
|
|
## devtest_update_network
|
|
## ======================
|
|
|
|
## This script updates the baremetal networks definition in the
|
|
## ``$TE_DATAFILE``.
|
|
### --end
|
|
|
|
JSONFILE=${1:-''}
|
|
EXTRA_ARGS=${2:-''}
|
|
|
|
if [ -z "$JSONFILE" -o -n "$EXTRA_ARGS" ]; then
|
|
show_options 1
|
|
fi
|
|
|
|
if [ -n "$NETS_PATH" ]; then
|
|
JSON=$(jq -s '.[0]["baremetal-network"]=.[1] | .[0]' $JSONFILE $NETS_PATH)
|
|
echo "${JSON}" > $JSONFILE
|
|
fi
|