diff --git a/awx/main/models/ad_hoc_commands.py b/awx/main/models/ad_hoc_commands.py index 1a48bbffcb..a1db3f6d73 100644 --- a/awx/main/models/ad_hoc_commands.py +++ b/awx/main/models/ad_hoc_commands.py @@ -201,6 +201,17 @@ class AdHocCommand(UnifiedJob): update_fields.append('name') super(AdHocCommand, self).save(*args, **kwargs) + # AdHocCommand Credential required + @property + def can_start(self): + if not super(AdHocCommand, self).can_start: + return False + + if not (self.credential and self.credential.active): + return False + + return True + class AdHocCommandEvent(CreatedModifiedModel): ''' diff --git a/awx/main/models/inventory.py b/awx/main/models/inventory.py index 6769efc28d..9bf848b1e0 100644 --- a/awx/main/models/inventory.py +++ b/awx/main/models/inventory.py @@ -1247,6 +1247,19 @@ class InventoryUpdate(UnifiedJob, InventorySourceOptions): def task_impact(self): return 50 + # InventoryUpdate credential required + # Custom InventoryUpdate credential not required + @property + def can_start(self): + if not super(InventoryUpdate, self).can_start: + return False + + if self.source != 'custom' \ + and not (self.credential and self.credential.active): + return False + return True + + class CustomInventoryScript(CommonModelNameNotUnique): class Meta: diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index 714ac794de..53dcdad818 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -491,6 +491,17 @@ class Job(UnifiedJob, JobOptions): presets[kw] = getattr(self, kw) return self.job_template.create_unified_job(**presets) + # Job Credential required + @property + def can_start(self): + if not super(Job, self).can_start: + return False + + if not (self.credential and self.credential.active): + return False + + return True + class JobHostSummary(CreatedModifiedModel): ''' Per-host statistics for each job.