From 56a8df9edbff1585e97e035b273fc3215b0a49c1 Mon Sep 17 00:00:00 2001 From: mkilar Date: Wed, 13 Aug 2025 17:24:00 +0200 Subject: [PATCH 1/2] adding LACP attributes port priority and rate v1 --- docs/cisco.dcnm.dcnm_interface_module.rst | 78 +++++++++++++++++++++++ plugins/modules/dcnm_interface.py | 42 ++++++++++++ tests/unit/modules/dcnm/test_dcnm_intf.py | 6 +- 3 files changed, 125 insertions(+), 1 deletion(-) diff --git a/docs/cisco.dcnm.dcnm_interface_module.rst b/docs/cisco.dcnm.dcnm_interface_module.rst index 0eecb3898..8d3322932 100644 --- a/docs/cisco.dcnm.dcnm_interface_module.rst +++ b/docs/cisco.dcnm.dcnm_interface_module.rst @@ -1286,6 +1286,45 @@ Parameters
Minimum Value (1), Maximum Value (31)
+ + + + +
+ lacp_port_priority + +
+ integer +
+ + + Default:
32768
+ + +
<1-65535> Set LACP port priority on member interfaces, default is 32768
+ + + + + + +
+ lacp_rate + +
+ string +
+ + + + + +
Set the rate at which LACP control packets are sent to an LACP-supported interface. Normal rate (30 seconds), fast rate (1 second), rate is set on member interfaces, default is normal
+ + @@ -2441,6 +2480,45 @@ Parameters
Enable lacp convergence for vPC port-channels
+ + + + +
+ lacp_port_priority + +
+ integer +
+ + + Default:
32768
+ + +
<1-65535> Set LACP port priority on member interfaces, default is 32768
+ + + + + + +
+ lacp_rate + +
+ string +
+ + + + + +
Set the rate at which LACP control packets are sent to an LACP-supported interface. Normal rate (30 seconds), fast rate (1 second), rate is set on member interfaces, default is normal
+ + diff --git a/plugins/modules/dcnm_interface.py b/plugins/modules/dcnm_interface.py index fbb800c63..294db45cb 100644 --- a/plugins/modules/dcnm_interface.py +++ b/plugins/modules/dcnm_interface.py @@ -196,6 +196,19 @@ - State of Switchport Monitor for SPAN/ERSPAN type: bool default: false + lacp_port_priority: + description: + - <1-65535> Set LACP port priority on member interfaces, default is 32768 + type: int + default: 32768 + lacp_rate: + description: + - Set the rate at which LACP control packets are sent to an LACP-supported + interface. Normal rate (30 seconds), fast rate (1 second), rate is set on member + interfaces, default is normal + type: str + choices: ['normal', 'fast'] + default: normal profile_vpc: description: - Though the key shown here is 'profile_vpc' the actual key to be used in playbook @@ -335,6 +348,19 @@ - Enable lacp convergence for vPC port-channels type: bool default: false + lacp_port_priority: + description: + - <1-65535> Set LACP port priority on member interfaces, default is 32768 + type: int + default: 32768 + lacp_rate: + description: + - Set the rate at which LACP control packets are sent to an LACP-supported + interface. Normal rate (30 seconds), fast rate (1 second), rate is set on member + interfaces, default is normal + type: str + choices: ['normal', 'fast'] + default: normal profile_subint: description: - Though the key shown here is 'profile_subint' the actual key to be used in playbook @@ -1963,6 +1989,8 @@ def __init__(self, module): "ENABLE_ORPHAN_PORT": "orphan_port", "DISABLE_LACP_SUSPEND": "disable_lacp_suspend_individual", "ENABLE_LACP_VPC_CONV": "enable_lacp_vpc_convergence", + "LACP_PORT_PRIO": "lacp_port_priority", + "LACP_RATE": "lacp_rate", "ENABLE_PFC": "enable_pfc", "ENABLE_MONITOR": "enable_monitor", "CDP_ENABLE": "enable_cdp", @@ -2320,6 +2348,8 @@ def dcnm_intf_validate_port_channel_input(self, config): enable_pfc=dict(type="bool", default=False), duplex=dict( type="str", default="auto", choices=["auto", "full", "half"]), + lacp_port_priority=dict(type="int", default=32768, range_min=1, range_max=65535), + lacp_rate=dict(type="str", default="normal"), ) pc_prof_spec_access = dict( @@ -2340,6 +2370,8 @@ def dcnm_intf_validate_port_channel_input(self, config): enable_pfc=dict(type="bool", default=False), duplex=dict( type="str", default="auto", choices=["auto", "full", "half"]), + lacp_port_priority=dict(type="int", default=32768, range_min=1, range_max=65535), + lacp_rate=dict(type="str", default="normal"), ) pc_prof_spec_l3 = dict( @@ -2426,6 +2458,8 @@ def dcnm_intf_validate_virtual_port_channel_input(self, cfg): admin_state=dict(type="bool", default=True), disable_lacp_suspend_individual=dict(type="bool", default=False), enable_lacp_vpc_convergence=dict(type="bool", default=False), + lacp_port_priority=dict(type="int", default=32768, range_min=1, range_max=65535), + lacp_rate=dict(type="str", default="normal"), ) vpc_prof_spec_access = dict( @@ -2912,6 +2946,8 @@ def dcnm_intf_get_pc_payload(self, delem, intf, profile): "ENABLE_MONITOR"] = delem[profile]["enable_monitor"] intf["interfaces"][0]["nvPairs"][ "PORT_DUPLEX_MODE"] = delem[profile]["duplex"] + intf["interfaces"][0]["nvPairs"]["LACP_PORT_PRIO"] = delem[profile]["lacp_port_priority"] + intf["interfaces"][0]["nvPairs"]["LACP_RATE"] = delem[profile]["lacp_rate"] if delem[profile]["mode"] == "access": if delem[profile]["members"] is None: intf["interfaces"][0]["nvPairs"]["MEMBER_INTERFACES"] = "" @@ -2945,6 +2981,8 @@ def dcnm_intf_get_pc_payload(self, delem, intf, profile): "ENABLE_MONITOR"] = delem[profile]["enable_monitor"] intf["interfaces"][0]["nvPairs"][ "PORT_DUPLEX_MODE"] = delem[profile]["duplex"] + intf["interfaces"][0]["nvPairs"]["LACP_PORT_PRIO"] = delem[profile]["lacp_port_priority"] + intf["interfaces"][0]["nvPairs"]["LACP_RATE"] = delem[profile]["lacp_rate"] if delem[profile]["mode"] == "l3": if delem[profile]["members"] is None: intf["interfaces"][0]["nvPairs"]["MEMBER_INTERFACES"] = "" @@ -3170,6 +3208,8 @@ def dcnm_intf_get_vpc_payload(self, delem, intf, profile): intf["interfaces"][0]["nvPairs"]["ENABLE_LACP_VPC_CONV"] = delem[profile]["enable_lacp_vpc_convergence"] else: intf["interfaces"][0]["nvPairs"]["ENABLE_LACP_VPC_CONV"] = False + intf["interfaces"][0]["nvPairs"]["LACP_PORT_PRIO"] = delem[profile]["lacp_port_priority"] + intf["interfaces"][0]["nvPairs"]["LACP_RATE"] = delem[profile]["lacp_rate"] intf["interfaces"][0]["nvPairs"]["INTF_NAME"] = ifname intf["interfaces"][0]["nvPairs"]["SPEED"] = self.dcnm_intf_xlate_speed( str(delem[profile].get("speed", "")) @@ -4267,6 +4307,8 @@ def dcnm_intf_compare_want_and_have(self, state): "CDP_ENABLE", "DISABLE_LACP_SUSPEND", "ENABLE_LACP_VPC_CONV", + "LACP_PORT_PRIO", + "LACP_RATE", "ENABLE_MONITOR", "ENABLE_ORPHAN_PORT", "ENABLE_PFC", diff --git a/tests/unit/modules/dcnm/test_dcnm_intf.py b/tests/unit/modules/dcnm/test_dcnm_intf.py index 30b888819..f6b44cbf8 100644 --- a/tests/unit/modules/dcnm/test_dcnm_intf.py +++ b/tests/unit/modules/dcnm/test_dcnm_intf.py @@ -2997,6 +2997,8 @@ def test_dcnm_intf_pc_replaced_existing(self): "ROUTING_TAG", "SPEED", "CONF", + "LACP_PORT_PRIO", + "LACP_RATE" ] for d in result["diff"][0]["replaced"]: @@ -4224,7 +4226,9 @@ def test_dcnm_intf_vpc_replaced_existing(self): "PEER2_PO_CONF", "INTF_NAME", "ENABLE_LACP_VPC_CONV", - "DISABLE_LACP_SUSPEND" + "DISABLE_LACP_SUSPEND", + "LACP_PORT_PRIO", + "LACP_RATE" ] for d in result["diff"][0]["replaced"]: From 5f5a44fc69c3d3dc6296443323b2b4b06975593b Mon Sep 17 00:00:00 2001 From: mkilar Date: Thu, 14 Aug 2025 15:23:08 +0200 Subject: [PATCH 2/2] adding defaults to introduced parameters --- plugins/modules/dcnm_interface.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/plugins/modules/dcnm_interface.py b/plugins/modules/dcnm_interface.py index 294db45cb..7c41a0269 100644 --- a/plugins/modules/dcnm_interface.py +++ b/plugins/modules/dcnm_interface.py @@ -2946,8 +2946,14 @@ def dcnm_intf_get_pc_payload(self, delem, intf, profile): "ENABLE_MONITOR"] = delem[profile]["enable_monitor"] intf["interfaces"][0]["nvPairs"][ "PORT_DUPLEX_MODE"] = delem[profile]["duplex"] - intf["interfaces"][0]["nvPairs"]["LACP_PORT_PRIO"] = delem[profile]["lacp_port_priority"] - intf["interfaces"][0]["nvPairs"]["LACP_RATE"] = delem[profile]["lacp_rate"] + if delem[profile].get("lacp_port_priority"): + intf["interfaces"][0]["nvPairs"]["LACP_PORT_PRIO"] = delem[profile]["lacp_port_priority"] + else: + intf["interfaces"][0]["nvPairs"]["LACP_PORT_PRIO"] = 32768 + if delem[profile].get("lacp_rate"): + intf["interfaces"][0]["nvPairs"]["LACP_RATE"] = delem[profile]["lacp_rate"] + else: + intf["interfaces"][0]["nvPairs"]["LACP_RATE"] = "normal" if delem[profile]["mode"] == "access": if delem[profile]["members"] is None: intf["interfaces"][0]["nvPairs"]["MEMBER_INTERFACES"] = "" @@ -2981,8 +2987,14 @@ def dcnm_intf_get_pc_payload(self, delem, intf, profile): "ENABLE_MONITOR"] = delem[profile]["enable_monitor"] intf["interfaces"][0]["nvPairs"][ "PORT_DUPLEX_MODE"] = delem[profile]["duplex"] - intf["interfaces"][0]["nvPairs"]["LACP_PORT_PRIO"] = delem[profile]["lacp_port_priority"] - intf["interfaces"][0]["nvPairs"]["LACP_RATE"] = delem[profile]["lacp_rate"] + if delem[profile].get("lacp_port_priority"): + intf["interfaces"][0]["nvPairs"]["LACP_PORT_PRIO"] = delem[profile]["lacp_port_priority"] + else: + intf["interfaces"][0]["nvPairs"]["LACP_PORT_PRIO"] = 32768 + if delem[profile].get("lacp_rate"): + intf["interfaces"][0]["nvPairs"]["LACP_RATE"] = delem[profile]["lacp_rate"] + else: + intf["interfaces"][0]["nvPairs"]["LACP_RATE"] = "normal" if delem[profile]["mode"] == "l3": if delem[profile]["members"] is None: intf["interfaces"][0]["nvPairs"]["MEMBER_INTERFACES"] = "" @@ -3208,8 +3220,14 @@ def dcnm_intf_get_vpc_payload(self, delem, intf, profile): intf["interfaces"][0]["nvPairs"]["ENABLE_LACP_VPC_CONV"] = delem[profile]["enable_lacp_vpc_convergence"] else: intf["interfaces"][0]["nvPairs"]["ENABLE_LACP_VPC_CONV"] = False - intf["interfaces"][0]["nvPairs"]["LACP_PORT_PRIO"] = delem[profile]["lacp_port_priority"] - intf["interfaces"][0]["nvPairs"]["LACP_RATE"] = delem[profile]["lacp_rate"] + if delem[profile].get("lacp_port_priority"): + intf["interfaces"][0]["nvPairs"]["LACP_PORT_PRIO"] = delem[profile]["lacp_port_priority"] + else: + intf["interfaces"][0]["nvPairs"]["LACP_PORT_PRIO"] = 32768 + if delem[profile].get("lacp_rate"): + intf["interfaces"][0]["nvPairs"]["LACP_RATE"] = delem[profile]["lacp_rate"] + else: + intf["interfaces"][0]["nvPairs"]["LACP_RATE"] = "normal" intf["interfaces"][0]["nvPairs"]["INTF_NAME"] = ifname intf["interfaces"][0]["nvPairs"]["SPEED"] = self.dcnm_intf_xlate_speed( str(delem[profile].get("speed", ""))