Clone baremetal-operator.git in baremetal deploy 83/3783/5
authorTodd Malsbary <todd.malsbary@intel.com>
Tue, 6 Oct 2020 21:16:21 +0000 (14:16 -0700)
committerKuralamudhan Ramakrishnan <kuralamudhan.ramakrishnan@intel.com>
Mon, 16 Nov 2020 17:41:16 +0000 (17:41 +0000)
Without this, the bmh_install step will fail if the repo is not
already present.

Issue-ID: ICN-475
Signed-off-by: Todd Malsbary <todd.malsbary@intel.com>
Change-Id: If6b2454f844cbc6d92355571b6b6642d2cc73c2c

deploy/metal3/scripts/01_metal3.sh
env/lib/common.sh

index e8bad40..f1b827b 100755 (executable)
@@ -15,6 +15,22 @@ fi
 IMAGE_URL=http://172.22.0.1/images/${BM_IMAGE}
 IMAGE_CHECKSUM=http://172.22.0.1/images/${BM_IMAGE}.md5sum
 
+function clone_repos {
+    mkdir -p "${M3PATH}"
+    if [[ -d ${BMOPATH} && "${FORCE_REPO_UPDATE}" == "true" ]]; then
+      rm -rf "${BMOPATH}"
+    fi
+    if [ ! -d "${BMOPATH}" ] ; then
+        pushd "${M3PATH}"
+        git clone "${BMOREPO}"
+        popd
+    fi
+    pushd "${BMOPATH}"
+    git checkout "${BMOBRANCH}"
+    git pull -r || true
+    popd
+}
+
 function get_default_interface_ipaddress {
     local _ip=$1
     local _default_interface=$(awk '$2 == 00000000 { print $1 }' /proc/net/route)
@@ -254,6 +270,7 @@ function deprovision_all_hosts {
 }
 
 if [ "$1" == "launch" ]; then
+    clone_repos
     launch_baremetal_operator
     exit 0
 fi
index 8ce0006..9c08025 100755 (executable)
@@ -43,6 +43,17 @@ IRONIC_IPMI_INTERFACE_IP=${IRONIC_IPMI_INTERFACE_IP:-}
 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"}
 
+#Path to clone the metal3 dev env repo
+M3PATH="$(go env GOPATH)/src/github.com/metal3-io"
+#Path to clone the baremetal operator repo
+BMOPATH="${M3PATH}/baremetal-operator"
+#Baremetal operator repository URL
+BMOREPO="${BMOREPO:-https://github.com/metal3-io/baremetal-operator.git}"
+#Baremetal operator repository branch to checkout
+BMOBRANCH="${BMOBRANCH:-10eb5aa3e614d0fdc6315026ebab061cbae6b929}"
+#Discard existing baremetal operator repo directory
+FORCE_REPO_UPDATE="${FORCE_REPO_UPDATE:-true}"
+
 #refered from onap
 function call_api {
     #Runs curl with passed flags and provides