summaryrefslogtreecommitdiffstats
path: root/xci/scripts/vm/build-dib-os.sh
diff options
context:
space:
mode:
authorMarkos Chandras <mchandras@suse.de>2017-10-03 10:25:28 +0100
committerMarkos Chandras <mchandras@suse.de>2017-10-04 10:18:40 +0100
commit6e6b5f8438c0fd3a4d9dffa04c5e97c80304a8b3 (patch)
treeb6b817aefa5f853c3e2fd6885649720853d4dfb8 /xci/scripts/vm/build-dib-os.sh
parentf1be44648ccb6ff9a73c953fa7838d0a177b8d93 (diff)
xci: scripts: vm: Add ability to use cached images for clean VM
Make it possible to use the hosted dib images from artifacts.opnfv.org instead of building a new one on every CI run. This way, we can reduce the time it takes to start the actual XCI deployment. Change-Id: Idb1f5e3929cc14502c3f7383a61d2fbd0a6eefaf Signed-off-by: Markos Chandras <mchandras@suse.de>
Diffstat (limited to 'xci/scripts/vm/build-dib-os.sh')
-rwxr-xr-xxci/scripts/vm/build-dib-os.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/xci/scripts/vm/build-dib-os.sh b/xci/scripts/vm/build-dib-os.sh
new file mode 100755
index 00000000..7547d40e
--- /dev/null
+++ b/xci/scripts/vm/build-dib-os.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2017 SUSE LINUX GmbH.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+ONE_DISTRO=${1:-}
+
+docker_cmd="sudo docker"
+# See if we can run docker as regular user.
+docker ps &> /dev/null && docker_cmd="docker"
+docker_name="docker_xci_builder_${ONE_DISTRO:-all}"
+
+# Destroy previous containers
+if eval $docker_cmd ps -a | grep -q ${docker_name} &>/dev/null; then
+ echo "Destroying previous container..."
+ eval $docker_cmd rm -f ${docker_name}
+fi
+
+# Prepare new working directory
+dib_workdir="${XCI_CACHE_DIR:-${HOME}/.cache/opnfv_xci_deploy}/clean_vm/images"
+[[ ! -d $dib_workdir ]] && mkdir -p $dib_workdir
+chmod 777 -R $dib_workdir
+
+# Record our information
+uid=$(id -u)
+gid=$(id -g)
+
+echo "Getting the latest docker image..."
+eval $docker_cmd pull hwoarang/docker-dib-xci:latest
+
+# Get rid of stale files
+rm -rf $dib_workdir/*.qcow2 $dib_workdir/*.sha256.txt $dib_workdir/*.d
+echo "Initiating dib build..."
+eval $docker_cmd run --name ${docker_name} \
+ --rm --privileged=true -e ONE_DISTRO=${ONE_DISTRO} \
+ -t -v $dib_workdir:$dib_workdir -w $dib_workdir \
+ hwoarang/docker-dib-xci '/usr/bin/do-build.sh'
+sudo chown $uid:$gid $dib_workdir/${ONE_DISTRO}.qcow2