Kiril Nesenko has uploaded a new change for review.

Change subject: packaging: Clean pgpass file on engine-cleanup
......................................................................

packaging: Clean pgpass file on engine-cleanup

This patch will clean engine etries from pgpass file on engine-cleanup.
Entried will be removed from the files only if DB was removed.

Change-Id: I21cbde71bf0a2181f8e0b8ed31205c26d16d2134
Signed-off-by: Kiril Nesenko <[email protected]>
---
M packaging/fedora/setup/engine-cleanup.py
1 file changed, 29 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/20/7320/1

diff --git a/packaging/fedora/setup/engine-cleanup.py 
b/packaging/fedora/setup/engine-cleanup.py
index be8c767..696be8c 100755
--- a/packaging/fedora/setup/engine-cleanup.py
+++ b/packaging/fedora/setup/engine-cleanup.py
@@ -275,6 +275,35 @@
         self.dropped = True
         logging.debug("DB Drop completed successfully")
 
+
+
+        if os.path.exists(basedefs.DB_PASS_FILE):
+            backupFile = "%s.%s" % (basedefs.DB_PASS_FILE, 
utils.getCurrentDateTime())
+            logging.debug("Found existing pgpass file, backing current to %s" 
% (backupFile))
+            shutil.copyfile(basedefs.DB_PASS_FILE, backupFile)
+
+        lines = []
+        with open (basedefs.DB_PASS_FILE, 'r') as f:
+            lines = f.read().split('\n')
+            inEngine = None
+            newLines = lines[:]
+            for line in newLines:
+                if basedefs.PGPASS_FILE_HEADER_LINE.split('\n')[0] in line:
+                    inEngine=True
+
+                if basedefs.PGPASS_FILE_CLOSING_LINE in line:
+                    lines.remove(line)
+                    inEngine=False
+
+                if inEngine:
+                    lines.remove(line)
+        with open(basedefs.DB_PASS_FILE, 'w') as f:
+            for line in lines:
+                f.write("%s\n" % line)
+
+        logging.debug("Cleaning %s completed successfully" % 
basedefs.DB_PASS_FILE)
+
+
     def exists(self):
         """
         check that db exists


--
To view, visit http://gerrit.ovirt.org/7320
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I21cbde71bf0a2181f8e0b8ed31205c26d16d2134
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Kiril Nesenko <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to