summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Reports/Updater/Routines.py
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2012-06-04 16:09:00 -0500
committerTim Laszlo <tim.laszlo@gmail.com>2012-06-04 16:12:04 -0500
commitd711dd20ca577779493e2c7ee3cd4a592adf4b90 (patch)
tree7c1101eb8f345e03ce4b51bf428f50f0dcd0076d /src/lib/Bcfg2/Server/Reports/Updater/Routines.py
parent4c86dd989773aeb010ac9c583bb9de21ea4fc023 (diff)
downloadbcfg2-d711dd20ca577779493e2c7ee3cd4a592adf4b90.tar.gz
bcfg2-d711dd20ca577779493e2c7ee3cd4a592adf4b90.tar.bz2
bcfg2-d711dd20ca577779493e2c7ee3cd4a592adf4b90.zip
DBStats: drop database table for ping
Diffstat (limited to 'src/lib/Bcfg2/Server/Reports/Updater/Routines.py')
-rw-r--r--src/lib/Bcfg2/Server/Reports/Updater/Routines.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lib/Bcfg2/Server/Reports/Updater/Routines.py b/src/lib/Bcfg2/Server/Reports/Updater/Routines.py
index 1d41848e4..b500fd0a6 100644
--- a/src/lib/Bcfg2/Server/Reports/Updater/Routines.py
+++ b/src/lib/Bcfg2/Server/Reports/Updater/Routines.py
@@ -1,4 +1,5 @@
import logging
+import traceback
from django.db.models.fields import NOT_PROVIDED
from django.db import connection, DatabaseError, backend, models
from django.core.management.color import no_style
@@ -232,6 +233,26 @@ class RemoveColumns(RebuildTable):
raise UpdaterRoutineException
+class DropTable(UpdaterRoutine):
+ """
+ Drop a table
+ """
+ def __init__(self, table_name):
+ self.table_name = table_name
+
+ def __str__(self):
+ return "Drop table %s" % self.table_name
+
+ def run(self):
+ try:
+ cursor = connection.cursor()
+ cursor.execute('DROP TABLE %s' % _quote(self.table_name))
+ except DatabaseError:
+ logger.error("Failed to drop table: %s" %
+ traceback.format_exc().splitlines()[-1])
+ raise UpdaterRoutineException
+
+
class UpdaterCallable(UpdaterRoutine):
"""Helper for routines. Basically delays execution"""
def __init__(self, fn):