mirror of
https://github.com/ansible/awx.git
synced 2026-03-04 10:11:05 -03:30
Strengthen attribute check for Tower configuration validations
This commit is contained in:
@@ -446,7 +446,9 @@ register(
|
|||||||
|
|
||||||
|
|
||||||
def logging_validate(serializer, attrs):
|
def logging_validate(serializer, attrs):
|
||||||
if not serializer.instance:
|
if not serializer.instance or \
|
||||||
|
not hasattr(serializer.instance, 'LOG_AGGREGATOR_HOST') or \
|
||||||
|
not hasattr(serializer.instance, 'LOG_AGGREGATOR_TYPE'):
|
||||||
return attrs
|
return attrs
|
||||||
errors = []
|
errors = []
|
||||||
if attrs.get('LOG_AGGREGATOR_ENABLED', False):
|
if attrs.get('LOG_AGGREGATOR_ENABLED', False):
|
||||||
|
|||||||
@@ -1089,7 +1089,9 @@ register(
|
|||||||
|
|
||||||
|
|
||||||
def tacacs_validate(serializer, attrs):
|
def tacacs_validate(serializer, attrs):
|
||||||
if not serializer.instance:
|
if not serializer.instance or \
|
||||||
|
not hasattr(serializer.instance, 'TACACSPLUS_HOST') or \
|
||||||
|
not hasattr(serializer.instance, 'TACACSPLUS_SECRET'):
|
||||||
return attrs
|
return attrs
|
||||||
errors = []
|
errors = []
|
||||||
host = serializer.instance.TACACSPLUS_HOST
|
host = serializer.instance.TACACSPLUS_HOST
|
||||||
|
|||||||
@@ -108,3 +108,5 @@ register_validate("category_a", validate_a)
|
|||||||
register_validate("category_b", validate_b)
|
register_validate("category_b", validate_b)
|
||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
It should be noted that each validation function will be invoked in two places: when updating the category it's responsible for and when updating the general category `all`. Always keep this fact in mind and test both situations when developing new validation functions.
|
||||||
|
|||||||
Reference in New Issue
Block a user