Apex: Refactor snapshot pipeline for other types
[releng.git] / jjb / apex / apex-snapshot-deploy.sh
index 0760626..dd69df3 100644 (file)
@@ -20,32 +20,44 @@ echo "Deploying Apex snapshot..."
 echo "--------------------------"
 echo
 
+if [ -z "$SNAP_TYPE" ]; then
+  echo "ERROR: SNAP_TYPE not provided...exiting"
+  exit 1
+fi
+
 echo "Cleaning server"
 pushd ci > /dev/null
 sudo opnfv-clean
 popd > /dev/null
 
+full_snap_url="gs://${GS_URL}/${OS_VERSION}/${TOPOLOGY}"
+
 echo "Downloading latest snapshot properties file"
-if ! wget -O $WORKSPACE/opnfv.properties http://$GS_URL/snapshot.properties; then
-  echo "ERROR: Unable to find snapshot.properties at ${GS_URL}...exiting"
+if ! gsutil cp ${full_snap_url}/snapshot.properties $WORKSPACE/opnfv.properties; then
+  echo "ERROR: Unable to find snapshot.properties at ${full_snap_url}...exiting"
   exit 1
 fi
 
+echo "Properties contents:"
+cat ${WORKSPACE}/opnfv.properties
+
 # find latest check sum
-latest_snap_checksum=$(cat opnfv.properties | grep OPNFV_SNAP_SHA512SUM | awk -F "=" '{print $2}')
+latest_snap_checksum=$(cat ${WORKSPACE}/opnfv.properties | grep ${SNAP_TYPE}_SNAP_SHA512SUM | awk -F "=" '{print $2}')
 if [ -z "$latest_snap_checksum" ]; then
   echo "ERROR: checksum of latest snapshot from snapshot.properties is null!"
   exit 1
 fi
 
 local_snap_checksum=""
+SNAP_CACHE=${SNAP_CACHE}/${OS_VERSION}/${TOPOLOGY}
 
 # check snap cache directory exists
 # if snapshot cache exists, find the checksum
 if [ -d "$SNAP_CACHE" ]; then
-  latest_snap=$(ls ${SNAP_CACHE} | grep tar.gz | tail -n 1)
+  latest_snap=$(ls ${SNAP_CACHE} | grep tar.gz | grep $SNAP_TYPE | tail -n 1)
   if [ -n "$latest_snap" ]; then
     local_snap_checksum=$(sha512sum ${SNAP_CACHE}/${latest_snap} | cut -d' ' -f1)
+    echo "Local snap checksum is: ${local_snap_checksum}"
   fi
 else
   mkdir -p ${SNAP_CACHE}
@@ -53,7 +65,12 @@ fi
 
 # compare check sum and download latest snap if not up to date
 if [ "$local_snap_checksum" != "$latest_snap_checksum" ]; then
-  snap_url=$(cat opnfv.properties | grep OPNFV_SNAP_URL | awk -F "=" '{print $2}')
+  snap_url=$(cat opnfv.properties | grep ${SNAP_TYPE}_SNAP_URL | awk -F "=" '{print $2}')
+  # TODO(trozet): Remove this once OPNFV url is deprecated
+  if [[ -z "$snap_url" && "$SNAP_TYPE" == 'csit' ]]; then
+      echo "WARN: Unable to find snap url for ${SNAP_TYPE}, attempting to use OPNFV"
+      snap_url=$(cat opnfv.properties | grep OPNFV_SNAP_URL | awk -F "=" '{print $2}')
+  fi
   if [ -z "$snap_url" ]; then
     echo "ERROR: Snap URL from snapshot.properties is null!"
     exit 1
@@ -61,7 +78,7 @@ if [ "$local_snap_checksum" != "$latest_snap_checksum" ]; then
   echo "INFO: SHA mismatch, will download latest snapshot"
   # wipe cache
   rm -rf ${SNAP_CACHE}/*
-  wget --directory-prefix=${SNAP_CACHE}/ ${snap_url}
+  gsutil cp "gs://${snap_url}" ${SNAP_CACHE}/
   snap_tar=$(basename ${snap_url})
 else
   snap_tar=${latest_snap}
@@ -133,10 +150,6 @@ for node_def in ${virsh_vm_defs}; do
   sudo virsh define ${node_def}
   node=$(echo ${node_def} | awk -F '.' '{print $1}')
   sudo cp -f ${node}.qcow2 /var/lib/libvirt/images/
-  # FIXME (trozet) install java on each disk image as required to upgrade ODL
-  # should be added to Apex as part of the deployment. Remove this after that
-  # is complete
-  sudo LIBGUESTFS_BACKEND=direct virt-customize --install java-1.8.0-openjdk -a /var/lib/libvirt/images/${node}.qcow2
   sudo virsh start ${node}
   echo "Node: ${node} started"
 done
@@ -154,7 +167,7 @@ while [ "$counter" -le 10 ]; do
   echo "Checking if OpenStack is up"
   if nc -z ${admin_controller_ip} 9696 > /dev/null; then
     echo "Overcloud Neutron is up...Checking if OpenDaylight NetVirt is up..."
-    if curl --fail --silent -u admin:admin ${netvirt_url} > /dev/null; then
+    if curl --fail --silent -u admin:${SDN_CONTROLLER_PASSWORD} ${netvirt_url} > /dev/null; then
       echo "OpenDaylight is up.  Overcloud deployment complete"
       exit 0
     else