mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
changed passwords_needed_to_start to take into acount if a credential is deleted
This commit is contained in:
@@ -1775,13 +1775,14 @@ class JobLaunchSerializer(BaseSerializer):
|
|||||||
passwords = self.context.get('passwords')
|
passwords = self.context.get('passwords')
|
||||||
data = self.context.get('data')
|
data = self.context.get('data')
|
||||||
|
|
||||||
|
credential = attrs.get('credential', None) or obj.credential
|
||||||
# fill passwords dict with request data passwords
|
# fill passwords dict with request data passwords
|
||||||
if obj.passwords_needed_to_start:
|
if credential.passwords_needed:
|
||||||
try:
|
try:
|
||||||
for p in obj.passwords_needed_to_start:
|
for p in credential.passwords_needed:
|
||||||
passwords[p] = data.get(p)
|
passwords[p] = data[p]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise serializers.ValidationError(obj.passwords_needed_to_start)
|
raise serializers.ValidationError(credential.passwords_needed)
|
||||||
return attrs
|
return attrs
|
||||||
|
|
||||||
def validate(self, attrs):
|
def validate(self, attrs):
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class AdHocCommand(UnifiedJob):
|
|||||||
@property
|
@property
|
||||||
def passwords_needed_to_start(self):
|
def passwords_needed_to_start(self):
|
||||||
'''Return list of password field names needed to start the job.'''
|
'''Return list of password field names needed to start the job.'''
|
||||||
if self.credential:
|
if self.credential and self.credential.active:
|
||||||
return self.credential.passwords_needed
|
return self.credential.passwords_needed
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ class JobOptions(BaseModel):
|
|||||||
@property
|
@property
|
||||||
def passwords_needed_to_start(self):
|
def passwords_needed_to_start(self):
|
||||||
'''Return list of password field names needed to start the job.'''
|
'''Return list of password field names needed to start the job.'''
|
||||||
if self.credential:
|
if self.credential and self.credential.active:
|
||||||
return self.credential.passwords_needed
|
return self.credential.passwords_needed
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|||||||
Reference in New Issue
Block a user