NFVBENCH-134 Support multiple idle interfaces per test VM
[nfvbench.git] / nfvbenchvm / dib / build-image.sh
1 #!/bin/bash
2 #
3 # A shell script to build the VPP VM image using diskinage-builder
4 #
5 # The following packages must be installed prior to using this script:
6 # sudo apt-get -y install python-virtualenv qemu-utils kpartx
7
8 set -e
9
10 # Artifact URL
11 gs_url=artifacts.opnfv.org/nfvbench/images
12
13 # image version number
14 __version__=0.7
15 image_name=nfvbenchvm_centos-$__version__
16
17 # if image exists skip building
18 if  command -v gsutil >/dev/null; then
19     if gsutil -q stat gs://$gs_url/$image_name.qcow2; then
20         echo "Image already exists at http://$gs_url/$image_name.qcow2"
21         exit 0
22     fi
23 else
24     echo "Cannot check image availability in OPNFV artifact repository (gsutil not available)"
25 fi
26
27 # install diskimage-builder
28 if [ -d dib-venv ]; then
29     . dib-venv/bin/activate
30 else
31     virtualenv dib-venv
32     . dib-venv/bin/activate
33     pip install diskimage-builder
34 fi
35
36 # Add nfvbenchvm_centos elements directory to the DIB elements path
37 export ELEMENTS_PATH=`pwd`/elements
38
39 # canned user/password for direct login
40 export DIB_DEV_USER_USERNAME=nfvbench
41 export DIB_DEV_USER_PASSWORD=nfvbench
42 export DIB_DEV_USER_PWDLESS_SUDO=Y
43
44 # Set the data sources to have ConfigDrive only
45 export DIB_CLOUD_INIT_DATASOURCES="ConfigDrive"
46
47 # Configure VPP REPO
48 export DIB_YUM_REPO_CONF=$ELEMENTS_PATH/nfvbenchvm/fdio-release.repo
49
50 # Use ELRepo to have latest kernel
51 export DIB_USE_ELREPO_KERNEL=True
52
53 echo "Building $image_name.qcow2..."
54 time disk-image-create -o $image_name centos7 nfvbenchvm
55 ls -l $image_name.qcow2
56
57 if command -v gsutil >/dev/null; then
58     echo "Uploading $image_name.qcow2..."
59     gsutil cp $image_name.qcow2 gs://$gs_url/$image_name.qcow2
60     echo "You can access to image at http://$gs_url/$image_name.qcow2"
61 else
62     echo "Cannot upload new image to the OPNFV artifact repository (gsutil not available)"
63 fi