AC-505 Implement update_on_launch for inventory sources and dependency checking to prevent related inventory updates and jobs from happening simultaneously.

This commit is contained in:
Chris Church
2013-10-09 18:11:58 -04:00
parent 8531d6091f
commit 2f135f99d4
2 changed files with 88 additions and 5 deletions

View File

@@ -1599,7 +1599,16 @@ class JobTemplate(CommonModel):
Return whether job template can be used to start a new job without
requiring any user input.
'''
return bool(self.credential and not self.credential.passwords_needed)
needed = []
if self.credential:
needed.extend(self.credential.passwords_needed)
if self.project.scm_update_on_launch:
needed.extend(self.project.scm_passwords_needed)
for inventory_source in self.inventory.inventory_sources.filter(active=True, update_on_launch=True):
for pw in inventory_source.source_passwords_needed:
if pw not in needed:
needed.append(pw)
return bool(len(needed) == 0)
class Job(CommonModelNameNotUnique):
'''
@@ -1777,6 +1786,10 @@ class Job(CommonModelNameNotUnique):
needed.extend(self.credential.passwords_needed)
if self.project.scm_update_on_launch:
needed.extend(self.project.scm_passwords_needed)
for inventory_source in self.inventory.inventory_sources.filter(active=True, update_on_launch=True):
for pw in inventory_source.source_passwords_needed:
if pw not in needed:
needed.append(pw)
return needed
@property