summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Reporting/models.py
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2012-10-09 06:41:11 -0500
committerTim Laszlo <tim.laszlo@gmail.com>2012-10-09 06:41:22 -0500
commitf065fbc48b4380fa9e723518d7465bd0e309b4a9 (patch)
tree338c34347580f8464a614df7064992c95e0f8b1e /src/lib/Bcfg2/Reporting/models.py
parent7a2a69a0c5a79c88874dd3ea3c9cecfb243fad4f (diff)
downloadbcfg2-f065fbc48b4380fa9e723518d7465bd0e309b4a9.tar.gz
bcfg2-f065fbc48b4380fa9e723518d7465bd0e309b4a9.tar.bz2
bcfg2-f065fbc48b4380fa9e723518d7465bd0e309b4a9.zip
Add prune routines
Diffstat (limited to 'src/lib/Bcfg2/Reporting/models.py')
-rw-r--r--src/lib/Bcfg2/Reporting/models.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Reporting/models.py b/src/lib/Bcfg2/Reporting/models.py
index 3a540587a..b8fe1b973 100644
--- a/src/lib/Bcfg2/Reporting/models.py
+++ b/src/lib/Bcfg2/Reporting/models.py
@@ -259,6 +259,12 @@ class Group(models.Model):
ordering = ('name',)
+ @staticmethod
+ def prune_orphans():
+ '''Prune unused groups'''
+ Group.objects.filter(interaction__isnull=True, group__isnull=True).delete()
+
+
class Bundle(models.Model):
"""
Bundles extracted from interactions
@@ -275,6 +281,12 @@ class Bundle(models.Model):
ordering = ('name',)
+ @staticmethod
+ def prune_orphans():
+ '''Prune unused bundles'''
+ Bundle.objects.filter(interaction__isnull=True, group__isnull=True).delete()
+
+
# new interaction models
class FilePerms(models.Model):
owner = models.CharField(max_length=128)
@@ -368,6 +380,12 @@ class BaseEntry(models.Model):
return isinstance(self, FailureEntry)
+ @classmethod
+ def prune_orphans(cls):
+ '''Remove unused entries'''
+ cls.objects.filter(interaction__isnull=True).delete()
+
+
class SuccessEntry(BaseEntry):
"""Base for successful entries"""
state = models.IntegerField(choices=TYPE_CHOICES)
@@ -411,7 +429,6 @@ class ActionEntry(SuccessEntry):
output = models.IntegerField(default=0)
ENTRY_TYPE = r"Action"
- #TODO - prune
class PackageEntry(SuccessEntry):