mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-22 22:11:44 -07:00
ACI: Change RETURN output as discussed (#35617)
* ACI: Change result output as discussed * Update all modules to use new aci.exit_json() * Update output_level spec and docs * Fix integration tests * Small PEP8 fix * Asorted fixes to tests and aci_rest * More test fixes and support for ANSIBLE_DEBUG * Fix another PEP8 issues * Move response handling inside ACI module * Reform of ACI error handling and error output * Diff multiline json output * Fix a few more tests * Revert aci_bd tests * Small correction * UI change: existing->current, original->previous * UI change: config->sent * Update all modules with RETURN values * Fix a few more tests * Improve docstring and add 'raw' return value * Fix thinko * Fix sanity/pep8 issues * Rewrite unit tests to comply with new design
This commit is contained in:
parent
685dd5e8b4
commit
bee765fa6b
73 changed files with 5733 additions and 747 deletions
|
@ -102,7 +102,110 @@ EXAMPLES = r'''
|
|||
snapshot: run-2017-08-24T17-20-05
|
||||
'''
|
||||
|
||||
RETURN = r''' # '''
|
||||
RETURN = r'''
|
||||
current:
|
||||
description: The existing configuration from the APIC after the module has finished
|
||||
returned: success
|
||||
type: list
|
||||
sample:
|
||||
[
|
||||
{
|
||||
"fvTenant": {
|
||||
"attributes": {
|
||||
"descr": "Production environment",
|
||||
"dn": "uni/tn-production",
|
||||
"name": "production",
|
||||
"nameAlias": "",
|
||||
"ownerKey": "",
|
||||
"ownerTag": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
error:
|
||||
description: The error information as returned from the APIC
|
||||
returned: failure
|
||||
type: dict
|
||||
sample:
|
||||
{
|
||||
"code": "122",
|
||||
"text": "unknown managed object class foo"
|
||||
}
|
||||
raw:
|
||||
description: The raw output returned by the APIC REST API (xml or json)
|
||||
returned: parse error
|
||||
type: string
|
||||
sample: '<?xml version="1.0" encoding="UTF-8"?><imdata totalCount="1"><error code="122" text="unknown managed object class foo"/></imdata>'
|
||||
sent:
|
||||
description: The actual/minimal configuration pushed to the APIC
|
||||
returned: info
|
||||
type: list
|
||||
sample:
|
||||
{
|
||||
"fvTenant": {
|
||||
"attributes": {
|
||||
"descr": "Production environment"
|
||||
}
|
||||
}
|
||||
}
|
||||
previous:
|
||||
description: The original configuration from the APIC before the module has started
|
||||
returned: info
|
||||
type: list
|
||||
sample:
|
||||
[
|
||||
{
|
||||
"fvTenant": {
|
||||
"attributes": {
|
||||
"descr": "Production",
|
||||
"dn": "uni/tn-production",
|
||||
"name": "production",
|
||||
"nameAlias": "",
|
||||
"ownerKey": "",
|
||||
"ownerTag": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
proposed:
|
||||
description: The assembled configuration from the user-provided parameters
|
||||
returned: info
|
||||
type: dict
|
||||
sample:
|
||||
{
|
||||
"fvTenant": {
|
||||
"attributes": {
|
||||
"descr": "Production environment",
|
||||
"name": "production"
|
||||
}
|
||||
}
|
||||
}
|
||||
filter_string:
|
||||
description: The filter string used for the request
|
||||
returned: failure or debug
|
||||
type: string
|
||||
sample: ?rsp-prop-include=config-only
|
||||
method:
|
||||
description: The HTTP method used for the request to the APIC
|
||||
returned: failure or debug
|
||||
type: string
|
||||
sample: POST
|
||||
response:
|
||||
description: The HTTP response from the APIC
|
||||
returned: failure or debug
|
||||
type: string
|
||||
sample: OK (30 bytes)
|
||||
status:
|
||||
description: The HTTP status from the APIC
|
||||
returned: failure or debug
|
||||
type: int
|
||||
sample: 200
|
||||
url:
|
||||
description: The HTTP url used for the request to the APIC
|
||||
returned: failure or debug
|
||||
type: string
|
||||
sample: https://10.11.12.13/api/mo/uni/tn-production.json
|
||||
'''
|
||||
|
||||
from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
@ -140,7 +243,7 @@ def main():
|
|||
if max_count in range(1, 11):
|
||||
max_count = str(max_count)
|
||||
else:
|
||||
module.fail_json(msg='The "max_count" must be a number between 1 and 10')
|
||||
module.fail_json(msg="Parameter 'max_count' must be a number between 1 and 10")
|
||||
snapshot = module.params['snapshot']
|
||||
if snapshot is not None and not snapshot.startswith('run-'):
|
||||
snapshot = 'run-' + snapshot
|
||||
|
@ -209,13 +312,13 @@ def main():
|
|||
),
|
||||
)
|
||||
|
||||
if aci.result['existing']:
|
||||
if aci.existing:
|
||||
aci.get_diff('configSnapshot')
|
||||
|
||||
# Mark Snapshot for Deletion
|
||||
aci.post_config()
|
||||
|
||||
module.exit_json(**aci.result)
|
||||
aci.exit_json()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue