1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

Merge pull request #6061 from AlanCoding/new_inv_src_fix

Fix bug that is blocking creating new custom (script-based) inventory sources
This commit is contained in:
Alan Rominger 2017-04-19 14:20:58 -04:00 committed by GitHub
commit 498abd6764

View File

@ -1471,7 +1471,13 @@ class InventorySourceOptionsSerializer(BaseSerializer):
errors['source_script'] = _("If 'source' is 'custom', 'source_script' must be provided.") errors['source_script'] = _("If 'source' is 'custom', 'source_script' must be provided.")
else: else:
try: try:
if source_script.organization != self.instance.inventory.organization: if not self.instance:
dest_inventory = attrs.get('inventory', None)
if not dest_inventory:
errors['inventory'] = _("Must provide an inventory.")
else:
dest_inventory = self.instance.inventory
if source_script.organization != dest_inventory.organization:
errors['source_script'] = _("The 'source_script' does not belong to the same organization as the inventory.") errors['source_script'] = _("The 'source_script' does not belong to the same organization as the inventory.")
except Exception as exc: except Exception as exc:
errors['source_script'] = _("'source_script' doesn't exist.") errors['source_script'] = _("'source_script' doesn't exist.")