#!/bin/bash # # Copyright 2014 Rackspace Australia # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # A tool to update a given dataset to a given version. Used to keep datasets # somewhat fresh rather than over-exercising old migrations. # Usage: ./update_datasets.sh VENV_NAME WORKING_DIR GIT_PATH DB_USER DB_PASS DB_NAME SEED_DATA OUTPUT_DATA # apt-get install git virtualenvwrapper python-pip mysql-server python-lxml build-essential libffi-dev # $1 is the unique job id # $2 is the working dir path # $3 is the path to the git repo path # $4 is the nova db user # $5 is the nova db password # $6 is the nova db name # $7 is the path to the seed dataset to test against # $8 is the logging.conf for openstack # $9 is the pip cache dir UNIQUE_ID=$1 WORKING_DIR_PATH=`realpath $2` GIT_REPO_PATH=`realpath $3` DB_USER=$4 DB_PASS=$5 DB_NAME=$6 DATASET_SEED_SQL=`realpath $7` DATASET_OUTPUT_SQL=$8 SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) # We also support the following environment variables to tweak our behavour: # NOCLEANUP: if set to anything, don't cleanup at the end of the run pip_requires() { pip install -q mysql-python pip install -q eventlet requires="tools/pip-requires" if [ ! -e $requires ] then requires="requirements.txt" fi echo "Install pip requirements from $requires" pip install -q -r $requires echo "Requirements installed" } db_sync() { # $1 is the test target (ie branch name) # $2 is an (optional) destination version number # Create a nova.conf file cat - > $WORKING_DIR_PATH/nova-$1.conf < $DATASET_OUTPUT_SQL