Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
617115a
[minor_change] Addition of l3out Floating SVI module and its child mo…
shrsr Sep 21, 2023
1730144
[ignore] Addition of child to a child class in the 'aci_floating_svi'…
shrsr Sep 26, 2023
fa75f30
[ignore] Addition of 'l3out_floating_svi_path_attributes' module
shrsr Sep 26, 2023
5eb1f04
[ignore] Change in payload function of 'aci.py' in module_utils to de…
shrsr Sep 27, 2023
28bad78
[ignore] Addition of 'aci_l3out_floating_svi_path_attributes' module …
shrsr Sep 27, 2023
e8bf1ff
[ignore] Addition of a test file for the module 'l3out_floating_svi'
shrsr Sep 29, 2023
05acd43
[ignore] Addition of test files for 'floating_svi' modules and its co…
shrsr Sep 30, 2023
79c2824
[ignore] Addition of sub class 6 function to 'aci.py' of module_utils…
shrsr Oct 2, 2023
2b5ce7f
[ignore] Modified docs to represent relations between the 'floating_s…
shrsr Oct 3, 2023
72d1111
[ignore] Modified docs to exclude un-used parameters in the 'floating…
shrsr Oct 4, 2023
8264801
[ignore] Modified test file to include anchors in 'floating_svi_secon…
shrsr Oct 5, 2023
3e401f6
[ignore] Added a field for author in the modules of 'floating_svi'
shrsr Oct 11, 2023
6ae5766
[ignore] Removed the path changes made to 'aci_rest' which is part of…
shrsr Oct 11, 2023
4101af2
[ignore] Added ',' to a line of code to conform to black formatting i…
shrsr Oct 13, 2023
5392103
[ignore] Modified the name of the examples inside the module 'floatin…
shrsr Oct 20, 2023
8f78614
[ignore] Addition of code to incorporate different versions of apic i…
shrsr Nov 3, 2023
26b5141
[ignore] Addition of notes to attributes in the docs section of 'l3ou…
shrsr Nov 3, 2023
ca2d6c8
[ignore] Addition of test statements for 'aci_l3out_floating_svi' to …
shrsr Nov 7, 2023
870fb1c
[ignore] Fix syntax using black on aci_l3out_floating_svi_path
lhercot Nov 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 88 additions & 2 deletions plugins/module_utils/aci.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ def construct_url(
subclass_3=None,
subclass_4=None,
subclass_5=None,
subclass_6=None,
child_classes=None,
config_only=True,
):
Expand All @@ -796,6 +797,7 @@ def construct_url(
:type subclass_3: dict
:type subclass_4: dict
:type subclass_5: dict
:type subclass_6: dict
:type child_classes: list
:return: The path and filter_string needed to build the full URL.
"""
Expand All @@ -806,7 +808,9 @@ def construct_url(
else:
self.child_classes = set(child_classes)

if subclass_5 is not None:
if subclass_6 is not None:
self._construct_url_7(root_class, subclass_1, subclass_2, subclass_3, subclass_4, subclass_5, subclass_6, config_only)
elif subclass_5 is not None:
self._construct_url_6(root_class, subclass_1, subclass_2, subclass_3, subclass_4, subclass_5, config_only)
elif subclass_4 is not None:
self._construct_url_5(root_class, subclass_1, subclass_2, subclass_3, subclass_4, config_only)
Expand Down Expand Up @@ -1077,7 +1081,7 @@ def _construct_url_5(self, root, ter, sec, parent, obj, config_only=True):

def _construct_url_6(self, root, quad, ter, sec, parent, obj, config_only=True):
"""
This method is used by construct_url when the object is the fourth-level class.
This method is used by construct_url when the object is the fifth-level class.
"""
root_rn = root.get("aci_rn")
root_obj = root.get("module_object")
Expand Down Expand Up @@ -1145,6 +1149,85 @@ def _construct_url_6(self, root, quad, ter, sec, parent, obj, config_only=True):
# Query for a specific object of the module's class
self.path = "api/mo/uni/{0}/{1}/{2}/{3}/{4}/{5}.json".format(root_rn, quad_rn, ter_rn, sec_rn, parent_rn, obj_rn)

def _construct_url_7(self, root, quin, quad, ter, sec, parent, obj, config_only=True):
"""
This method is used by construct_url when the object is the sixth-level class.
"""
root_rn = root.get("aci_rn")
root_obj = root.get("module_object")
quin_rn = quin.get("aci_rn")
quin_obj = quin.get("module_object")
quad_rn = quad.get("aci_rn")
quad_obj = quad.get("module_object")
ter_rn = ter.get("aci_rn")
ter_obj = ter.get("module_object")
sec_rn = sec.get("aci_rn")
sec_obj = sec.get("module_object")
parent_rn = parent.get("aci_rn")
parent_obj = parent.get("module_object")
obj_class = obj.get("aci_class")
obj_rn = obj.get("aci_rn")
obj_filter = obj.get("target_filter")
mo = obj.get("module_object")

if self.child_classes is None:
self.child_classes = [obj_class]

if self.module.params.get("state") in ("absent", "present"):
# State is absent or present
self.path = "api/mo/uni/{0}/{1}/{2}/{3}/{4}/{5}/{6}.json".format(root_rn, quin_rn, quad_rn, ter_rn, sec_rn, parent_rn, obj_rn)
if config_only:
self.update_qs({"rsp-prop-include": "config-only"})
self.obj_filter = obj_filter
# TODO: Add all missing cases
elif root_obj is None:
self.child_classes.add(obj_class)
self.path = "api/class/{0}.json".format(obj_class)
self.update_qs({"query-target-filter": self.build_filter(obj_class, obj_filter)})
elif quin_obj is None:
self.child_classes.add(obj_class)
self.path = "api/mo/uni/{0}.json".format(root_rn)
# NOTE: No need to select by root_filter
# self.update_qs({'query-target-filter': self.build_filter(root_class, root_filter)})
# TODO: Filter by quin_filter, parent and obj_filter
self.update_qs({"rsp-subtree-filter": self.build_filter(obj_class, obj_filter)})
elif quad_obj is None:
self.child_classes.add(obj_class)
self.path = "api/mo/uni/{0}/{1}.json".format(root_rn, quin_rn)
# NOTE: No need to select by root_filter
# self.update_qs({'query-target-filter': self.build_filter(root_class, root_filter)})
# TODO: Filter by quin_filter, parent and obj_filter
self.update_qs({"rsp-subtree-filter": self.build_filter(obj_class, obj_filter)})
elif ter_obj is None:
self.child_classes.add(obj_class)
self.path = "api/mo/uni/{0}/{1}/{2}.json".format(root_rn, quin_rn, quad_rn)
# NOTE: No need to select by quad_filter
# self.update_qs({'query-target-filter': self.build_filter(quin_class, quin_filter)})
# TODO: Filter by ter_filter, parent and obj_filter
self.update_qs({"rsp-subtree-filter": self.build_filter(obj_class, obj_filter)})
elif sec_obj is None:
self.child_classes.add(obj_class)
self.path = "api/mo/uni/{0}/{1}/{2}/{3}.json".format(root_rn, quin_rn, quad_rn, ter_rn)
# NOTE: No need to select by ter_filter
# self.update_qs({'query-target-filter': self.build_filter(ter_class, ter_filter)})
# TODO: Filter by sec_filter, parent and obj_filter
self.update_qs({"rsp-subtree-filter": self.build_filter(obj_class, obj_filter)})
elif parent_obj is None:
self.child_classes.add(obj_class)
self.path = "api/mo/uni/{0}/{1}/{2}/{3}/{4}.json".format(root_rn, quin_rn, quad_rn, ter_rn, sec_rn)
# NOTE: No need to select by sec_filter
# self.update_qs({'query-target-filter': self.build_filter(sec_class, sec_filter)})
# TODO: Filter by parent_filter and obj_filter
self.update_qs({"rsp-subtree-filter": self.build_filter(obj_class, obj_filter)})
elif mo is None:
self.child_classes.add(obj_class)
self.path = "api/mo/uni/{0}/{1}/{2}/{3}/{4}/{5}.json".format(root_rn, quin_rn, quad_rn, ter_rn, sec_rn, parent_rn)
# NOTE: No need to select by parent_filter
# self.update_qs({'query-target-filter': self.build_filter(parent_class, parent_filter)})
else:
# Query for a specific object of the module's class
self.path = "api/mo/uni/{0}/{1}/{2}/{3}/{4}/{5}/{6}.json".format(root_rn, quin_rn, quad_rn, ter_rn, sec_rn, parent_rn, obj_rn)

def delete_config(self):
"""
This method is used to handle the logic when the modules state is equal to absent. The method only pushes a change if
Expand Down Expand Up @@ -1380,6 +1463,9 @@ def payload(self, aci_class, class_config, child_configs=None):
else:
child[root_key]["attributes"][final_keys] = str(values)
has_value = True
# TODO: This needs to be recursive in order to handle attributes and the children of the subsequent children of the child
if child_copy[root_key].get("children") is not None:
has_value = True
if has_value:
children.append(child)

Expand Down
Loading