3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # A shell script to build the PROX VM image using diskimage-builder
19 echo " -v verify only (build but do not push to google storage)"
23 # Takes only 1 optional argument
30 if [ $1 = "-v" ]; then
39 gs_url=artifacts.opnfv.org/samplevnf/images
41 image_name=rapid-${GIT_BRANCH##*/}
43 # if image exists skip building
44 echo "Checking if image exists in google storage..."
45 if command -v gsutil >/dev/null; then
46 if gsutil -q stat gs://$gs_url/$image_name.qcow2; then
47 echo "Image already exists at http://$gs_url/$image_name.qcow2"
49 echo "Starting build..."
52 echo "Cannot check image availability in OPNFV artifact repository (gsutil not available)"
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
63 # Add rapid elements directory to the DIB elements path
64 export ELEMENTS_PATH=`pwd`/elements
65 # canned user/password for direct login
66 export DIB_DEV_USER_USERNAME=prox
67 export DIB_DEV_USER_PASSWORD=prox
68 export DIB_DEV_USER_PWDLESS_SUDO=Y
69 # Set the data sources to have ConfigDrive only
70 export DIB_CLOUD_INIT_DATASOURCES="Ec2, ConfigDrive, OpenStack"
71 # Use ELRepo to have latest kernel
72 export DIB_USE_ELREPO_KERNEL=True
73 echo "Building $image_name.qcow2..."
74 time disk-image-create -o $image_name centos7 cloud-init rapid vm
76 ls -l $image_name.qcow2
79 if [ $verify_only -eq 1 ]; then
80 echo "Image verification SUCCESS"
81 echo "NO upload to google storage (-v)"
83 if command -v gsutil >/dev/null; then
84 echo "Uploading $image_name.qcow2..."
85 gsutil cp $image_name.qcow2 gs://$gs_url/$image_name.qcow2
86 echo "You can access to image at http://$gs_url/$image_name.qcow2"
88 echo "Cannot upload new image to the OPNFV artifact repository (gsutil not available)"