mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
ACI: Fixes to recent change to parameter choices (#35968)
This PR includes: - Fixes related to the recent merge of #31637 and #34537 - A generic fix for a reference for assignment issue - Fixes to aci.boolean() in order to catch exception
This commit is contained in:
parent
d76db835ff
commit
01ba3a4efc
8 changed files with 42 additions and 36 deletions
|
@ -169,24 +169,34 @@ class ACIModule(object):
|
|||
|
||||
def boolean(self, value, true='yes', false='no'):
|
||||
''' Return an acceptable value back '''
|
||||
|
||||
# When we expect value is of type=bool
|
||||
if value is None:
|
||||
return None
|
||||
elif value is True:
|
||||
return true
|
||||
elif value is False:
|
||||
return false
|
||||
elif boolean(value) is True: # When type=raw, this supports Ansible booleans
|
||||
return true
|
||||
elif boolean(value) is False: # When type=raw, this supports Ansible booleans
|
||||
return false
|
||||
elif value == true: # When type=raw, this supports the original boolean values
|
||||
self.module.deprecate("Boolean value '%s' is no longer valid, please use 'yes' as a boolean value." % value, '2.9')
|
||||
return true
|
||||
elif value == false: # When type=raw, this supports the original boolean values
|
||||
self.module.deprecate("Boolean value '%s' is no longer valid, please use 'no' as a boolean value." % value, '2.9')
|
||||
return false
|
||||
else: # When type=raw, escalate back to user
|
||||
self.module.fail_json(msg="Boolean value '%s' is an invalid ACI boolean value.")
|
||||
|
||||
# When we expect value is of type=raw, deprecate in Ansible v2.8 (and all modules use type=bool)
|
||||
try:
|
||||
# This supports all Ansible boolean types
|
||||
bool_value = boolean(value)
|
||||
if bool_value is True:
|
||||
return true
|
||||
elif bool_value is False:
|
||||
return false
|
||||
except:
|
||||
# This provides backward compatibility to Ansible v2.4, deprecate in Ansible v2.8
|
||||
if value == true:
|
||||
self.module.deprecate("Boolean value '%s' is no longer valid, please use 'yes' as a boolean value." % value, '2.9')
|
||||
return true
|
||||
elif value == false:
|
||||
self.module.deprecate("Boolean value '%s' is no longer valid, please use 'no' as a boolean value." % value, '2.9')
|
||||
return false
|
||||
|
||||
# If all else fails, escalate back to user
|
||||
self.module.fail_json(msg="Boolean value '%s' is an invalid ACI boolean value.")
|
||||
|
||||
def iso8601_format(self, dt):
|
||||
''' Return an ACI-compatible ISO8601 formatted time: 2123-12-12T00:00:00.000+00:00 '''
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue