6 APEX_PKGS="common undercloud onos"
10 echo "Starting the Apex virtual deployment."
11 echo "--------------------------------------------------------"
14 if ! rpm -q wget > /dev/null; then
15 sudo yum -y install wget
18 if [[ "$BUILD_DIRECTORY" == *verify* || "$BUILD_DIRECTORY" == *csit* ]]; then
19 # Build is from a verify, use local build artifacts (not RPMs)
20 cd $WORKSPACE/../${BUILD_DIRECTORY}
22 echo "WORKSPACE modified to $WORKSPACE"
24 elif [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
25 # if artifact name is passed the pull a
26 # specific artifact from artifacts.opnfv.org
27 # artifact specified should be opnfv-apex-<version>.noarch.rpm
28 RPM_INSTALL_PATH=$GS_URL
29 RPM_LIST=$RPM_INSTALL_PATH/$ARTIFACT_NAME
32 if [[ $BUILD_DIRECTORY == *apex-build* ]]; then
33 # Triggered from a daily so RPMS should be in local directory
34 BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
35 echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
37 if [[ -f ${BUILD_DIRECTORY}/../opnfv.properties ]]; then
38 # if opnfv.properties exists then use the
39 # local build. Source the file so we get local OPNFV vars
40 source ${BUILD_DIRECTORY}/../opnfv.properties
41 RPM_INSTALL_PATH=${BUILD_DIRECTORY}/noarch
42 RPM_LIST=$RPM_INSTALL_PATH/$(basename $OPNFV_RPM_URL)
44 echo "BUILD_DIRECTORY is from a daily job, so will not use latest from URL"
45 echo "Check that the slave has opnfv.properties in $BUILD_DIRECTORY"
49 # use the latest from artifacts.opnfv.org
50 # get the latest.properties to get the link to the latest artifact
51 if ! wget -O $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties; then
52 echo "ERROR: Unable to find latest.properties at ${GS_URL}...exiting"
55 # source the file so we get OPNFV vars
56 source opnfv.properties
57 RPM_INSTALL_PATH=$(echo "http://"$OPNFV_RPM_URL | sed 's/\/'"$(basename $OPNFV_RPM_URL)"'//')
58 RPM_LIST=${RPM_INSTALL_PATH}/$(basename $OPNFV_RPM_URL)
62 if [ -z "$DEPLOY_SCENARIO" ]; then
63 echo "Deploy scenario not set!"
65 elif [[ "$DEPLOY_SCENARIO" == *gate* ]]; then
66 echo "Detecting Gating scenario..."
67 if [ -z "$GERRIT_EVENT_COMMENT_TEXT" ]; then
68 echo "ERROR: Gate job triggered without comment!"
71 DEPLOY_SCENARIO=$(echo ${GERRIT_EVENT_COMMENT_TEXT} | grep start-gate-scenario | grep -Eo 'os-.*$')
72 if [ -z "$DEPLOY_SCENARIO" ]; then
73 echo "ERROR: Unable to detect scenario in Gerrit Comment!"
74 echo "Format of comment to trigger gate should be 'start-gate-scenario: <scenario>'"
77 echo "Gate scenario detected: ${DEPLOY_SCENARIO}"
82 # use local build for verify and csit promote
83 if [[ "$BUILD_DIRECTORY" == *verify* || "$BUILD_DIRECTORY" == *csit* ]]; then
84 if [ ! -e "${WORKSPACE}/build/lib" ]; then
85 ln -s ${WORKSPACE}/lib ${WORKSPACE}/build/lib
87 DEPLOY_SETTINGS_DIR="${WORKSPACE}/config/deploy"
88 NETWORK_SETTINGS_DIR="${WORKSPACE}/config/network"
89 DEPLOY_CMD="$(pwd)/deploy.sh"
90 RESOURCES="${WORKSPACE}/.build/"
91 CONFIG="${WORKSPACE}/build"
92 LIB="${WORKSPACE}/lib"
93 # Make sure python34 deps are installed
94 for dep_pkg in epel-release python34 python34-PyYAML python34-setuptools; do
95 if ! rpm -q ${dep_pkg} > /dev/null; then
96 if ! sudo yum install -y ${dep_pkg}; then
97 echo "Failed to install ${dep_pkg}"
103 # Make sure jinja2 is installed
104 for python_pkg in jinja2; do
105 if ! python3.4 -c "import $python_pkg"; then
106 echo "$python_pkg package not found for python3.4, attempting to install..."
107 if ! sudo easy_install-3.4 $python_pkg; then
108 echo -e "Failed to install $python_pkg package for python3.4"
114 # Make sure ipxe-roms-qemu package is updated to latest.
115 # This package is needed for multi virtio nic PXE boot in virtual environment.
116 sudo yum update -y ipxe-roms-qemu
118 if [ -z ${PYTHONPATH:-} ]; then
119 export PYTHONPATH=${WORKSPACE}/lib/python
121 export PYTHONPATH=$PYTHONPATH:${WORKSPACE}/lib/python
125 # find version of RPM
126 VERSION_EXTENSION=$(echo $(basename $RPM_LIST) | grep -Eo '[0-9]+\.[0-9]+-[0-9]{8}')
127 # build RPM List which already includes base Apex RPM
128 for pkg in ${APEX_PKGS}; do
129 RPM_LIST+=" ${RPM_INSTALL_PATH}/opnfv-apex-${pkg}-${VERSION_EXTENSION}.noarch.rpm"
132 # remove old / install new RPMs
133 if rpm -q opnfv-apex > /dev/null; then
134 INSTALLED_RPMS=$(rpm -qa | grep apex)
135 if [ -n "$INSTALLED_RPMS" ]; then
136 sudo yum remove -y ${INSTALLED_RPMS}
140 if ! sudo yum install -y $RPM_LIST; then
141 echo "Unable to install new RPMs: $RPM_LIST"
145 DEPLOY_CMD=opnfv-deploy
146 DEPLOY_SETTINGS_DIR="/etc/opnfv-apex/"
147 NETWORK_SETTINGS_DIR="/etc/opnfv-apex/"
148 RESOURCES="/var/opt/opnfv/images"
149 CONFIG="/var/opt/opnfv"
150 LIB="/var/opt/opnfv/lib"
153 # set env vars to deploy cmd
154 DEPLOY_CMD="CONFIG=${CONFIG} RESOURCES=${RESOURCES} LIB=${LIB} ${DEPLOY_CMD}"
156 if [ "$OPNFV_CLEAN" == 'yes' ]; then
157 if sudo test -e '/root/inventory/pod_settings.yaml'; then
158 clean_opts='-i /root/inventory/pod_settings.yaml'
162 if [[ "$BUILD_DIRECTORY" == *verify* || "$BUILD_DIRECTORY" == *csit* ]]; then
163 sudo CONFIG=${CONFIG} LIB=${LIB} ./clean.sh ${clean_opts}
165 sudo CONFIG=${CONFIG} LIB=${LIB} opnfv-clean ${clean_opts}
169 if echo ${DEPLOY_SCENARIO} | grep ipv6; then
171 DEPLOY_SCENARIO=$(echo ${DEPLOY_SCENARIO} | sed 's/-ipv6//')
172 echo "INFO: IPV6 Enabled"
175 echo "Deploy Scenario set to ${DEPLOY_SCENARIO}"
176 DEPLOY_FILE="${DEPLOY_SETTINGS_DIR}/${DEPLOY_SCENARIO}.yaml"
178 if [ ! -e "$DEPLOY_FILE" ]; then
179 echo "ERROR: Required settings file missing: Deploy settings file ${DEPLOY_FILE}"
182 if [[ "$JOB_NAME" == *virtual* ]]; then
183 # settings for virtual deployment
184 if [ "$IPV6_FLAG" == "True" ]; then
185 NETWORK_FILE="${NETWORK_SETTINGS_DIR}/network_settings_v6.yaml"
186 elif echo ${DEPLOY_SCENARIO} | grep fdio; then
187 NETWORK_FILE="${NETWORK_SETTINGS_DIR}/network_settings_vpp.yaml"
189 NETWORK_FILE="${NETWORK_SETTINGS_DIR}/network_settings.yaml"
191 DEPLOY_CMD="${DEPLOY_CMD} -v"
192 if [[ "$JOB_NAME" == *csit* ]]; then
193 DEPLOY_CMD="${DEPLOY_CMD} -e csit-environment.yaml --virtual-computes 2"
196 # settings for bare metal deployment
197 if [ "$IPV6_FLAG" == "True" ]; then
198 NETWORK_FILE="/root/network/network_settings_v6.yaml"
199 elif [[ "$JOB_NAME" == *master* ]]; then
200 NETWORK_FILE="/root/network/network_settings-master.yaml"
202 NETWORK_FILE="/root/network/network_settings.yaml"
204 INVENTORY_FILE="/root/inventory/pod_settings.yaml"
206 if ! sudo test -e "$INVENTORY_FILE"; then
207 echo "ERROR: Required settings file missing: Inventory settings file ${INVENTORY_FILE}"
210 # include inventory file for bare metal deployment
211 DEPLOY_CMD="${DEPLOY_CMD} -i ${INVENTORY_FILE}"
214 # Check that network settings file exists
215 if ! sudo test -e "$NETWORK_FILE"; then
216 echo "ERROR: Required settings file missing: Network Settings file ${NETWORK_FILE}"
221 sudo ${DEPLOY_CMD} -d ${DEPLOY_FILE} -n ${NETWORK_FILE} --debug
223 if [[ "$JOB_NAME" == *csit* ]]; then
224 echo "CSIT job: setting host route for floating ip routing"
225 # csit route to allow docker container to reach floating ips
226 UNDERCLOUD=$(sudo virsh domifaddr undercloud | grep -Eo "[0-9\.]+{3}[0-9]+")
227 if sudo route | grep 192.168.37.128 > /dev/null; then
228 sudo route del -net 192.168.37.128 netmask 255.255.255.128
230 sudo route add -net 192.168.37.128 netmask 255.255.255.128 gw ${UNDERCLOUD}
234 echo "--------------------------------------------------------"