add an option to drop databases
authorStephen Soltesz <soltesz@cs.princeton.edu>
Wed, 7 Jan 2009 22:31:04 +0000 (22:31 +0000)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Wed, 7 Jan 2009 22:31:04 +0000 (22:31 +0000)
move a database model import to a function.

monitor-server.init
pcucontrol/reboot.py

index 3fb1728..f45360b 100644 (file)
@@ -421,6 +421,19 @@ case "$1" in
                result "$MESSAGE"
        ;;
 
+       delete)
+               MESSAGE=$"Deleting databases..."
+               dialog "$MESSAGE"
+
+               dropdb -U postgres $ZABBIX_DB_NAME
+               dropuser -U postgres $ZABBIX_DB_USER
+
+               dropdb -U postgres $MONITOR_DB_NAME
+               dropuser -U postgres $MONITOR_DB_USER
+
+               result "$MESSAGE"
+       ;;
+
        stop)
                MESSAGE=$"Stopping Monitor"
                dialog "$MESSAGE"
index 3ad6438..035aa01 100755 (executable)
@@ -27,7 +27,6 @@ sys.path.insert(0, os.path.dirname(sys.argv[0]) + "/pyssh")
 import pcucontrol.transports.pyssh as pyssh
 from monitor import config
 
-from monitor.database.info.model import FindbadPCURecord
 
 # Event class ID from pcu events
 #NODE_POWER_CONTROL = 3
@@ -336,6 +335,7 @@ def pcu_name(pcu):
                return None
 
 def get_pcu_values(pcu_id):
+       from monitor.database.info.model import FindbadPCURecord
        print "pcuid: %s" % pcu_id
        try:
                pcurec = FindbadPCURecord.get_latest_by(plc_pcuid=pcu_id).first()