mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-22 22:11:44 -07:00
Aci build url (#33017)
* ACI Buid URL: Refactor how ACI modules dynamically build proper URL. * Remove MIM URl from update * fix missing comma
This commit is contained in:
parent
e50f931cf3
commit
429af90027
32 changed files with 732 additions and 185 deletions
|
@ -147,13 +147,20 @@ def main():
|
|||
snapshot = module.params['snapshot']
|
||||
if snapshot is not None and not snapshot.startswith('run-'):
|
||||
snapshot = 'run-' + snapshot
|
||||
module.params['snapshot'] = snapshot
|
||||
state = module.params['state']
|
||||
|
||||
aci = ACIModule(module)
|
||||
|
||||
if state == 'present':
|
||||
aci.construct_url(root_class='export_policy')
|
||||
aci.construct_url(
|
||||
root_class=dict(
|
||||
aci_class='configExportP',
|
||||
aci_rn='fabric/configexp-{}'.format(export_policy),
|
||||
filter_target='(configExportP.name, "{}")'.format(export_policy),
|
||||
module_object=export_policy,
|
||||
),
|
||||
)
|
||||
|
||||
aci.get_existing()
|
||||
|
||||
# Filter out module params with null values
|
||||
|
@ -176,13 +183,25 @@ def main():
|
|||
aci.post_config()
|
||||
|
||||
else:
|
||||
# Add snapshot_container to module.params to build URL
|
||||
# Prefix the proper url to export_policy
|
||||
if export_policy is not None:
|
||||
module.params['snapshot_container'] = 'uni/fabric/configexp-{}'.format(module.params['export_policy'])
|
||||
else:
|
||||
module.params['snapshot_container'] = None
|
||||
export_policy = 'uni/fabric/configexp-{}'.format(export_policy)
|
||||
|
||||
aci.construct_url(
|
||||
root_class=dict(
|
||||
aci_class='configSnapshotCont',
|
||||
aci_rn='backupst/snapshots-[{}]'.format(export_policy),
|
||||
filter_target='(configSnapshotCont.name, "{}")'.format(export_policy),
|
||||
module_object=export_policy,
|
||||
),
|
||||
subclass_1=dict(
|
||||
aci_class='configSnapshot',
|
||||
aci_rn='snapshot-{}'.format(snapshot),
|
||||
filter_target='(configSnapshot.name, "{}")'.format(snapshot),
|
||||
module_object=snapshot,
|
||||
),
|
||||
)
|
||||
|
||||
aci.construct_url(root_class='snapshot_container', subclass_1='snapshot')
|
||||
aci.get_existing()
|
||||
|
||||
if state == 'absent':
|
||||
|
@ -201,9 +220,6 @@ def main():
|
|||
# Mark Snapshot for Deletion
|
||||
aci.post_config()
|
||||
|
||||
# Remove snapshot used to build URL from module.params
|
||||
module.params.pop('snapshot_container')
|
||||
|
||||
module.exit_json(**aci.result)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue