Updated inventory script to only return active groups and active hosts for active inventories.

This commit is contained in:
Chris Church
2013-06-12 22:37:25 -04:00
parent 6f43190b2b
commit 6557fb33f3
4 changed files with 62 additions and 26 deletions

View File

@@ -117,6 +117,15 @@ class PrimordialModel(models.Model):
def __unicode__(self):
return unicode("%s-%s"% (self.name, self.id))
def mark_inactive(self, save=True):
'''Use instead of delete to rename and mark inactive.'''
if self.active:
if 'name' in self._meta.get_all_field_names():
self.name = "_deleted_%s_%s" % (now().isoformat(), self.name)
self.active = False
if save:
self.save()
class CommonModel(PrimordialModel):
''' a base model where the name is unique '''