From d4d7abfd2342ecc315321187cd194c5b12455bf2 Mon Sep 17 00:00:00 2001 From: davidplunkett Date: Tue, 26 Mar 2019 02:31:45 +0000 Subject: [PATCH] allow input file to be unicycle yaml file Change-Id: I5ca1d5077ed9a12ad9172be099e5d7641c24c559 Signed-off-by: davidplunkett --- buildrc | 1 + install_server_os.sh | 7 +++++++ setup_tools.sh | 9 +++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/buildrc b/buildrc index 04b430e..758916e 100644 --- a/buildrc +++ b/buildrc @@ -34,6 +34,7 @@ export HPE_ROOT=${HPE_ROOT:-$AKRAINO_ROOT/hpe} export REGION_ROOT=${REGION_ROOT:-$WEB_ROOT/region} export BUILD_ROOT=${BUILD_ROOT:-$AKRAINO_ROOT/server-config} export IPXE_ROOT=${IPXE_ROOT:-$AKRAINO_ROOT/ipxe} +export YAML_ROOT=${YAML_ROOT:-$AKRAINO_ROOT/yaml_builds} export UBUNTU_URL=${UBUNTU_URL:-http://releases.ubuntu.com/16.04/ubuntu-16.04.6-server-amd64.iso} export BUILD_WEBPORT=8090 diff --git a/install_server_os.sh b/install_server_os.sh index 75d67ee..f15f7ec 100755 --- a/install_server_os.sh +++ b/install_server_os.sh @@ -85,6 +85,13 @@ BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" # LOAD SERVER VARIABLES IF SERVER RCFILE PROVIDED - OTHERWISE ASSUME THE VARIABLES HAVE BEEN EXPORTED if [ -n "$RCFILE" ] && [ -f "$RCFILE" ]; then + # IF RCFILE IS YAML FORMAL THEN CONVERT RCFILE TO PROPERTIES FILE + if [ "$(grep -vP '^#|^\s*$' $RCFILE | head -n 1)" = "---" ]; then + NEWRCFILE=$BUILD_ROOT/$(basename "$RCFILE" | cut -d. -f1)rc + echo "WARNING: Converting yaml file [$RCFILE] to properties file [$NEWRCFILE]" + python $YAML_ROOT/scripts/jcopy.py $RCFILE $YAML_ROOT/tools/j2/serverrc.j2 $NEWRCFILE + export RCFILE=$NEWRCFILE + fi source $RCFILE fi diff --git a/setup_tools.sh b/setup_tools.sh index 08b6d50..01e7590 100755 --- a/setup_tools.sh +++ b/setup_tools.sh @@ -42,6 +42,11 @@ esac done set -- "${POSITIONAL[@]}" # restore positional parameters +# SKIP IF TOOLS HAVE ALREADY BEEN SETUP +if [ -n "$REDFISH_TOOLS_SETUP" ]; then + exit 0 +fi + # LOAD BUILD DEFAULT VALUES IF BUILD VARIABLES ARE NOT LOADED if [ -z "$AKRAINO_ROOT" ]; then BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -65,7 +70,7 @@ mkdir -p $BUILD_ROOT ## CHECK THAT REQUIRED PACKAGES ARE INSTALLED echo "Checking for known required packages" -PACKAGES="xorriso sshpass python-requests python-pip coreutils" +PACKAGES="docker python xorriso sshpass python-requests python-pip python-yaml python-jinja2 make gcc coreutils" for PKG in $PACKAGES ; do if ! apt list $PKG 2>/dev/null | grep "$PKG.*installed.*" ; then echo "Attempting to install missing package $PKG" @@ -123,4 +128,4 @@ if [ ! -f "$HPE_ROOT/examples/Redfish/_redfishobject.py" ]; then fi echo "Tools are ready in [$AKRAINO_ROOT]" - +export REDFISH_TOOLS_SETUP="True" -- 2.16.6