restrict the running of jobs

The following jobs require a credential to launch
* InventoryUpdate without custom script
* Job
* AdHocJob
This commit is contained in:
Chris Meyers 2015-05-19 10:11:51 -04:00
parent 0589f5ad06
commit 28d9b994eb
3 changed files with 35 additions and 0 deletions

View File

@ -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):
'''

View File

@ -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:

View File

@ -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.