3 # A shell script to build the VPP VM image using diskinage-builder
5 # The following packages must be installed prior to using this script:
6 # sudo apt-get -y install python-virtualenv qemu-utils kpartx
10 echo " -v verify only (build but do not push to google storage)"
14 # Takes only 1 optional argument
21 if [ $1 = "-v" ]; then
30 gs_url=artifacts.opnfv.org/nfvbench/images
32 # image version number
34 image_name=nfvbenchvm_centos-$__version__
36 # if image exists skip building
37 echo "Checking if image exists in google storage..."
38 if command -v gsutil >/dev/null; then
39 if gsutil -q stat gs://$gs_url/$image_name.qcow2; then
40 echo "Image already exists at http://$gs_url/$image_name.qcow2"
41 echo "Build is skipped"
44 echo "Image does not exist in google storage, starting build..."
47 echo "Cannot check image availability in OPNFV artifact repository (gsutil not available)"
50 # check if image is already built locally
51 if [ -f $image_name.qcow2 ]; then
52 echo "Image $image_name.qcow2 already exists locally"
55 # install diskimage-builder
56 if [ -d dib-venv ]; then
57 . dib-venv/bin/activate
60 . dib-venv/bin/activate
61 pip install diskimage-builder
64 # Add nfvbenchvm_centos elements directory to the DIB elements path
65 export ELEMENTS_PATH=`pwd`/elements
67 # canned user/password for direct login
68 export DIB_DEV_USER_USERNAME=nfvbench
69 export DIB_DEV_USER_PASSWORD=nfvbench
70 export DIB_DEV_USER_PWDLESS_SUDO=Y
72 # Set the data sources to have ConfigDrive only
73 export DIB_CLOUD_INIT_DATASOURCES="ConfigDrive"
76 export DIB_YUM_REPO_CONF=$ELEMENTS_PATH/nfvbenchvm/fdio-release.repo
78 # Use ELRepo to have latest kernel
79 export DIB_USE_ELREPO_KERNEL=True
81 echo "Building $image_name.qcow2..."
82 time disk-image-create -o $image_name centos7 nfvbenchvm
85 ls -l $image_name.qcow2
88 if [ $verify_only -eq 1 ]; then
89 echo "Image verification SUCCESS"
90 echo "NO upload to google storage (-v)"
92 if command -v gsutil >/dev/null; then
93 echo "Uploading $image_name.qcow2..."
94 gsutil cp $image_name.qcow2 gs://$gs_url/$image_name.qcow2
95 echo "You can access to image at http://$gs_url/$image_name.qcow2"
97 echo "Cannot upload new image to the OPNFV artifact repository (gsutil not available)"