From f30c93884fce46a2e40cc4a8b6e063d99a28e6e3 Mon Sep 17 00:00:00 2001 From: Anastasia Kuznetsova Date: Fri, 2 Sep 2016 17:31:51 +0300 Subject: [PATCH] Add initial version of script for zipping packages For running k8s and docker autotests against this repo we need to prepare and upload packages first. This is a POC of script, it should be refactored and improved in future, but for now we need to have some prototype somewhere, otherwise it will be hardcoded in jenkins job. Change-Id: I58c7965b275dd3a86de69f9e341c61edc04cc976 --- .gitreview | 2 +- tools/prepare_upload_packages.sh | 59 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 tools/prepare_upload_packages.sh diff --git a/.gitreview b/.gitreview index 1905299..e70a0ec 100644 --- a/.gitreview +++ b/.gitreview @@ -1,4 +1,4 @@ [gerrit] host=review.openstack.org port=29418 -project=openstack/k8s-docker-suite-app-murano.git +project=openstack/k8s-docker-suite-app-murano diff --git a/tools/prepare_upload_packages.sh b/tools/prepare_upload_packages.sh new file mode 100755 index 0000000..b9b6c27 --- /dev/null +++ b/tools/prepare_upload_packages.sh @@ -0,0 +1,59 @@ +refresh_existing_packages=true +script_dir="$(dirname $0)" +destination_dir="$(pwd)/murano-apps" + +echo "Preparing to zip archives ..." + +if [[ ! -d "$destination_dir" ]]; then + mkdir $destination_dir +fi + +packages_dirs="Applications Kubernetes DockerInterfacesLibrary DockerStandaloneHost" + +pushd "$script_dir/../" +for folder in $packages_dirs; do + if [[ ! -d "$folder" ]]; then + echo "Folder '$folder' doen't exist, skipping this step" + continue + fi + echo "Zipping $folder ..." + + pushd "$folder" + for d in $(find . -iname 'manifest.yaml' | xargs -n1 dirname); do + path="$d" + # get FQN for creating package + package_name="$(grep FullName "$path/manifest.yaml" | awk '{print $2}')" + filename="$destination_dir/$package_name.zip" + #TODO: prepare murano packages using 'murano package-create' cmd when bugs + # https://bugs.launchpad.net/python-muranoclient/+bug/1620981 and + # https://bugs.launchpad.net/python-muranoclient/+bug/1620984 are fixed + pushd "$path" + # check that file exist and remove it or create new version + if [ -f "$filename" ] ; then + if ! $refresh_existing_packages ; then + rm "$filename" + fi + fi + zip -r "$filename" ./* + popd + done + popd +done +popd + +echo "Uploading packages to Murano ..." + +INITIAL_MURANO_REPO_URL=$MURANO_REPO_URL +export MURANO_REPO_URL="mock.com" + +pushd "$destination_dir" + for package in $(ls); do + echo "Uploading $package" + murano package-import --exists-action u $destination_dir/$package + done +popd + +echo "Cleaning up..." + +export MURANO_REPO_URL=$INITIAL_MURANO_REPO_URL +rm -rf $destination_dir