summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Reports/Updater/Routines.py
diff options
context:
space:
mode:
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):