X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=env%2Flib%2Fcommon.sh;h=6ee235ea1955d9d8560e14feda4c70b16f394023;hb=15eb5f9a89d0dbbff46e1b2a02bee7df1d533af6;hp=1e633b6dd8cc1cbc449a13ccf72e4a944c0f7947;hpb=5905a11aab5e26bcdf37984c6ac6b679e988d9e0;p=icn.git diff --git a/env/lib/common.sh b/env/lib/common.sh index 1e633b6..6ee235e 100755 --- a/env/lib/common.sh +++ b/env/lib/common.sh @@ -1,16 +1,15 @@ #!/usr/bin/env bash set -eu -o pipefail -DOWNLOAD_PATH=${DOWNLOAD_PATH:-/opt/icn} - 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"} IRONIC_IPMI_INTERFACE=${IRONIC_IPMI_INTERFACE:-} IRONIC_PROVISIONING_INTERFACE_IP=${IRONIC_PROVISIONING_INTERFACE_IP:-"172.22.0.1"} -BM_IMAGE_URL=${BM_IMAGE_URL:-"https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img"} -BM_IMAGE=${BM_IMAGE:-"bionic-server-cloudimg-amd64.img"} +BM_IMAGE_URL=${BM_IMAGE_URL:-"https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img"} +BM_IMAGE=${BM_IMAGE:-"focal-server-cloudimg-amd64.img"} #Baremetal operator repository URL BMOREPO="${BMOREPO:-https://github.com/metal3-io/baremetal-operator.git}" @@ -18,7 +17,22 @@ BMOREPO="${BMOREPO:-https://github.com/metal3-io/baremetal-operator.git}" BMOPATH="/opt/src/github.com/metal3-io/baremetal-operator" #Bare Metal Operator version to use BMO_VERSION="capm3-v0.5.1" -#Discard existing baremetal operator repo directory + +#KuD repository URL +KUDREPO="${KUDREPO:-https://github.com/onap/multicloud-k8s.git}" +#Path to clone the KuD repo +KUDPATH="/opt/src/github.com/onap/multicloud-k8s" +#KuD version to use +KUD_VERSION="ed96bca7fe415f1636d82c26af15d7474bdfe876" + +#EMCO repository URL +EMCOREPO="${EMCOREPO:-https://github.com/open-ness/EMCO.git}" +#Path to clone the EMCO repo +EMCOPATH="/opt/src/github.com/open-ness/EMCO" +#EMCO version to use +EMCO_VERSION="openness-21.03.06" + +#Discard existing repo directory FORCE_REPO_UPDATE="${FORCE_REPO_UPDATE:-true}" # The kustomize version to use @@ -27,6 +41,9 @@ KUSTOMIZE_VERSION="v4.3.0" #Cluster API version to use CAPI_VERSION="v0.4.3" +#Cluster API version to use +CAPM3_VERSION="v0.5.1" + #The flux version to use FLUX_VERSION="0.20.0" @@ -62,8 +79,6 @@ function call_api { } function list_nodes { - NODES_FILE="${IRONIC_DATA_DIR}/nodes.json" - if [ ! -f "$NODES_FILE" ]; then exit 1 fi @@ -109,7 +124,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} } @@ -118,20 +132,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") @@ -142,17 +153,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 } @@ -171,25 +182,40 @@ function wait_for { done } -function clone_baremetal_operator_repository { - mkdir -p $(dirname ${BMOPATH}) - if [[ -d ${BMOPATH} && "${FORCE_REPO_UPDATE}" == "true" ]]; then - rm -rf "${BMOPATH}" +function clone_repository { + local -r path=$1 + local -r repo=$2 + local -r version=$3 + mkdir -p $(dirname ${path}) + if [[ -d ${path} && "${FORCE_REPO_UPDATE}" == "true" ]]; then + rm -rf "${path}" fi - if [ ! -d "${BMOPATH}" ] ; then - pushd $(dirname ${BMOPATH}) - git clone "${BMOREPO}" + if [ ! -d "${path}" ] ; then + pushd $(dirname ${path}) + git clone "${repo}" popd else - pushd "${BMOPATH}" + pushd "${path}" git fetch popd fi - pushd "${BMOPATH}" - git reset --hard "${BMO_VERSION}" + pushd "${path}" + git reset --hard "${version}" popd } +function clone_baremetal_operator_repository { + clone_repository ${BMOPATH} ${BMOREPO} ${BMO_VERSION} +} + +function clone_kud_repository { + clone_repository ${KUDPATH} ${KUDREPO} ${KUD_VERSION} +} + +function clone_emco_repository { + clone_repository ${EMCOPATH} ${EMCOREPO} ${EMCO_VERSION} +} + function install_kustomize { curl -sL "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2F${KUSTOMIZE_VERSION}/kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz" -o kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz tar xzf kustomize_${KUSTOMIZE_VERSION}_linux_amd64.tar.gz --no-same-owner @@ -211,6 +237,12 @@ function install_flux_cli { flux --version } +function install_emcoctl { + clone_emco_repository + make -C ${EMCOPATH}/src/tools/emcoctl + sudo install -o root -g root -m 0755 ${EMCOPATH}/bin/emcoctl/emcoctl /usr/local/bin/emcoctl +} + function fetch_image { if [[ "${BM_IMAGE_URL}" && "${BM_IMAGE}" ]]; then mkdir -p "${IRONIC_DATA_DIR}/html/images"