summaryrefslogtreecommitdiffstats
path: root/xci/scripts/update-osa-version-files.sh
diff options
context:
space:
mode:
authorMarkos Chandras <mchandras@suse.de>2017-06-15 14:13:33 +0100
committerTrevor Bramwell <tbramwell@linuxfoundation.org>2017-08-11 12:56:12 -0700
commitfec906c6ae80f79adf0612fb6e9c50b5f2d1e45e (patch)
treec8b9e9132d4971931b470c8b2d95d853afecb9cf /xci/scripts/update-osa-version-files.sh
parentaca10dfcb31bca73e7336d1553e1b48458bfcf66 (diff)
prototypes: xci: scripts: Add update-osa-version-files.sh script
Add new prototypes/xci/scripts/update-osa-version-files.sh which can be used to update the XCI ansible-role-requirements.yml file as well as the OSA pinned SHA string. This file is using the upstream 'sources-branch-updater-lib.sh' library from the openstack-ansible repository. Change-Id: I51b88c50cb2bffe0cf1b7aa054a5b237103fd92f Signed-off-by: Markos Chandras <mchandras@suse.de>
Diffstat (limited to 'xci/scripts/update-osa-version-files.sh')
-rw-r--r--xci/scripts/update-osa-version-files.sh85
1 files changed, 85 insertions, 0 deletions
diff --git a/xci/scripts/update-osa-version-files.sh b/xci/scripts/update-osa-version-files.sh
new file mode 100644
index 00000000..92df978b
--- /dev/null
+++ b/xci/scripts/update-osa-version-files.sh
@@ -0,0 +1,85 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2017 SUSE LINUX GmbH and others.
+# 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
+##############################################################################
+
+# This script is used to pin the SHAs for the various roles in the
+# ansible-role-requirements file
+
+set -e
+
+# NOTE(hwoarang) This could break if files are re-arranged in the future
+releng_xci_base="$(dirname $(readlink -f $0))/.."
+
+usage() {
+ echo """
+ ${0} <openstack-ansible commit SHA>
+ """
+ exit 0
+}
+
+cleanup() {
+ [[ -d $tempdir ]] && rm -rf $tempdir
+}
+
+printme() {
+ echo "===> $1"
+}
+
+# Only need a single argument
+[[ $# -ne 1 ]] && echo "Invalid number of arguments!" && usage
+
+tempdir="$(mktemp -d)"
+
+trap cleanup EXIT
+
+pushd $tempdir &> /dev/null
+
+printme "Downloading the sources-branch-updater-lib.sh library"
+
+printme "Cloning the openstack-ansible repository"
+(
+ git clone -q git://git.openstack.org/openstack/openstack-ansible && cd openstack-ansible && git checkout -q $1
+)
+
+popd &> /dev/null
+
+pushd $tempdir/openstack-ansible &> /dev/null
+source scripts/sources-branch-updater-lib.sh
+printme "Synchronize roles and packages"
+update_ansible_role_requirements "master" "false" "true"
+
+# Construct the ansible-role-requirements-file
+echo """---
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2017 Ericsson AB and others.
+# 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
+##############################################################################
+# these versions are extracted based on the osa commit ${1} on $(git --no-pager log -1 --format=%cI $1)
+# https://review.openstack.org/gitweb?p=openstack/openstack-ansible.git;a=commit;h=$1
+""" > $releng_xci_base/file/ansible-role-requirements.yml
+cat $tempdir/openstack-ansible/ansible-role-requirements.yml >> $releng_xci_base/file/ansible-role-requirements.yml
+
+# Update the pinned OSA version
+sed -i "/^export OPENSTACK_OSA_VERSION/s@:-\"[a-z0-9]*@:-\"${1}@" $releng_xci_base/config/pinned-versions
+
+popd &> /dev/null
+
+printme ""
+printme "======================= Report ============================"
+printme ""
+printme "The $releng_xci_base/file/ansible-role-requirements.yml and"
+printme "$releng_xci_base/config/pinned-versions files have been"
+printme "updated. Please make sure you test the end result before"
+printme "committing it!"
+printme ""
+printme "==========================================================="