summaryrefslogtreecommitdiffstats
path: root/jjb/apex/apex-deploy-baremetal.sh
blob: efb6561d7bdc3ebb27b60b6a0110c2f04e8d422c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail

# log info to console
echo "Starting the Apex baremetal deployment."
echo "--------------------------------------------------------"
echo

if [[ ! "$ARTIFACT_NAME" == "latest" ]]; then
    # if artifact name is passed the pull a
    # specific artifact from artifacts.opnfv.org
    RPM_INSTALL_PATH=$GS_URL/$ARTIFACT_NAME
else
    if [[ $BUILD_DIRECTORY == *apex-build* ]]; then
      BUILD_DIRECTORY=$WORKSPACE/../$BUILD_DIRECTORY
      echo "BUILD DIRECTORY modified to $BUILD_DIRECTORY"
    fi
    if [[ -f ${BUILD_DIRECTORY}/../opnfv.properties ]]; then
        # if opnfv.properties exists then use the
        # local build. Source the file so we get local OPNFV vars
        source ${BUILD_DIRECTORY}/../opnfv.properties
        RPM_INSTALL_PATH=${BUILD_DIRECTORY}/$(basename $OPNFV_RPM_URL)
    else
        # no opnfv.properties means use the latest from artifacts.opnfv.org
        # get the latest.properties to get the link to the latest artifact
        curl -s -o $WORKSPACE/opnfv.properties http://$GS_URL/latest.properties
        [[ -f opnfv.properties ]] || exit 1
        # source the file so we get OPNFV vars
        source opnfv.properties
        RPM_INSTALL_PATH=$OPNFV_RPM_URL
    fi
fi

if [ ! -e "$RPM_INSTALL_PATH" ]; then
   RPM_INSTALL_PATH=http://${OPNFV_RPM_URL}
fi

RPM_LIST=$RPM_INSTALL_PATH
for pkg in common undercloud; do
    RPM_LIST+=" ${RPM_INSTALL_PATH/opnfv-apex/opnfv-apex-${pkg}}"
done

# update / install the new rpm
if rpm -q opnfv-apex > /dev/null; then
   if [ $(basename $OPNFV_RPM_URL) == $(rpm -q opnfv-apex).rpm ]; then
     echo "RPM is already installed"
   elif sudo yum update -y $RPM_LIST | grep "does not update installed package"; then
       if ! sudo yum downgrade -y $RPM_LIST; then
         sudo yum remove -y opnfv-undercloud opnfv-common
         sudo yum downgrade -y $RPM_INSTALL_PATH
       fi
   fi
else
   sudo yum install -y $RPM_LIST;
fi

# cleanup environment before we start
sudo opnfv-clean
# initiate baremetal deployment
if [ -e /etc/opnfv-apex/network_settings.yaml ]; then
  if [ -n "$DEPLOY_SCENARIO" ]; then
    echo "Deploy Scenario set to ${DEPLOY_SCENARIO}"
    if [ -e /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml ]; then
      sudo opnfv-deploy -i  /root/inventory/pod_settings.yaml \
      -d /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml \
      -n /root/network/network_settings.yaml --debug
    else
      echo "File does not exist /etc/opnfv-apex/${DEPLOY_SCENARIO}.yaml"
      exit 1
    fi
  else
    echo "Deploy scenario not set!"
    exit 1
  fi
else
  echo "File /etc/opnfv-apex/network_settings.yaml does not exist!"
  exit 1
fi

echo
echo "--------------------------------------------------------"
echo "Done!"