Use common files to store distro related data for VIRL
[csit.git] / bootstrap-vpp-verify-semiweekly.sh
index e6c48ec..c3fc4e0 100644 (file)
@@ -21,10 +21,6 @@ RETURN_STATUS=0
 cat /etc/hostname
 cat /etc/hosts
 
-export DEBIAN_FRONTEND=noninteractive
-sudo apt-get -y update
-sudo apt-get -y install libpython2.7-dev python-virtualenv
-
 PYBOT_ARGS="--noncritical MULTI_THREAD"
 
 ARCHIVE_ARTIFACTS=(log.html output.xml report.html)
@@ -32,25 +28,47 @@ ARCHIVE_ARTIFACTS=(log.html output.xml report.html)
 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 export PYTHONPATH=${SCRIPT_DIR}
 
+if [ -f "/etc/redhat-release" ]; then
+    DISTRO="CENTOS"
+    sudo yum install -y python-devel python-virtualenv
+else
+    DISTRO="UBUNTU"
+    export DEBIAN_FRONTEND=noninteractive
+    sudo apt-get -y update
+    sudo apt-get -y install libpython2.7-dev python-virtualenv
+fi
 
 # 1st step: Download and prepare VPP packages
 
 # Temporarily download VPP packages from nexus.fd.io
-rm -f *.deb
 if [ "${#}" -ne "0" ]; then
     arr=(${@})
     echo ${arr[0]}
 else
-    # Download the latest VPP build .deb install packages
+    case "$DISTRO" in
+        CENTOS )
+            PACKAGE=rpm
+            ;;
+        UBUNTU )
+            PACKAGE=deb
+    esac
+    # Download the latest VPP build install packages
+    rm -f *.${PACKAGE}
     echo Downloading VPP packages...
     bash ${SCRIPT_DIR}/resources/tools/download_install_vpp_pkgs.sh --skip-install
 fi
 
-VPP_DEBS=(*.deb)
-echo ${VPP_DEBS[@]}
+# Take vpp package and get the vpp version
+VPP_PKGS=(*.$PACKAGE)
+case "$DISTRO" in
+        CENTOS )
+            VPP_VER="$( expr match $(ls *.rpm | head -n 1) 'vpp-\(.*\).rpm' )"
+            ;;
+        UBUNTU )
+            VPP_VER="$( expr match $(ls *.deb | head -n 1) 'vpp-\(.*\)-deb.deb' )"
+esac
 
-VPP_VER=$(echo ${VPP_DEBS#vpp-})
-VPP_VER=$(echo ${VPP_VER%-deb.deb})
+echo ${VPP_PKGS[@]}
 
 set +x
 echo "****************************************************************************************************************************************"
@@ -87,8 +105,15 @@ VIRL_PKEY=priv_key
 VIRL_SERVER_STATUS_FILE="status"
 VIRL_SERVER_EXPECTED_STATUS="PRODUCTION"
 
-VIRL_TOPOLOGY=double-ring-nested.xenial
-VIRL_RELEASE=csit-ubuntu-16.04.1_2016-10-10_1.4
+case "$DISTRO" in
+        CENTOS )
+            VIRL_TOPOLOGY=$(cat ${SCRIPT_DIR}/VIRL_TOPOLOGY_CENTOS)
+            VIRL_RELEASE=$(cat ${SCRIPT_DIR}/VIRL_RELEASE_CENTOS)
+            ;;
+        UBUNTU )
+            VIRL_TOPOLOGY=$(cat ${SCRIPT_DIR}/VIRL_TOPOLOGY_UBUNTU)
+            VIRL_RELEASE=$(cat ${SCRIPT_DIR}/VIRL_RELEASE_UBUNTU)
+esac
 
 SSH_OPTIONS="-i ${VIRL_PKEY} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o BatchMode=yes -o LogLevel=error"
 
@@ -166,18 +191,18 @@ done
 
 
 VIRL_DIR_LOC="/tmp"
-VPP_DEBS_VIRL=(${VPP_DEBS[@]})
+VPP_PKGS_VIRL=(${VPP_PKGS[@]})
 
 # Prepend directory location at remote host to deb file list
-for index in "${!VPP_DEBS_VIRL[@]}"; do
-    VPP_DEBS_VIRL[${index}]=${VIRL_DIR_LOC}/${VPP_DEBS_VIRL[${index}]}
+for index in "${!VPP_PKGS_VIRL[@]}"; do
+    VPP_PKGS_VIRL[${index}]=${VIRL_DIR_LOC}/${VPP_PKGS_VIRL[${index}]}
 done
 
-echo "Updated file names: " ${VPP_DEBS_VIRL[@]}
+echo "Updated file names: " ${VPP_PKGS_VIRL[@]}
 
 cat ${VIRL_PKEY}
 # Copy the files to VIRL host
-scp ${SSH_OPTIONS} *.deb \
+scp ${SSH_OPTIONS} *.${PACKAGE} \
     ${VIRL_USERNAME}@${VIRL_SERVER}:${VIRL_DIR_LOC}/
 
 result=$?
@@ -197,7 +222,7 @@ function stop_virl_simulation {
 
 VIRL_SID=$(ssh ${SSH_OPTIONS} \
     ${VIRL_USERNAME}@${VIRL_SERVER} \
-    "start-testcase -c ${VIRL_TOPOLOGY} -r ${VIRL_RELEASE} ${VPP_DEBS_VIRL[@]}")
+    "start-testcase -c ${VIRL_TOPOLOGY} -r ${VIRL_RELEASE} ${VPP_PKGS_VIRL[@]}")
 retval=$?
 if [ ${retval} -ne "0" ]; then
     echo "VIRL simulation start failed"

©2016 FD.io a Linux Foundation Collaborative Project. All Rights Reserved.
Linux Foundation is a registered trademark of The Linux Foundation. Linux is a registered trademark of Linus Torvalds.
Please see our privacy policy and terms of use.