Yedidyah Bar David has uploaded a new change for review.

Change subject: packaging: engine-backup: notify engine
......................................................................

packaging: engine-backup: notify engine

Change-Id: I44dac9764cad3e35b0cf2bedd7197209a7633d3d
Bug-Url: https://bugzilla.redhat.com/1188143
Signed-off-by: Yedidyah Bar David <d...@redhat.com>
---
M packaging/bin/engine-backup.sh
1 file changed, 38 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/28/40128/1

diff --git a/packaging/bin/engine-backup.sh b/packaging/bin/engine-backup.sh
index ac45ef0..f0648cb 100755
--- a/packaging/bin/engine-backup.sh
+++ b/packaging/bin/engine-backup.sh
@@ -135,6 +135,11 @@
 REPORTSDB_BACKUP_FILE_NAME="reports_backup.db"
 
 cleanup() {
+       ec="$?"
+       if [ -n "${ENGINE_DB_USER}" -a "${ec}" = '1' -a "${MODE}" = "backup" ]; 
then
+               notify_engine "${ENGINE_DB_USER}" "${ENGINE_DB_HOST}" 
"${ENGINE_DB_PORT}" "${ENGINE_DB_DATABASE}" -1 "Failed"
+       fi
+
        [ -n "${TEMP_FOLDER}" ] && rm -rf "${TEMP_FOLDER}"
 }
 
@@ -589,6 +594,9 @@
        output "Backing up:"
        log "Generating pgpass"
        generatePgPass
+       if [ -n "${ENGINE_DB_USER}" ]; then
+               notify_engine "${ENGINE_DB_USER}" "${ENGINE_DB_HOST}" 
"${ENGINE_DB_PORT}" "${ENGINE_DB_DATABASE}" 0 "Started"
+       fi
 
        # Create temporary folder
        local tardir="${TEMP_FOLDER}/tar"
@@ -624,6 +632,10 @@
        output "Packing into file '${FILE}'"
        log "Creating tarball ${FILE}"
        createtar "${tardir}" "${FILE}"
+       if [ -n "${ENGINE_DB_USER}" ]; then
+               notify_engine "${ENGINE_DB_USER}" "${ENGINE_DB_HOST}" 
"${ENGINE_DB_PORT}" "${ENGINE_DB_DATABASE}" 1 "Finished"
+       fi
+
 }
 
 createtar() {
@@ -1200,6 +1212,32 @@
        done
 }
 
+notify_engine() {
+       local user="$1"
+       local host="$2"
+       local port="$3"
+       local database="$4"
+       local status="$5"
+       local message="$6"
+       # TODO decide how to write message
+
+       local psqllog="${TEMP_FOLDER}/psql-notification-log"
+
+       output "Notifying engine"
+       PGPASSFILE="${MYPGPASS}" psql \
+               -w \
+               -t \
+               -U "${user}" \
+               -h "${host}" \
+               -p "${port}" \
+               -d "${database}" \
+               -c "SELECT LogEngineBackupEvent('engine', now(), ${status}, 
'${LOG}');"
+               > "${psqllog}"  2>&1 \
+               || logdie "Failed notifying engine"
+       cat "${psqllog}" >> "${LOG}"  2>&1 \
+               || logdie "Failed to append psql log to main log"
+}
+
 ## Main
 
 my_load_config


-- 
To view, visit https://gerrit.ovirt.org/40128
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I44dac9764cad3e35b0cf2bedd7197209a7633d3d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Yedidyah Bar David <d...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to