Eli Mesika has uploaded a new change for review. Change subject: core: rhevm-upgrade creates log/helping files... ......................................................................
core: rhevm-upgrade creates log/helping files... rhevm-upgrade creates log/helping files in /usr/share/ovirt-engine/dbscripts This patch 1) moves intermediate *.md5 files creation to a temporary directory under /tmp 2) sets the default log location to /var/log/ovirt-engine/db 3) removes the .schema auto-creation, instead , there is a exportDbSchema.sh utility that can be invoked manually to generate this file. Change-Id: Id89c6d9267a7f739bc3584ab3a59888cece50fb7 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=947344 Signed-off-by: Eli Mesika <emes...@redhat.com> --- M backend/manager/dbscripts/create_schema.sh M backend/manager/dbscripts/dbcustomfunctions.sh M backend/manager/dbscripts/dbfunctions.sh A backend/manager/dbscripts/exportDbSchema.sh 4 files changed, 60 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/90/14090/1 diff --git a/backend/manager/dbscripts/create_schema.sh b/backend/manager/dbscripts/create_schema.sh index 6a94016..f2a514b 100755 --- a/backend/manager/dbscripts/create_schema.sh +++ b/backend/manager/dbscripts/create_schema.sh @@ -61,7 +61,7 @@ insert_initial_data #remove checksum file in clean install in order to run views/sp creation -rm -f .${DATABASE}.scripts.md5 >& /dev/null +rm -f ${MD5DIR}/.${DATABASE}.scripts.md5 >& /dev/null # Running upgrade scripts printf "Running upgrade scripts...\n" diff --git a/backend/manager/dbscripts/dbcustomfunctions.sh b/backend/manager/dbscripts/dbcustomfunctions.sh index 3d6d30d..dd00cf2 100755 --- a/backend/manager/dbscripts/dbcustomfunctions.sh +++ b/backend/manager/dbscripts/dbcustomfunctions.sh @@ -14,7 +14,6 @@ DATABASE="engine" USERNAME="" VERBOSE=false - LOGFILE="$ME.log" DBOBJECT_OWNER="engine" LC_ALL="C" export LC_ALL @@ -28,6 +27,17 @@ PGPASSFILE="${HOME}/.pgpass" fi export PGPASSFILE + # Setting *.md5 generated files dir + MD5DIR="$(mktemp -d)" + if [ ! -d "${MD5DIR}" ]; then + mkdir -p ${MD5DIR} + fi + # Setting log files dir + LOGDIR="/var/log/ovirt-engine/db" + LOGFILE="${LOGDIR}/${ME}.log" + if [ ! -d "${LOGDIR}" ]; then + mkdir -p ${LOGDIR} + fi } #refreshes views diff --git a/backend/manager/dbscripts/dbfunctions.sh b/backend/manager/dbscripts/dbfunctions.sh index 73e15d3..1f08012 100755 --- a/backend/manager/dbscripts/dbfunctions.sh +++ b/backend/manager/dbscripts/dbfunctions.sh @@ -266,7 +266,7 @@ is_view_or_sp_changed() { files=$(get_files "upgrade" 3) - md5sum_file=.${DATABASE}.scripts.md5 + md5sum_file=${MD5DIR}/.${DATABASE}.scripts.md5 md5sum_tmp_file=${md5sum_file}.tmp md5sum $files create_*views.sql *_sp.sql > ${md5sum_tmp_file} diff -s -q ${md5sum_file} ${md5sum_tmp_file} >& /dev/null @@ -382,8 +382,6 @@ # restore views & SPs if dropped if [ $updated -eq 1 ]; then run_post_upgrade - # auto generate .schema file - pg_dump -f .schema -F p -n public -s -U ${USERNAME} ${DATABASE} -h ${SERVERNAME} -p ${PORT} >& /dev/null else echo "database is up to date." fi diff --git a/backend/manager/dbscripts/exportDbSchema.sh b/backend/manager/dbscripts/exportDbSchema.sh new file mode 100755 index 0000000..7e4ffd8 --- /dev/null +++ b/backend/manager/dbscripts/exportDbSchema.sh @@ -0,0 +1,47 @@ +#!/bin/bash +#include db general functions +pushd $(dirname ${0})>/dev/null +source ./dbfunctions.sh +source ./dbcustomfunctions.sh + +#setting defaults +set_defaults + +usage() { + printf "Usage: ${ME} [-h] [-s SERVERNAME] [-d DATABASE] [-u USERNAME] [-v]\n" + printf "\n" + printf "\t-s SERVERNAME - The database servername for the database (def. ${SERVERNAME})\n" + printf "\t-d DATABASE - The database name (def. ${DATABASE})\n" + printf "\t-u USERNAME - The username for the database.\n" + printf "\t-l LOGFILE - The logfile for capturing output (def. ${LOGFILE}\n" + printf "\t-v - Turn on verbosity (WARNING: lots of output)\n" + printf "\t-h - This help text.\n" + printf "\n" + popd>/dev/null + exit $ret +} + +DEBUG () { + if $VERBOSE; then + printf "DEBUG: $*" + fi +} + +while getopts hs:d:u:p:l:v option; do + case $option in + s) SERVERNAME=$OPTARG;; + d) DATABASE=$OPTARG;; + u) USERNAME=$OPTARG;; + l) LOGFILE=$OPTARG;; + v) VERBOSE=true;; + h) ret=0 && usage;; + \?) ret=1 && usage;; + esac +done + +pg_dump -f .${DATABASE}.schema -F p -n public -s -U ${USERNAME} ${DATABASE} -h ${SERVERNAME} -p ${PORT} >& /dev/null + +printf "Done.\n" +printf "Exported file is .${DATABASE}.schema.\n" +popd>/dev/null +exit 0 -- To view, visit http://gerrit.ovirt.org/14090 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id89c6d9267a7f739bc3584ab3a59888cece50fb7 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <emes...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches