diff options
author | Tim Laszlo <tim.laszlo@gmail.com> | 2010-07-15 20:48:02 +0000 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2010-07-16 16:36:15 -0500 |
commit | 84b3bcd2d27e92323ac699fd84a9c1130d85280f (patch) | |
tree | a1934db43baf1afd94471a25807068dc38649d92 /src/lib/Server/Admin/Reports.py | |
parent | c76279defd35949ec87fa243acae6e141ee201ee (diff) | |
download | bcfg2-84b3bcd2d27e92323ac699fd84a9c1130d85280f.tar.gz bcfg2-84b3bcd2d27e92323ac699fd84a9c1130d85280f.tar.bz2 bcfg2-84b3bcd2d27e92323ac699fd84a9c1130d85280f.zip |
DBStats: Support for postgresql
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5975 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Admin/Reports.py')
-rwxr-xr-x | src/lib/Server/Admin/Reports.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/lib/Server/Admin/Reports.py b/src/lib/Server/Admin/Reports.py index 87a91a2bd..d11451852 100755 --- a/src/lib/Server/Admin/Reports.py +++ b/src/lib/Server/Admin/Reports.py @@ -35,7 +35,7 @@ sys.path.pop() # Set DJANGO_SETTINGS_MODULE appropriately. os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % project_name -from django.db import connection +from django.db import connection, transaction from Bcfg2.Server.Reports.reports.models import Client, Interaction, Entries, \ Entries_interactions, Performance, \ @@ -109,6 +109,7 @@ class Reports(Bcfg2.Server.Admin.Mode): else: print "Unknown command: %s" % args[0] + @transaction.commit_on_success def scrub(self): ''' Perform a thorough scrub and cleanup of the database ''' @@ -134,7 +135,7 @@ class Reports(Bcfg2.Server.Admin.Mode): if key in cmp_reasons: self.log.debug("Update interactions from %d to %d" \ % (reason.id, cmp_reasons[key])) - dup_reasons.append(reason.id) + dup_reasons.append([reason.id]) batch_update.append([cmp_reasons[key], reason.id]) else: cmp_reasons[key] = reason.id @@ -145,8 +146,10 @@ class Reports(Bcfg2.Server.Admin.Mode): cursor = connection.cursor() cursor.executemany('update reports_entries_interactions set reason_id=%s where reason_id=%s', batch_update) cursor.executemany('delete from reports_reason where id = %s', dup_reasons) + transaction.set_dirty() except Exception, ex: self.log.error("Failed to delete reasons: %s" % ex) + raise self.log.info("Found %d dupes out of %d" % (len(dup_reasons), start_count)) @@ -182,5 +185,8 @@ class Reports(Bcfg2.Server.Admin.Mode): except (IOError, XMLSyntaxError): self.errExit("StatReports: Failed to parse %s"%(clientspath)) - load_stats(clientsdata, statsdata, verb, self.log, quick=quick, location=platform.node()) + try: + load_stats(clientsdata, statsdata, verb, self.log, quick=quick, location=platform.node()) + except: + pass |