X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=env%2Flib%2Fcommon.sh;h=a6a6c4b560d1325077952526fa73f609a426d240;hb=9098160f02327e2454375310eda4c53f43fad05b;hp=38088c3fd09aa5d85d982aa52ce477fbc6842fd9;hpb=24d823d135caf31d9cb0e58f5edd9dc0d944af27;p=icn.git diff --git a/env/lib/common.sh b/env/lib/common.sh index 38088c3..a6a6c4b 100755 --- a/env/lib/common.sh +++ b/env/lib/common.sh @@ -2,6 +2,7 @@ set -eu -o pipefail IRONIC_DATA_DIR=${IRONIC_DATA_DIR:-"/opt/ironic"} +NODES_FILE=${NODES_FILE:-"${IRONIC_DATA_DIR}/nodes.json"} #IRONIC_PROVISIONING_INTERFACE is required to be provisioning, don't change it IRONIC_INTERFACE=${IRONIC_INTERFACE:-} IRONIC_PROVISIONING_INTERFACE=${IRONIC_PROVISIONING_INTERFACE:-"provisioning"} @@ -46,6 +47,9 @@ CAPM3_VERSION="v0.5.1" #The flux version to use FLUX_VERSION="0.20.0" +#The sops version to use +SOPS_VERSION="v3.7.1" + #refered from onap function call_api { #Runs curl with passed flags and provides @@ -78,8 +82,6 @@ function call_api { } function list_nodes { - NODES_FILE="${IRONIC_DATA_DIR}/nodes.json" - if [ ! -f "$NODES_FILE" ]; then exit 1 fi @@ -125,7 +127,6 @@ function networkdata_networks_field { name=$1 network=$2 field=$3 - NODES_FILE="${IRONIC_DATA_DIR}/nodes.json" cat $NODES_FILE | jq -c -r --arg name "$name" --arg network "$network" --arg field "$field" '.nodes[] | select(.name==$name) | .net.networks[] | select(.id==$network).'${field} } @@ -134,20 +135,17 @@ function networkdata_links_field { name=$1 link=$2 field=$3 - NODES_FILE="${IRONIC_DATA_DIR}/nodes.json" cat $NODES_FILE | jq -c -r --arg name "$name" --arg link "$link" --arg field "$field" '.nodes[] | select(.name==$name) | .net.links[] | select(.id==$link).'${field} } function node_networkdata { name=$1 - NODES_FILE="${IRONIC_DATA_DIR}/nodes.json" - if [ ! -f "$NODES_FILE" ]; then exit 1 fi - printf " networks:\n" + printf "networks:\n" for network in $(cat $NODES_FILE | jq -r --arg name "$name" '.nodes[] | select(.name==$name) | .net.networks[].id'); do link=$(networkdata_networks_field $name $network "link") type=$(networkdata_networks_field $name $network "type") @@ -158,17 +156,17 @@ function node_networkdata { gateway=$(networkdata_networks_field $name $network "gateway") dns_nameservers=$(networkdata_networks_field $name $network "dns_nameservers") - printf " ${network}:\n" - printf " macAddress: ${mac}\n" - printf " type: ${type}\n" + printf " ${network}:\n" + printf " macAddress: ${mac}\n" + printf " type: ${type}\n" if [[ $ip_address != "null" ]]; then - printf " ipAddress: ${ip_address}\n" + printf " ipAddress: ${ip_address}\n" fi if [[ $gateway != "null" ]]; then - printf " gateway: ${gateway}\n" + printf " gateway: ${gateway}\n" fi if [[ $dns_nameservers != "null" ]]; then - printf " nameservers: ${dns_nameservers}\n" + printf " nameservers: ${dns_nameservers}\n" fi done } @@ -248,6 +246,13 @@ function install_emcoctl { sudo install -o root -g root -m 0755 ${EMCOPATH}/bin/emcoctl/emcoctl /usr/local/bin/emcoctl } +function install_sops { + curl -L https://github.com/mozilla/sops/releases/download/${SOPS_VERSION}/sops-${SOPS_VERSION}.linux -o sops + sudo install -o root -g root -m 0755 sops /usr/local/bin/sops + rm sops + sops --version +} + function fetch_image { if [[ "${BM_IMAGE_URL}" && "${BM_IMAGE}" ]]; then mkdir -p "${IRONIC_DATA_DIR}/html/images"