8276ae4bf22a0567cab5bc6a71dfb4e33cc65ac4
[iec.git] / deploy / compass / deployVM.sh
1 #!/bin/bash
2 set -x
3
4 # Building compass
5 build_compass(){
6   echo "*** begin Compass4nfv build:"
7
8   # Fix bug of getting IP address failure.
9   sed -i "s/inet addr:/inet /g" util/docker-compose/roles/compass/tasks/main.yml
10   sed -i "s/cut -d: -f2/cut -d ' ' -f10/g" util/docker-compose/roles/compass/tasks/main.yml
11
12   if [ ${HOST_ARCH} = 'aarch64' ]; then
13     curl -s http://people.linaro.org/~yibo.cai/compass/compass4nfv-arm64-fixup.sh | bash || true
14   fi
15
16   ./build.sh |& tee log1-Build.txt
17 }
18
19 # Clear environments
20 clear_env(){
21
22   if [ -d "${WORKSPACE}/compass4nfv" ]; then
23     sudo rm -rf ${WORKSPACE}/compass4nfv
24   fi
25
26   if [ -d "${WORKSPACE}/iec" ]; then
27     sudo rm -rf ${WORKSPACE}/iec
28   fi
29 }
30
31 # Configure parameters of Arm VMs
32 config_arm(){
33   # Remove the useless software list from software list( from line 28 to end).
34   sed -i '28,$d' deploy/adapters/ansible/kubernetes/ansible-kubernetes.yml
35   export ADAPTER_OS_PATTERN='(?i)ubuntu-16.04.*arm.*'
36   export OS_VERSION="xenial"
37   export KUBERNETES_VERSION="v1.13.0"
38
39   export DHA="deploy/conf/vm_environment/k8-nosdn-nofeature-noha.yml"
40   export NETWORK="deploy/conf/vm_environment/network.yml"
41   export VIRT_NUMBER=2 VIRT_CPUS=4 VIRT_MEM=4096 VIRT_DISK=50G
42 }
43
44 # Configure parameters of x86 VMs
45 config_x86(){
46   export NETWORK="deploy/conf/vm_environment/network.yml"
47   export DHA="/deploy/conf/vm_environment/os-nosdn-nofeature-noha.yml"
48   export OS_VERSION="xenial"
49   export TAR_URL="file://${INSTALLDIR}/work/building/compass.tar.gz"
50
51   sed -i '44,$d' deploy/adapters/ansible/openstack/HA-ansible-multinodes.yml
52
53   sed -i '/export OPENSTACK_VERSION=queens/a export VIRT_NUMBER=2' deploy.sh
54 }
55
56 echo "*** begin AUTO install: OPNFV Compass4nfv"
57
58 # before starting, stop all the compass docker
59 sudo docker rm -f "$(sudo docker ps | grep compass | cut -f1 -d' ')" || true
60
61 # shellcheck disable=SC2164
62 WORKSPACE=$(cd "$(dirname "$0")";pwd)
63
64 clear_env
65
66 git clone https://gerrit.opnfv.org/gerrit/compass4nfv
67
68 # prepare install directory
69 INSTALLDIR=${WORKSPACE}/compass4nfv
70 HOST_ARCH=$(uname -m)
71
72 cd compass4nfv || exit
73
74 # launch build script
75 build_compass
76
77 # Configure parameters of VMs
78 if [ ${HOST_ARCH} = 'aarch64' ]; then
79   config_arm
80 else
81   config_x86
82 fi
83
84 # launch deploy script
85 echo "*** begin Compass4nfv deploy:"
86 ./deploy.sh