ACI: Implement aci.boolean() to return an ACI boolean (#35610)

* ACI: Implement aci.boolean() to return an ACI boolean

A boolean value in ACI is not always standardized to yes/no.
Sometimes we have active/inactive, or enabled/disabled
Whereas the interface we want is a true YAML boolean.

We did not modify enabled/disabled values at this time.
I first want to determine if this implementation is acceptable.

* Support enabled/disabled as well, with deprecation messages

* Fix typo

* Fix PEP8 issue

* Ensure the aci object exists before using it

* Add comment to ensure this gets fixed in v2.9

* Fix typo
This commit is contained in:
Dag Wieers 2018-02-02 18:54:48 +01:00 committed by GitHub
commit 3dfede5642
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 96 additions and 88 deletions

View file

@ -46,7 +46,7 @@ options:
description:
- Determines if secure information should be included in the backup.
- The APIC defaults new Export Policies to C(yes).
choices: [ 'no', 'yes' ]
type: bool
default: 'yes'
max_count:
description:
@ -114,7 +114,7 @@ def main():
description=dict(type='str', aliases=['descr']),
export_policy=dict(type='str', aliases=['name']),
format=dict(type='str', choices=['json', 'xml']),
include_secure=dict(type='str', choices=['no', 'yes']),
include_secure=dict(type='bool'),
max_count=dict(type='int'),
snapshot=dict(type='str'),
state=dict(type='str', choices=['absent', 'present', 'query'], default='present'),
@ -129,10 +129,12 @@ def main():
],
)
aci = ACIModule(module)
description = module.params['description']
export_policy = module.params['export_policy']
file_format = module.params['format']
include_secure = module.params['include_secure']
include_secure = aci.boolean(module.params['include_secure'])
max_count = module.params['max_count']
if max_count is not None:
if max_count in range(1, 11):
@ -144,8 +146,6 @@ def main():
snapshot = 'run-' + snapshot
state = module.params['state']
aci = ACIModule(module)
if state == 'present':
aci.construct_url(
root_class=dict(