mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
restrict the running of jobs
The following jobs require a credential to launch * InventoryUpdate without custom script * Job * AdHocJob
This commit is contained in:
parent
0589f5ad06
commit
28d9b994eb
@ -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):
|
||||
'''
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user