7 echo "Starting the Apex virtual deployment."
8 echo "--------------------------------------------------------"
11 if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
12 cd $WORKSPACE/../${BUILD_DIRECTORY/build_output/}
14 echo "WORKSPACE modified to $WORKSPACE"
16 elif [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
17 # if artifact name is passed the pull a
18 # specific artifact from artifacts.opnfv.org
19 RPM_INSTALL_PATH=$GS_URL
20 RPM_LIST=$RPM_INSTALL_PATH/$ARTIFACT_NAME
22 if [[ $BUILD_DIRECTORY == *verify* ]]; then
23 BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
24 echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
25 elif [[ $BUILD_DIRECTORY == *apex-build* ]]; then
26 BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
27 echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
30 if [[ -f ${BUILD_DIRECTORY}/../opnfv.properties ]]; then
31 # if opnfv.properties exists then use the
32 # local build. Source the file so we get local OPNFV vars
33 source ${BUILD_DIRECTORY}/../opnfv.properties
34 RPM_INSTALL_PATH=${BUILD_DIRECTORY}/noarch
35 RPM_LIST=$RPM_INSTALL_PATH/$(basename $OPNFV_RPM_URL)
37 if [[ $BUILD_DIRECTORY == *verify* ]]; then
38 echo "BUILD_DIRECTORY is from a verify job, so will not use latest from URL"
39 echo "Check that the slave has opnfv.properties in $BUILD_DIRECTORY"
41 elif [[ $BUILD_DIRECTORY == *apex-build* ]]; then
42 echo "BUILD_DIRECTORY is from a daily job, so will not use latest from URL"
43 echo "Check that the slave has opnfv.properties in $BUILD_DIRECTORY"
46 # no opnfv.properties means use the latest from artifacts.opnfv.org
47 # get the latest.properties to get the link to the latest artifact
48 curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
49 [[ -f opnfv.properties ]] || exit 1
50 # source the file so we get OPNFV vars
51 source opnfv.properties
52 RPM_INSTALL_PATH=$(echo $OPNFV_RPM_URL | sed 's/'"$(basename $OPNFV_RPM_URL)"'//')
53 RPM_LIST=$RPM_INSTALL_PATH/$(basename $OPNFV_RPM_URL)
57 if [ -z "$DEPLOY_SCENARIO" ]; then
58 echo "Deploy scenario not set!"
62 # use local build for verify
63 if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
64 if [ ! -e "${WORKSPACE}/build/lib" ]; then ln -s ${WORKSPACE}/lib ${WORKSPACE}/build/lib; fi
65 DEPLOY_CMD="CONFIG=${WORKSPACE}/build RESOURCES=${WORKSPACE}/build/images/ ./deploy.sh -c ${WORKSPACE}/build -r ${WORKSPACE}/build/images/"
66 DEPLOY_FILE="${WORKSPACE}/config/deploy/${DEPLOY_SCENARIO}.yaml"
67 NETWORK_FILE="${WORKSPACE}/config/network/network_settings.yaml"
68 # Make sure python34 is installed
69 if ! rpm -q python34 > /dev/null; then
70 sudo yum install -y epel-release
71 if ! sudo yum install -y python34; then
72 echo "Failed to install python34"
76 if ! rpm -q python34-PyYAML > /dev/null; then
77 sudo yum install -y epel-release
78 if ! sudo yum install -y python34-PyYAML; then
79 echo "Failed to install python34-PyYAML"
83 if ! rpm -q python34-setuptools > /dev/null; then
84 if ! sudo yum install -y python34-setuptools; then
85 echo "Failed to install python34-setuptools"
89 if [ -z ${PYTHONPATH:-} ]; then
90 export PYTHONPATH=${WORKSPACE}/lib/python
92 export PYTHONPATH=$PYTHONPATH:${WORKSPACE}/lib/python
95 VERSION_EXTENSION=$(echo $(basename $RPM_LIST) | sed 's/opnfv-apex-//')
96 for pkg in common undercloud opendaylight-sfc onos; do
97 RPM_LIST+=" ${RPM_INSTALL_PATH}/opnfv-apex-${pkg}-${VERSION_EXTENSION}"
100 # update / install the new rpm
101 if rpm -q opnfv-apex > /dev/null; then
102 INSTALLED_RPMS=$(rpm -qa | grep apex)
103 for x in $INSTALLED_RPMS; do
104 INSTALLED_RPM_VER=$(echo $x | sed 's/opnfv-apex-//').rpm
105 # Does each RPM's version match the version required for deployment
106 if [ "$INSTALLED_RPM_VER" == "$VERSION_EXTENSION" ]; then
107 echo "RPM $x is already installed"
109 echo "RPM $x does not match $VERSION_EXTENSION"
110 echo "Will upgrade/downgrade RPMs..."
111 # Try to upgrade/downgrade RPMS
112 if sudo yum update -y $RPM_LIST | grep "does not update installed package"; then
113 if ! sudo yum downgrade -y $RPM_LIST; then
114 sudo yum remove -y opnfv-apex-undercloud opnfv-apex-common opnfv-apex-opendaylight-sfc opnfv-apex-onos
115 sudo yum downgrade -y $RPM_INSTALL_PATH
122 sudo yum install -y $RPM_LIST;
124 DEPLOY_CMD=opnfv-deploy
125 DEPLOY_FILE="/etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
126 NETWORK_FILE="/etc/opnfv-apex/network_settings.yaml"
127 export RESOURCES="/var/opt/opnfv/images"
128 export CONFIG="/var/opt/opnfv"
131 if [ "$OPNFV_CLEAN" == 'yes' ]; then
132 if [[ $BUILD_DIRECTORY == *verify-master* ]]; then
133 sudo CONFIG=${WORKSPACE}/build ./clean.sh
138 # initiate virtual deployment
139 echo "Deploy Scenario set to ${DEPLOY_SCENARIO}"
140 if [ -e $DEPLOY_FILE ]; then
141 sudo $DEPLOY_CMD -v -d ${DEPLOY_FILE} -n $NETWORK_FILE --debug
143 echo "File does not exist /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
147 echo "--------------------------------------------------------"