mirror of
https://github.com/ansible/awx.git
synced 2026-03-10 05:59:28 -02:30
Add URL and type fields to instances/instance groups.
This commit is contained in:
@@ -3395,7 +3395,7 @@ class InstanceSerializer(BaseSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Instance
|
model = Instance
|
||||||
fields = ("related", "id", "uuid", "hostname", "created", "modified",
|
fields = ("id", "type", "url", "related", "uuid", "hostname", "created", "modified",
|
||||||
"version", "capacity", "consumed_capacity", "percent_capacity_remaining", "jobs_running")
|
"version", "capacity", "consumed_capacity", "percent_capacity_remaining", "jobs_running")
|
||||||
|
|
||||||
def get_related(self, obj):
|
def get_related(self, obj):
|
||||||
@@ -3422,7 +3422,7 @@ class InstanceGroupSerializer(BaseSerializer):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = InstanceGroup
|
model = InstanceGroup
|
||||||
fields = ("related", "id", "name", "created", "modified", "capacity", "consumed_capacity",
|
fields = ("id", "type", "url", "related", "name", "created", "modified", "capacity", "consumed_capacity",
|
||||||
"percent_capacity_remaining", "jobs_running", "instances")
|
"percent_capacity_remaining", "jobs_running", "instances")
|
||||||
|
|
||||||
def get_related(self, obj):
|
def get_related(self, obj):
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from django.utils.translation import ugettext_lazy as _
|
|||||||
|
|
||||||
from solo.models import SingletonModel
|
from solo.models import SingletonModel
|
||||||
|
|
||||||
|
from awx.api.versioning import reverse
|
||||||
from awx.main.managers import InstanceManager
|
from awx.main.managers import InstanceManager
|
||||||
from awx.main.models.inventory import InventoryUpdate
|
from awx.main.models.inventory import InventoryUpdate
|
||||||
from awx.main.models.jobs import Job
|
from awx.main.models.jobs import Job
|
||||||
@@ -34,6 +35,9 @@ class Instance(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
app_label = 'main'
|
app_label = 'main'
|
||||||
|
|
||||||
|
def get_absolute_url(self, request=None):
|
||||||
|
return reverse('api:instance_detail', kwargs={'pk': self.pk}, request=request)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def consumed_capacity(self):
|
def consumed_capacity(self):
|
||||||
return sum(x.task_impact for x in UnifiedJob.objects.filter(execution_node=self.hostname,
|
return sum(x.task_impact for x in UnifiedJob.objects.filter(execution_node=self.hostname,
|
||||||
@@ -57,6 +61,9 @@ class InstanceGroup(models.Model):
|
|||||||
help_text=_('Instances that are members of this InstanceGroup'),
|
help_text=_('Instances that are members of this InstanceGroup'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def get_absolute_url(self, request=None):
|
||||||
|
return reverse('api:instance_group_detail', kwargs={'pk': self.pk}, request=request)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def capacity(self):
|
def capacity(self):
|
||||||
return sum([x[0] for x in self.instances.values_list('capacity')])
|
return sum([x[0] for x in self.instances.values_list('capacity')])
|
||||||
|
|||||||
Reference in New Issue
Block a user