From cb43020cbf757bfd2fa2bd0291224ca8bcf99f64 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Fri, 17 Nov 2017 15:33:02 +0100 Subject: [PATCH] New tool to generate lxd images from an OSM installation and push them to ETSI FTP Change-Id: If178de582660690ff3f04af6fa1ef2961e7b1c24 Signed-off-by: garciadeblas --- tools/gen-lxdimages.sh | 85 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 tools/gen-lxdimages.sh diff --git a/tools/gen-lxdimages.sh b/tools/gen-lxdimages.sh new file mode 100755 index 00000000..10c59b9a --- /dev/null +++ b/tools/gen-lxdimages.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +function usage() { + echo -e "usage: $0 [OPTIONS]" + echo -e " OPTIONS" + echo -e " -c : the component whose lxd image has to be generated. Allowed values: RO, VCA, SOUI, MON" + echo -e " -R : push images to specific RELEASE folder" +} + +GEN_ALL="y" +GEN_RO="" +GEN_VCA="" +GEN_SOUI="" +GEN_MON="" +RELEASE="ReleaseTHREE" + +while getopts ":h" o; do + case "${o}" in + h) + usage + exit 0 + ;; + R) + RELEASE="${OPTARG}" + ;; + c) + [ "${OPTARG}" == "RO" ] && GEN_ALL="" && GEN_RO="y" && continue + [ "${OPTARG}" == "VCA" ] && GEN_ALL="" && GEN_VCA="y" && continue + [ "${OPTARG}" == "SOUI" ] && GEN_ALL="" && GEN_SOUI="y" && continue + [ "${OPTARG}" == "MON" ] && GEN_ALL="" && GEN_MON="y" && continue + echo -e "Invalid option: '--$OPTARG'\n" >&2 + usage && exit 1 + ;; + *) + usage && exit 1 + ;; + esac +done + +[ "$GEN_ALL" == "y" ] && GEN_RO="y" && GEN_VCA="y" && GEN_SOUI="y" && GEN_MON="y" + +echo "Stopping containers" +lxc stop RO +lxc stop VCA +lxc stop SO-ub +#lxc stop MON + +echo "Saving containers as images in local lxd server" +OSM_RO_IMAGE="osm-ro" +OSM_VCA_IMAGE="osm-vca" +OSM_SOUI_IMAGE="osm-soui" +OSM_MON_IMAGE="osm-mon" + +[ -n "$GEN_RO" ] && lxc publish --public RO --alias ${OSM_RO_IMAGE} +[ -n "$GEN_VCA" ] && lxc publish --public VCA --alias ${OSM_VCA_IMAGE} +[ -n "$GEN_SOUI" ] && lxc publish --public SO-ub --alias ${OSM_SOUI_IMAGE} +#[ -n "$GEN_MON" ] && lxc publish --public MON --alias ${OSM_MON_IMAGE} +#lxc image list + +#echo "Copying images to a remote lxd server" +#[ -n "$GEN_RO" ] && lxc image copy ${OSM_RO_IMAGE} remote: +#[ -n "$GEN_VCA" ] && lxc image copy ${OSM_VCA_IMAGE} remote: +#[ -n "$GEN_SOUI" ] && lxc image copy ${OSM_SOUI_IMAGE} remote: +#[ -n "$GEN_MON" ] && lxc image copy ${OSM_MON_IMAGE} remote: + +echo "Exporting images as targz" +TEMPDIR="$(mktemp -d -q --tmpdir "osmlxd.XXXXXX")" +trap 'rm -rf "$TEMPDIR"' EXIT +RELEASE_DIR="${TEMPDIR}/${RELEASE}" + +[ -n "$GEN_RO" ] && lxc image export ${OSM_RO_IMAGE} $RELEASE_DIR/${OSM_RO_IMAGE} +[ -n "$GEN_VCA" ] && lxc image export ${OSM_VCA_IMAGE} $RELEASE_DIR/${OSM_VCA_IMAGE} +[ -n "$GEN_SOUI" ] && lxc image export ${OSM_SOUI_IMAGE} $RELEASE_DIR/${OSM_SOUI_IMAGE} +#[ -n "$GEN_MON" ] && lxc image export ${OSM_MON_IMAGE} $RELEASE_DIR/${OSM_MON_IMAGE} +[ -n "$GEN_RO" ] && chmod +r $RELEASE_DIR/${OSM_RO_IMAGE} +[ -n "$GEN_VCA" ] && chmod +r $RELEASE_DIR/${OSM_VCA_IMAGE} +[ -n "$GEN_SOUI" ] && chmod +r $RELEASE_DIR/${OSM_SOUI_IMAGE} +#[ -n "$GEN_MON" ] && chmod +r $RELEASE_DIR/${OSM_MON_IMAGE} + +echo "Pushing images to ETSI FTP server" +RSYNC_USER_HOST=osmusers@osm-download.etsi.org +RSYNC_OPTIONS="--delete --password-file rsync.pass" +cd $TEMPDIR && rsync -avR $RSYNC_OPTIONS $RELEASE rsync://$RSYNC_USER_HOST/repos/osm/lxd + + -- 2.25.1