mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 22:37:41 -02:30
Update views and serializers to support instance group (ramparts)
* includes top level views for instances and instance groups and extending those views to be able to view running jobs * Associative endpoints on Organizations, Inventories, and Job Templates * Related and summary field entries where appropriate * Adding job model references to executing instance group * Fix up default queue properties for clustering from the settings file * Update production and default settings for instance queues in settings
This commit is contained in:
@@ -14,7 +14,7 @@ from awx.main.models.jobs import Job
|
||||
from awx.main.models.projects import ProjectUpdate
|
||||
from awx.main.models.unified_jobs import UnifiedJob
|
||||
|
||||
__all__ = ('Instance', 'JobOrigin', 'TowerScheduleState',)
|
||||
__all__ = ('Instance', 'InstanceGroup', 'JobOrigin', 'TowerScheduleState',)
|
||||
|
||||
|
||||
class Instance(models.Model):
|
||||
@@ -34,6 +34,11 @@ class Instance(models.Model):
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
|
||||
@property
|
||||
def consumed_capacity(self):
|
||||
return sum(x.task_impact for x in UnifiedJob.objects.filter(execution_node=self.hostname,
|
||||
status__in=('running', 'waiting')))
|
||||
|
||||
@property
|
||||
def role(self):
|
||||
# NOTE: TODO: Likely to repurpose this once standalone ramparts are a thing
|
||||
@@ -52,6 +57,15 @@ class InstanceGroup(models.Model):
|
||||
help_text=_('Instances that are members of this InstanceGroup'),
|
||||
)
|
||||
|
||||
@property
|
||||
def capacity(self):
|
||||
return sum([x[0] for x in self.instances.values_list('capacity')])
|
||||
|
||||
@property
|
||||
def consumed_capacity(self):
|
||||
return sum(x.task_impact for x in UnifiedJob.objects.filter(instance_group=self,
|
||||
status__in=('running', 'waiting')))
|
||||
|
||||
class Meta:
|
||||
app_label = 'main'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user