mirror of
https://github.com/ansible/awx.git
synced 2026-03-22 11:25:08 -02:30
Protect the system from when one attempts to start a job without an inventory
This commit is contained in:
@@ -417,6 +417,8 @@ class Job(UnifiedJob, JobOptions):
|
|||||||
|
|
||||||
def generate_dependencies(self, active_tasks):
|
def generate_dependencies(self, active_tasks):
|
||||||
from awx.main.models import InventoryUpdate, ProjectUpdate
|
from awx.main.models import InventoryUpdate, ProjectUpdate
|
||||||
|
if self.inventory is None or self.project is None:
|
||||||
|
return []
|
||||||
inventory_sources = self.inventory.inventory_sources.filter(active=True, update_on_launch=True)
|
inventory_sources = self.inventory.inventory_sources.filter(active=True, update_on_launch=True)
|
||||||
project_found = False
|
project_found = False
|
||||||
inventory_sources_found = []
|
inventory_sources_found = []
|
||||||
|
|||||||
@@ -102,7 +102,8 @@ def emit_update_inventory_on_created_or_deleted(sender, **kwargs):
|
|||||||
except Inventory.DoesNotExist:
|
except Inventory.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
update_inventory_computed_fields.delay(inventory.id, True)
|
if inventory is not None:
|
||||||
|
update_inventory_computed_fields.delay(inventory.id, True)
|
||||||
|
|
||||||
def store_initial_active_state(sender, **kwargs):
|
def store_initial_active_state(sender, **kwargs):
|
||||||
instance = kwargs['instance']
|
instance = kwargs['instance']
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ def update_inventory_computed_fields(inventory_id, should_update_hosts=True):
|
|||||||
i = Inventory.objects.filter(id=inventory_id)
|
i = Inventory.objects.filter(id=inventory_id)
|
||||||
if not i.exists():
|
if not i.exists():
|
||||||
logger.error("Update Inventory Computed Fields failed due to missing inventory: " + str(inventory_id))
|
logger.error("Update Inventory Computed Fields failed due to missing inventory: " + str(inventory_id))
|
||||||
|
return
|
||||||
i = i[0]
|
i = i[0]
|
||||||
i.update_computed_fields(update_hosts=should_update_hosts)
|
i.update_computed_fields(update_hosts=should_update_hosts)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user