From 6e6b5f8438c0fd3a4d9dffa04c5e97c80304a8b3 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 3 Oct 2017 10:25:28 +0100 Subject: 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 --- xci/scripts/vm/build-dib-os.sh | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 xci/scripts/vm/build-dib-os.sh (limited to 'xci/scripts/vm/build-dib-os.sh') 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 -- cgit 1.2.3-korg