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

Merge pull request #1439 from ryanpetrello/fix-7923

add validation to InventorySource.inventory to avoid task manager death
This commit is contained in:
Ryan Petrello 2018-03-05 15:12:24 -05:00 committed by GitHub
commit 1596b2907b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -1653,6 +1653,8 @@ class InventoryUpdate(UnifiedJob, InventorySourceOptions, JobNotificationMixin,
organization_groups = [] organization_groups = []
if self.inventory_source.inventory is not None: if self.inventory_source.inventory is not None:
inventory_groups = [x for x in self.inventory_source.inventory.instance_groups.all()] inventory_groups = [x for x in self.inventory_source.inventory.instance_groups.all()]
else:
inventory_groups = []
selected_groups = inventory_groups + organization_groups selected_groups = inventory_groups + organization_groups
if not selected_groups: if not selected_groups:
return self.global_instance_groups return self.global_instance_groups

View File

@ -1998,6 +1998,9 @@ class RunInventoryUpdate(BaseTask):
inventory_source = inventory_update.inventory_source inventory_source = inventory_update.inventory_source
inventory = inventory_source.inventory inventory = inventory_source.inventory
if inventory is None:
raise RuntimeError('Inventory Source is not associated with an Inventory.')
# Piece together the initial command to run via. the shell. # Piece together the initial command to run via. the shell.
args = ['awx-manage', 'inventory_import'] args = ['awx-manage', 'inventory_import']
args.extend(['--inventory-id', str(inventory.pk)]) args.extend(['--inventory-id', str(inventory.pk)])