mirror of
https://github.com/ansible/awx.git
synced 2026-01-20 06:01:25 -03:30
add inventory to schedule summary fields
* Use the same logic that related inventory uses. If there is an inventory that overrides the inventory on the unified job template then summarize that field. Else, use the inventory on the unified job template being scheduled.
This commit is contained in:
parent
d1cce109fb
commit
f37391397e
@ -4614,6 +4614,22 @@ class ScheduleSerializer(LaunchConfigurationBaseSerializer, SchedulePreviewSeria
|
||||
res['inventory'] = obj.unified_job_template.inventory.get_absolute_url(self.context.get('request'))
|
||||
return res
|
||||
|
||||
def get_summary_fields(self, obj):
|
||||
summary_fields = super(ScheduleSerializer, self).get_summary_fields(obj)
|
||||
inventory = None
|
||||
if obj.inventory:
|
||||
inventory = obj.inventory
|
||||
elif obj.unified_job_template and getattr(obj.unified_job_template, 'inventory', None):
|
||||
inventory = obj.unified_job_template.inventory
|
||||
else:
|
||||
return summary_fields
|
||||
|
||||
summary_fields['inventory'] = dict()
|
||||
for field in SUMMARIZABLE_FK_FIELDS['inventory']:
|
||||
summary_fields['inventory'][field] = getattr(inventory, field, None)
|
||||
|
||||
return summary_fields
|
||||
|
||||
def validate_unified_job_template(self, value):
|
||||
if type(value) == InventorySource and value.source not in SCHEDULEABLE_PROVIDERS:
|
||||
raise serializers.ValidationError(_('Inventory Source must be a cloud resource.'))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user