Add common code for determining active (licensed) hosts with unique names, update licensing code and inventory import to use it. Implements https://trello.com/c/2Q9Mosks

This commit is contained in:
Chris Church
2014-12-03 19:41:01 -05:00
parent 6b91f46082
commit fcf7398ec6
3 changed files with 12 additions and 1 deletions

View File

@@ -8,6 +8,14 @@ from django.db import models
from django.utils.functional import cached_property
class HostManager(models.Manager):
"""Custom manager class for Hosts model."""
def active_count(self):
"""Return count of active, unique hosts for licensing."""
return self.filter(active=True, inventory__active=True).distinct('name').count()
class InstanceManager(models.Manager):
"""A custom manager class for the Instance model.