summaryrefslogtreecommitdiffstats
path: root/src
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
parent4c86dd989773aeb010ac9c583bb9de21ea4fc023 (diff)
downloadbcfg2-d711dd20ca577779493e2c7ee3cd4a592adf4b90.tar.gz
bcfg2-d711dd20ca577779493e2c7ee3cd4a592adf4b90.tar.bz2
bcfg2-d711dd20ca577779493e2c7ee3cd4a592adf4b90.zip
DBStats: drop database table for ping
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Server/Reports/Updater/Changes/1_3_0.py3
-rw-r--r--src/lib/Bcfg2/Server/Reports/Updater/Routines.py21
2 files changed, 23 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Server/Reports/Updater/Changes/1_3_0.py b/src/lib/Bcfg2/Server/Reports/Updater/Changes/1_3_0.py
index b09b06302..1a2fff1ea 100644
--- a/src/lib/Bcfg2/Server/Reports/Updater/Changes/1_3_0.py
+++ b/src/lib/Bcfg2/Server/Reports/Updater/Changes/1_3_0.py
@@ -6,7 +6,7 @@ The updates() method must be defined and it should return an Updater object
"""
from Bcfg2.Server.Reports.Updater import Updater, UpdaterError
from Bcfg2.Server.Reports.Updater.Routines import AddColumns, \
- RemoveColumns, RebuildTable
+ RemoveColumns, RebuildTable, DropTable
from Bcfg2.Server.Reports.reports.models import Reason, Interaction
@@ -21,6 +21,7 @@ def updates():
'perms', 'current_perms',
'status', 'current_status',
'to', 'current_to']))
+ fixes.add(DropTable('reports_ping'))
return fixes
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):