9 FUNCTEST_ENV_FLAG=False
12 echo "Starting the Apex deployment."
13 echo "--------------------------------------------------------"
16 if [ -z "$DEPLOY_SCENARIO" ]; then
17 echo "Deploy scenario not set!"
20 echo "Deploy scenario: ${DEPLOY_SCENARIO}"
23 # Dev or RPM/ISO build
24 if [[ "$ARTIFACT_VERSION" =~ dev ]]; then
25 # Settings for deploying from git workspace
26 DEPLOY_SETTINGS_DIR="${WORKSPACE}/config/deploy"
27 NETWORK_SETTINGS_DIR="${WORKSPACE}/config/network"
28 CLEAN_CMD="opnfv-clean"
29 # if we are using master, then we are downloading/caching upstream images
30 # we want to use that built in mechanism to avoid re-downloading every job
31 # so we use a dedicated folder to hold the upstream cache
32 UPSTREAM_CACHE=$HOME/upstream_cache
33 if [[ "$BRANCH" != 'stable/fraser' ]]; then
34 mkdir -p ${UPSTREAM_CACHE}
35 RESOURCES=$UPSTREAM_CACHE
37 RESOURCES="${WORKSPACE}/.build/"
39 CONFIG="${WORKSPACE}/build"
42 LIB="${WORKSPACE}/lib"
43 DEPLOY_CMD="opnfv-deploy --image-dir ${RESOURCES}"
44 # Ensure artifacts were downloaded and extracted correctly
45 # TODO(trozet) add verification here
48 sudo rm -rf /tmp/.build
50 sudo pip3 install --upgrade --force-reinstall .
51 mv -f /tmp/.build ${WORKSPACE}/
53 DEPLOY_SETTINGS_DIR="/etc/opnfv-apex/"
54 NETWORK_SETTINGS_DIR="/etc/opnfv-apex/"
55 CLEAN_CMD="opnfv-clean"
56 # set to use different directory here because upon RPM removal this
57 # directory will be wiped in daily
58 UPSTREAM_CACHE=$HOME/upstream_cache
59 if [[ "$BRANCH" != 'stable/fraser' ]]; then
60 mkdir -p ${UPSTREAM_CACHE}
61 RESOURCES=$UPSTREAM_CACHE
63 RESOURCES="/var/opt/opnfv/images"
65 DEPLOY_CMD="opnfv-deploy --image-dir ${RESOURCES}"
66 CONFIG="/var/opt/opnfv"
69 LIB="/var/opt/opnfv/lib"
70 sudo mkdir -p /var/log/apex
71 sudo chmod 777 /var/log/apex
75 # Install Dependencies
76 # Make sure python34 dependencies are installed
77 dependencies="epel-release python34 python34-devel libvirt-devel python34-pip \
78 ansible python34-PyYAML python34-jinja2 python34-setuptools python-tox ansible"
80 for dep_pkg in $dependencies; do
81 if ! rpm -q ${dep_pkg} > /dev/null; then
82 if ! sudo yum install -y ${dep_pkg}; then
83 echo "Failed to install ${dep_pkg}"
89 if [[ "$JOB_NAME" =~ "virtual" ]]; then
90 # Make sure ipxe-roms-qemu package is updated to latest.
91 # This package is needed for multi virtio nic PXE boot in virtual environment.
92 sudo yum update -y ipxe-roms-qemu
95 if [ "$OPNFV_CLEAN" == 'yes' ]; then
96 if sudo test -e '/root/inventory/pod_settings.yaml'; then
97 clean_opts='-i /root/inventory/pod_settings.yaml'
102 sudo ${CLEAN_CMD} ${clean_opts}
105 # These are add-ons to regular scenarios where you can do like
106 # os-nosdn-nofeature-noha-ipv6, or os-nosdn-nofeature-noha-allinone
107 if echo ${DEPLOY_SCENARIO} | grep ipv6; then
109 DEPLOY_SCENARIO=$(echo ${DEPLOY_SCENARIO} | sed 's/-ipv6//')
110 echo "INFO: IPV6 Enabled"
113 if echo ${DEPLOY_SCENARIO} | grep allinone; then
115 DEPLOY_SCENARIO=$(echo ${DEPLOY_SCENARIO} | sed 's/-allinone//')
116 echo "INFO: All in one deployment detected"
119 if echo ${DEPLOY_SCENARIO} | grep csit; then
121 DEPLOY_SCENARIO=$(echo ${DEPLOY_SCENARIO} | sed 's/-csit//')
122 echo "INFO: CSIT env requested in deploy scenario"
123 elif echo ${DEPLOY_SCENARIO} | grep functest; then
124 FUNCTEST_ENV_FLAG=True
125 DEPLOY_SCENARIO=$(echo ${DEPLOY_SCENARIO} | sed 's/-functest//')
126 echo "INFO: Functest env requested in deploy scenario"
129 echo "Deploy Scenario set to ${DEPLOY_SCENARIO}"
130 DEPLOY_FILE="${DEPLOY_SETTINGS_DIR}/${DEPLOY_SCENARIO}.yaml"
132 if [ ! -e "$DEPLOY_FILE" ]; then
133 echo "ERROR: Required settings file missing: Deploy settings file ${DEPLOY_FILE}"
136 if [[ "$JOB_NAME" =~ "virtual" ]]; then
137 # settings for virtual deployment
138 DEPLOY_CMD="${DEPLOY_CMD} -v"
139 if [[ "${DEPLOY_SCENARIO}" =~ fdio|ovs ]]; then
140 DEPLOY_CMD="${DEPLOY_CMD} --virtual-default-ram 12 --virtual-compute-ram 7"
142 if [[ "$ALLINONE_FLAG" == "True" ]]; then
143 DEPLOY_CMD="${DEPLOY_CMD} --virtual-computes 0"
144 elif [[ "$PROMOTE" == "True" ]]; then
145 DEPLOY_CMD="${DEPLOY_CMD} --virtual-computes 2"
148 if [[ "$FUNCTEST_ENV_FLAG" == "True" || "$CSIT_ENV_FLAG" == "True" ]]; then
149 if [[ "$CSIT_ENV_FLAG" == "True" ]]; then
154 if [ -z "$OS_VERSION" ]; then
155 echo "INFO: OS_VERSION not passed to deploy, detecting based on branch and scenario"
158 if [[ "$DEPLOY_SCENARIO" =~ "rocky" ]]; then
168 echo "Unable to detection OS_VERSION, aborting"
173 if [[ "$OS_VERSION" != "master" ]]; then
174 SNAP_ENV="${ENV_TYPE}-${OS_VERSION}-environment.yaml"
176 SNAP_ENV="${ENV_TYPE}-environment.yaml"
178 DEPLOY_CMD="${DEPLOY_CMD} -e ${SNAP_ENV}"
181 # settings for bare metal deployment
182 NETWORK_SETTINGS_DIR="/root/network"
183 INVENTORY_FILE="/root/inventory/pod_settings.yaml"
185 if ! sudo test -e "$INVENTORY_FILE"; then
186 echo "ERROR: Required settings file missing: Inventory settings file ${INVENTORY_FILE}"
189 # include inventory file for bare metal deployment
190 DEPLOY_CMD="${DEPLOY_CMD} -i ${INVENTORY_FILE}"
193 if [ "$IPV6_FLAG" == "True" ]; then
194 NETWORK_FILE="${NETWORK_SETTINGS_DIR}/network_settings_v6.yaml"
195 elif [[ "$CSIT_ENV_FLAG" == "True" || "$FUNCTEST_ENV_FLAG" == "True" ]]; then
196 # We use csit network settings which is single network for snapshots
197 NETWORK_FILE="${NETWORK_SETTINGS_DIR}/network_settings_csit.yaml"
199 NETWORK_FILE="${NETWORK_SETTINGS_DIR}/network_settings.yaml"
202 # Check that network settings file exists
203 if ! sudo test -e "$NETWORK_FILE"; then
204 echo "ERROR: Required settings file missing: Network Settings file ${NETWORK_FILE}"
209 sudo ${DEPLOY_CMD} -d ${DEPLOY_FILE} -n ${NETWORK_FILE} --debug
212 echo "--------------------------------------------------------"