From de40f24493abaa6d74ab454cf8c09bdf9f1e058a Mon Sep 17 00:00:00 2001 From: Sabari Jaganathan <93724860+sajagana@users.noreply.github.com> Date: Tue, 18 Apr 2023 15:57:43 +0530 Subject: [PATCH 1/2] Added IP Dataplane attribute to the subnet and vrf module --- plugins/modules/aci_bd_subnet.py | 11 ++++++++++- plugins/modules/aci_vrf.py | 10 ++++++++++ .../integration/targets/aci_bd_subnet/tasks/main.yml | 3 +++ tests/integration/targets/aci_vrf/tasks/main.yml | 5 +++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/plugins/modules/aci_bd_subnet.py b/plugins/modules/aci_bd_subnet.py index c10db5c8c..3c61f0c1b 100644 --- a/plugins/modules/aci_bd_subnet.py +++ b/plugins/modules/aci_bd_subnet.py @@ -91,6 +91,13 @@ - The name of the Subnet. type: str aliases: [ name ] + dataplane: + description: + - The Dataplane IP Address Learning. + - The APIC defaults to C(enabled) when unset during creation. + type: str + choices: [ enabled, disabled ] + aliases: [ ip_dataplane ] tenant: description: - The name of the Tenant. @@ -369,6 +376,7 @@ def main(): state=dict(type="str", default="present", choices=["absent", "present", "query"]), tenant=dict(type="str", aliases=["tenant_name"]), # Not required for querying all objects name_alias=dict(type="str"), + dataplane=dict(type="str", choices=["enabled", "disabled"], aliases=["ip_dataplane"]), ) module = AnsibleModule( @@ -410,7 +418,7 @@ def main(): if subnet_control: subnet_control = SUBNET_CONTROL_MAPPING[subnet_control] name_alias = module.params.get("name_alias") - + dataplane = module.params.get("dataplane") aci.construct_url( root_class=dict( aci_class="fvTenant", @@ -447,6 +455,7 @@ def main(): scope=scope, virtual=enable_vip, nameAlias=name_alias, + ipDPLearning=dataplane, ), child_configs=[ {"fvRsBDSubnetToProfile": {"attributes": {"tnL3extOutName": route_profile_l3_out, "tnRtctrlProfileName": route_profile}}}, diff --git a/plugins/modules/aci_vrf.py b/plugins/modules/aci_vrf.py index 49c0c9fc1..418e05ef1 100644 --- a/plugins/modules/aci_vrf.py +++ b/plugins/modules/aci_vrf.py @@ -43,6 +43,13 @@ - The description for the VRF. type: str aliases: [ descr ] + dataplane: + description: + - The Dataplane IP Address Learning. + - The APIC defaults to C(enabled) when unset during creation. + type: str + choices: [ enabled, disabled ] + aliases: [ ip_dataplane ] state: description: - Use C(present) or C(absent) for adding or removing. @@ -256,6 +263,7 @@ def main(): preferred_group=dict(type="str", choices=["enabled", "disabled"]), match_type=dict(type="str", choices=["all", "at_least_one", "at_most_one", "none"]), name_alias=dict(type="str"), + dataplane=dict(type="str", choices=["enabled", "disabled"], aliases=["ip_dataplane"]), ) module = AnsibleModule( @@ -276,6 +284,7 @@ def main(): name_alias = module.params.get("name_alias") preferred_group = module.params.get("preferred_group") match_type = module.params.get("match_type") + dataplane = module.params.get("dataplane") if match_type is not None: match_type = MATCH_TYPE_MAPPING[match_type] @@ -308,6 +317,7 @@ def main(): pcEnfPref=policy_control_preference, name=vrf, nameAlias=name_alias, + ipDataPlaneLearning=dataplane, ), child_configs=[ dict(vzAny=dict(attributes=dict(prefGrMemb=preferred_group, matchT=match_type))), diff --git a/tests/integration/targets/aci_bd_subnet/tasks/main.yml b/tests/integration/targets/aci_bd_subnet/tasks/main.yml index 10f00990c..4332b4bed 100644 --- a/tests/integration/targets/aci_bd_subnet/tasks/main.yml +++ b/tests/integration/targets/aci_bd_subnet/tasks/main.yml @@ -68,6 +68,7 @@ scope: [private, shared] route_profile: default route_profile_l3_out: default + dataplane: disabled register: create_subnet2 - name: create subnet again - idempotency works @@ -105,8 +106,10 @@ - create_check_mode.sent.fvSubnet.attributes.name == create_subnet.sent.fvSubnet.attributes.name == 'anstest' - create_subnet is changed - create_subnet.current.0.fvSubnet.attributes.annotation == 'orchestrator:ansible' + - create_subnet.current.0.fvSubnet.attributes.ipDPLearning == 'enabled' - create_subnet.previous == [] - create_subnet2 is changed + - create_subnet2.current.0.fvSubnet.attributes.ipDPLearning == 'disabled' - create_subnet2.sent == create_subnet2.proposed - create_subnet2.sent.fvSubnet.attributes.scope == "private,shared" - create_subnet2.sent.fvSubnet.children.0.fvRsBDSubnetToProfile.attributes.tnL3extOutName == 'default' diff --git a/tests/integration/targets/aci_vrf/tasks/main.yml b/tests/integration/targets/aci_vrf/tasks/main.yml index fa3f1057c..904934019 100644 --- a/tests/integration/targets/aci_vrf/tasks/main.yml +++ b/tests/integration/targets/aci_vrf/tasks/main.yml @@ -35,6 +35,7 @@ <<: *aci_tenant_present vrf: anstest description: Ansible Test + dataplane: disabled check_mode: true register: vrf_present_check_mode @@ -62,6 +63,7 @@ policy_control_direction: egress preferred_group: enabled match_type: all + dataplane: "{{ fake_var | default(omit) }}" register: vrf_present_2 - name: create vrf without all necessary params - failure message works @@ -80,6 +82,7 @@ - vrf_present is changed - vrf_present.sent == vrf_present_check_mode.sent - vrf_present.current.0.fvCtx.attributes.annotation == 'orchestrator:ansible' + - vrf_present.current.0.fvCtx.attributes.ipDataPlaneLearning == 'disabled' - vrf_present.previous == [] - vrf_present_idempotent is not changed - vrf_present_idempotent.previous != [] @@ -88,9 +91,11 @@ - vrf_update.sent != vrf_update.proposed - vrf_update.sent.fvCtx.attributes.descr == 'Ansible Test Update' - vrf_update.sent.fvCtx.attributes.pcEnfPref == 'unenforced' + - vrf_update.current.0.fvCtx.attributes.ipDataPlaneLearning == 'disabled' - vrf_present_2.sent.fvCtx.attributes.name == 'anstest2' - vrf_present_2.sent.fvCtx.attributes.pcEnfDir == 'egress' - vrf_present_2.sent.fvCtx.attributes.descr == 'Ansible Test' + - vrf_present_2.current.0.fvCtx.attributes.ipDataPlaneLearning == 'enabled' - vrf_present_2.current.0.fvCtx.children.0.vzAny.attributes.matchT == 'All' - vrf_present_2.current.0.fvCtx.children.0.vzAny.attributes.prefGrMemb == 'enabled' - vrf_present_missing_param is failed From 7596b48c4585208caf0ecb8ce0226c14f7e132ed Mon Sep 17 00:00:00 2001 From: Sabari Jaganathan <93724860+sajagana@users.noreply.github.com> Date: Wed, 19 Apr 2023 17:34:38 +0530 Subject: [PATCH 2/2] Changed the dataplane attribute to ip_data_plane_learning --- plugins/modules/aci_bd_subnet.py | 12 ++++++------ plugins/modules/aci_vrf.py | 12 ++++++------ .../integration/targets/aci_bd_subnet/tasks/main.yml | 2 +- tests/integration/targets/aci_vrf/tasks/main.yml | 9 ++++----- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/plugins/modules/aci_bd_subnet.py b/plugins/modules/aci_bd_subnet.py index 3c61f0c1b..19a9deee7 100644 --- a/plugins/modules/aci_bd_subnet.py +++ b/plugins/modules/aci_bd_subnet.py @@ -91,13 +91,13 @@ - The name of the Subnet. type: str aliases: [ name ] - dataplane: + ip_data_plane_learning: description: - - The Dataplane IP Address Learning. + - Whether IP data plane learning is enabled or disabled. - The APIC defaults to C(enabled) when unset during creation. type: str choices: [ enabled, disabled ] - aliases: [ ip_dataplane ] + aliases: [ ip_dataplane_learning ] tenant: description: - The name of the Tenant. @@ -376,7 +376,7 @@ def main(): state=dict(type="str", default="present", choices=["absent", "present", "query"]), tenant=dict(type="str", aliases=["tenant_name"]), # Not required for querying all objects name_alias=dict(type="str"), - dataplane=dict(type="str", choices=["enabled", "disabled"], aliases=["ip_dataplane"]), + ip_data_plane_learning=dict(type="str", choices=["enabled", "disabled"], aliases=["ip_dataplane_learning"]), ) module = AnsibleModule( @@ -418,7 +418,7 @@ def main(): if subnet_control: subnet_control = SUBNET_CONTROL_MAPPING[subnet_control] name_alias = module.params.get("name_alias") - dataplane = module.params.get("dataplane") + ip_data_plane_learning = module.params.get("ip_data_plane_learning") aci.construct_url( root_class=dict( aci_class="fvTenant", @@ -455,7 +455,7 @@ def main(): scope=scope, virtual=enable_vip, nameAlias=name_alias, - ipDPLearning=dataplane, + ipDPLearning=ip_data_plane_learning, ), child_configs=[ {"fvRsBDSubnetToProfile": {"attributes": {"tnL3extOutName": route_profile_l3_out, "tnRtctrlProfileName": route_profile}}}, diff --git a/plugins/modules/aci_vrf.py b/plugins/modules/aci_vrf.py index 418e05ef1..1aa87f2a3 100644 --- a/plugins/modules/aci_vrf.py +++ b/plugins/modules/aci_vrf.py @@ -43,13 +43,13 @@ - The description for the VRF. type: str aliases: [ descr ] - dataplane: + ip_data_plane_learning: description: - - The Dataplane IP Address Learning. + - Whether IP data plane learning is enabled or disabled. - The APIC defaults to C(enabled) when unset during creation. type: str choices: [ enabled, disabled ] - aliases: [ ip_dataplane ] + aliases: [ ip_dataplane_learning ] state: description: - Use C(present) or C(absent) for adding or removing. @@ -263,7 +263,7 @@ def main(): preferred_group=dict(type="str", choices=["enabled", "disabled"]), match_type=dict(type="str", choices=["all", "at_least_one", "at_most_one", "none"]), name_alias=dict(type="str"), - dataplane=dict(type="str", choices=["enabled", "disabled"], aliases=["ip_dataplane"]), + ip_data_plane_learning=dict(type="str", choices=["enabled", "disabled"], aliases=["ip_dataplane_learning"]), ) module = AnsibleModule( @@ -284,7 +284,7 @@ def main(): name_alias = module.params.get("name_alias") preferred_group = module.params.get("preferred_group") match_type = module.params.get("match_type") - dataplane = module.params.get("dataplane") + ip_data_plane_learning = module.params.get("ip_data_plane_learning") if match_type is not None: match_type = MATCH_TYPE_MAPPING[match_type] @@ -317,7 +317,7 @@ def main(): pcEnfPref=policy_control_preference, name=vrf, nameAlias=name_alias, - ipDataPlaneLearning=dataplane, + ipDataPlaneLearning=ip_data_plane_learning, ), child_configs=[ dict(vzAny=dict(attributes=dict(prefGrMemb=preferred_group, matchT=match_type))), diff --git a/tests/integration/targets/aci_bd_subnet/tasks/main.yml b/tests/integration/targets/aci_bd_subnet/tasks/main.yml index 4332b4bed..f9833cf75 100644 --- a/tests/integration/targets/aci_bd_subnet/tasks/main.yml +++ b/tests/integration/targets/aci_bd_subnet/tasks/main.yml @@ -68,7 +68,7 @@ scope: [private, shared] route_profile: default route_profile_l3_out: default - dataplane: disabled + ip_data_plane_learning: disabled register: create_subnet2 - name: create subnet again - idempotency works diff --git a/tests/integration/targets/aci_vrf/tasks/main.yml b/tests/integration/targets/aci_vrf/tasks/main.yml index 904934019..695f40fe7 100644 --- a/tests/integration/targets/aci_vrf/tasks/main.yml +++ b/tests/integration/targets/aci_vrf/tasks/main.yml @@ -35,7 +35,6 @@ <<: *aci_tenant_present vrf: anstest description: Ansible Test - dataplane: disabled check_mode: true register: vrf_present_check_mode @@ -63,7 +62,7 @@ policy_control_direction: egress preferred_group: enabled match_type: all - dataplane: "{{ fake_var | default(omit) }}" + ip_data_plane_learning: disabled register: vrf_present_2 - name: create vrf without all necessary params - failure message works @@ -82,7 +81,7 @@ - vrf_present is changed - vrf_present.sent == vrf_present_check_mode.sent - vrf_present.current.0.fvCtx.attributes.annotation == 'orchestrator:ansible' - - vrf_present.current.0.fvCtx.attributes.ipDataPlaneLearning == 'disabled' + - vrf_present.current.0.fvCtx.attributes.ipDataPlaneLearning == 'enabled' - vrf_present.previous == [] - vrf_present_idempotent is not changed - vrf_present_idempotent.previous != [] @@ -91,11 +90,11 @@ - vrf_update.sent != vrf_update.proposed - vrf_update.sent.fvCtx.attributes.descr == 'Ansible Test Update' - vrf_update.sent.fvCtx.attributes.pcEnfPref == 'unenforced' - - vrf_update.current.0.fvCtx.attributes.ipDataPlaneLearning == 'disabled' + - vrf_update.current.0.fvCtx.attributes.ipDataPlaneLearning == 'enabled' - vrf_present_2.sent.fvCtx.attributes.name == 'anstest2' - vrf_present_2.sent.fvCtx.attributes.pcEnfDir == 'egress' - vrf_present_2.sent.fvCtx.attributes.descr == 'Ansible Test' - - vrf_present_2.current.0.fvCtx.attributes.ipDataPlaneLearning == 'enabled' + - vrf_present_2.current.0.fvCtx.attributes.ipDataPlaneLearning == 'disabled' - vrf_present_2.current.0.fvCtx.children.0.vzAny.attributes.matchT == 'All' - vrf_present_2.current.0.fvCtx.children.0.vzAny.attributes.prefGrMemb == 'enabled' - vrf_present_missing_param is failed