mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
ACI Query: Update var name to be unique (#33217)
* ACI Query: Update var name to be unique * Update dict copy to use deepcopy * Update dict copy to use deepcopy
This commit is contained in:
parent
1057ec3dc4
commit
5e46a0add6
1 changed files with 13 additions and 11 deletions
|
@ -31,6 +31,7 @@
|
|||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import json
|
||||
from copy import deepcopy
|
||||
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
from ansible.module_utils._text import to_bytes
|
||||
|
@ -322,13 +323,14 @@ class ACIModule(object):
|
|||
"""
|
||||
obj_class = obj['aci_class']
|
||||
obj_rn = obj['aci_rn']
|
||||
mo = obj['module_object']
|
||||
|
||||
# State is present or absent
|
||||
if self.module.params['state'] != 'query':
|
||||
path = 'api/mo/uni/{}.json'.format(obj_rn)
|
||||
filter_string = '?rsp-prop-include=config-only' + child_includes
|
||||
# Query for all objects of the module's class
|
||||
elif obj is None:
|
||||
elif mo is None:
|
||||
path = 'api/class/{}.json'.format(obj_class)
|
||||
filter_string = ''
|
||||
# Query for a specific object in the module's class
|
||||
|
@ -351,7 +353,7 @@ class ACIModule(object):
|
|||
obj_class = obj['aci_class']
|
||||
obj_rn = obj['aci_rn']
|
||||
obj_filter = obj['filter_target']
|
||||
obj = obj['module_object']
|
||||
mo = obj['module_object']
|
||||
|
||||
if not child_includes:
|
||||
self_child_includes = '?rsp-subtree=full&rsp-subtree-class=' + obj_class
|
||||
|
@ -363,13 +365,13 @@ class ACIModule(object):
|
|||
path = 'api/mo/uni/{}/{}.json'.format(parent_rn, obj_rn)
|
||||
filter_string = '?rsp-prop-include=config-only' + child_includes
|
||||
# Query for all objects of the module's class
|
||||
elif obj is None and parent_obj is None:
|
||||
elif mo is None and parent_obj is None:
|
||||
path = 'api/class/{}.json'.format(obj_class)
|
||||
filter_string = ''
|
||||
# Queries when parent object is provided
|
||||
elif parent_obj is not None:
|
||||
# Query for specific object in the module's class
|
||||
if obj is not None:
|
||||
if mo is not None:
|
||||
path = 'api/mo/uni/{}/{}.json'.format(parent_rn, obj_rn)
|
||||
filter_string = ''
|
||||
# Query for all object's of the module's class that belong to a specific parent object
|
||||
|
@ -400,7 +402,7 @@ class ACIModule(object):
|
|||
obj_class = obj['aci_class']
|
||||
obj_rn = obj['aci_rn']
|
||||
obj_filter = obj['filter_target']
|
||||
obj = obj['module_object']
|
||||
mo = obj['module_object']
|
||||
|
||||
if not child_includes:
|
||||
self_child_includes = '&rsp-subtree=full&rsp-subtree-class=' + obj_class
|
||||
|
@ -417,7 +419,7 @@ class ACIModule(object):
|
|||
path = 'api/mo/uni/{}/{}/{}.json'.format(root_rn, parent_rn, obj_rn)
|
||||
filter_string = '?rsp-prop-include=config-only' + child_includes
|
||||
# Query for all objects of the module's class
|
||||
elif obj is None and parent_obj is None and root_obj is None:
|
||||
elif mo is None and parent_obj is None and root_obj is None:
|
||||
path = 'api/class/{}.json'.format(obj_class)
|
||||
filter_string = ''
|
||||
# Queries when root object is provided
|
||||
|
@ -425,7 +427,7 @@ class ACIModule(object):
|
|||
# Queries when parent object is provided
|
||||
if parent_obj is not None:
|
||||
# Query for a specific object of the module's class
|
||||
if obj is not None:
|
||||
if mo is not None:
|
||||
path = 'api/mo/uni/{}/{}/{}.json'.format(root_rn, parent_rn, obj_rn)
|
||||
filter_string = ''
|
||||
# Query for all objects of the module's class that belong to a specific parent object
|
||||
|
@ -433,7 +435,7 @@ class ACIModule(object):
|
|||
path = 'api/mo/uni/{}/{}.json'.format(root_rn, parent_rn)
|
||||
filter_string = self_child_includes.replace('&', '?', 1)
|
||||
# Query for all objects of the module's class that match the provided ID value and belong to a specefic root object
|
||||
elif obj is not None:
|
||||
elif mo is not None:
|
||||
path = 'api/mo/uni/{}.json'.format(root_rn)
|
||||
filter_string = '?rsp-subtree-filter=eq{}{}'.format(obj_filter, self_child_includes)
|
||||
# Query for all objects of the module's class that belong to a specific root object
|
||||
|
@ -444,7 +446,7 @@ class ACIModule(object):
|
|||
elif parent_obj is not None:
|
||||
# Query for all objects of the module's class that belong to any parent class
|
||||
# matching the provided ID values for both object and parent object
|
||||
if obj is not None:
|
||||
if mo is not None:
|
||||
path = 'api/class/{}.json'.format(parent_class)
|
||||
filter_string = '?query-target-filter=eq{}{}&rsp-subtree-filter=eq{}'.format(
|
||||
parent_filter, self_child_includes, obj_filter)
|
||||
|
@ -483,7 +485,7 @@ class ACIModule(object):
|
|||
obj_class = obj['aci_class']
|
||||
obj_rn = obj['aci_rn']
|
||||
# obj_filter = obj['filter_target']
|
||||
# obj = obj['module_object']
|
||||
# mo = obj['module_object']
|
||||
|
||||
# State is ablsent or present
|
||||
if self.module.params['state'] != 'query':
|
||||
|
@ -706,7 +708,7 @@ class ACIModule(object):
|
|||
if child_configs:
|
||||
children = []
|
||||
for child in child_configs:
|
||||
child_copy = child.copy()
|
||||
child_copy = deepcopy(child)
|
||||
has_value = False
|
||||
for root_key in child_copy.keys():
|
||||
for final_keys, values in child_copy[root_key]['attributes'].items():
|
||||
|
|
Loading…
Reference in a new issue