Skip to content

add duplex for eth and po interface in access and trunk #401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 29 additions & 2 deletions plugins/modules/dcnm_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@
- Administrative state of the interface
type: bool
default: true
duplex:
description:
- Duplex of the interface. Speed must be set to use duplex.
type: str
choices: ['auto', 'full', 'half']
default: auto
profile_vpc:
description:
- Though the key shown here is 'profile_vpc' the actual key to be used in playbook
Expand Down Expand Up @@ -486,6 +492,12 @@
- Speed of the interface.
type: str
default: Auto
duplex:
description:
- Duplex of the interface. Speed must be set to use duplex.
type: str
choices: ['auto', 'full', 'half']
default: auto
int_vrf:
description:
- Interface VRF name. This object is applicable only if the 'mode' is 'routed'
Expand Down Expand Up @@ -1864,6 +1876,7 @@ def __init__(self, module):
"PORTTYPE_FAST_ENABLED": "port_type_fast",
"MTU": "mtu",
"SPEED": "speed",
"PORT_DUPLEX_MODE": "duplex",
"ALLOWED_VLANS": "allowed_vlans",
"NATIVE_VLAN": "native_vlan",
"ACCESS_VLAN": "access_vlan",
Expand Down Expand Up @@ -2199,6 +2212,8 @@ def dcnm_intf_validate_port_channel_input(self, config):
cmds=dict(type="list", elements="str"),
description=dict(type="str", default=""),
admin_state=dict(type="bool", default=True),
duplex=dict(
type="str", default="auto", choices=["auto", "full", "half"]),
)

pc_prof_spec_access = dict(
Expand All @@ -2213,6 +2228,8 @@ def dcnm_intf_validate_port_channel_input(self, config):
cmds=dict(type="list", elements="str"),
description=dict(type="str", default=""),
admin_state=dict(type="bool", default=True),
duplex=dict(
type="str", default="auto", choices=["auto", "full", "half"]),
)

pc_prof_spec_l3 = dict(
Expand Down Expand Up @@ -2411,6 +2428,8 @@ def dcnm_intf_validate_ethernet_interface_input(self, cfg):
cmds=dict(type="list", elements="str"),
description=dict(type="str", default=""),
admin_state=dict(type="bool", default=True),
duplex=dict(
type="str", default="auto", choices=["auto", "full", "half"]),
)

eth_prof_spec_access = dict(
Expand All @@ -2425,6 +2444,8 @@ def dcnm_intf_validate_ethernet_interface_input(self, cfg):
cmds=dict(type="list", elements="str"),
description=dict(type="str", default=""),
admin_state=dict(type="bool", default=True),
duplex=dict(
type="str", default="auto", choices=["auto", "full", "half"]),
)

eth_prof_spec_routed_host = dict(
Expand Down Expand Up @@ -2760,7 +2781,8 @@ def dcnm_intf_get_pc_payload(self, delem, intf, profile):
"native_vlan"
]
intf["interfaces"][0]["nvPairs"]["PO_ID"] = ifname

intf["interfaces"][0]["nvPairs"][
"PORT_DUPLEX_MODE"] = delem[profile]["duplex"]
if delem[profile]["mode"] == "access":
if delem[profile]["members"] is None:
intf["interfaces"][0]["nvPairs"]["MEMBER_INTERFACES"] = ""
Expand All @@ -2784,7 +2806,8 @@ def dcnm_intf_get_pc_payload(self, delem, intf, profile):
"access_vlan"
]
intf["interfaces"][0]["nvPairs"]["PO_ID"] = ifname

intf["interfaces"][0]["nvPairs"][
"PORT_DUPLEX_MODE"] = delem[profile]["duplex"]
if delem[profile]["mode"] == "l3":
if delem[profile]["members"] is None:
intf["interfaces"][0]["nvPairs"]["MEMBER_INTERFACES"] = ""
Expand Down Expand Up @@ -3149,6 +3172,8 @@ def dcnm_intf_get_eth_payload(self, delem, intf, profile):
"native_vlan"
]
intf["interfaces"][0]["nvPairs"]["INTF_NAME"] = ifname
intf["interfaces"][0]["nvPairs"][
"PORT_DUPLEX_MODE"] = delem[profile]["duplex"]
if delem[profile]["mode"] == "access":
intf["interfaces"][0]["nvPairs"]["BPDUGUARD_ENABLED"] = delem[
profile
Expand All @@ -3163,6 +3188,8 @@ def dcnm_intf_get_eth_payload(self, delem, intf, profile):
"access_vlan"
]
intf["interfaces"][0]["nvPairs"]["INTF_NAME"] = ifname
intf["interfaces"][0]["nvPairs"][
"PORT_DUPLEX_MODE"] = delem[profile]["duplex"]
if delem[profile]["mode"] == "routed":
intf["interfaces"][0]["nvPairs"]["INTF_VRF"] = delem[profile][
"int_vrf"
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/modules/dcnm/fixtures/dcnm_intf_eth_configs.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"policy": "int_trunk_host_11_1",
"allowed_vlans": "none",
"native_vlan": 10,
"duplex": "auto",
"cmds": [
"no shutdown"
],
Expand Down Expand Up @@ -123,6 +124,7 @@
"no shutdown"
],
"speed": "Auto",
"duplex": "auto",
"fabric": "test_fabric"
},
"name": "eth1/31",
Expand Down Expand Up @@ -215,6 +217,7 @@
"policy": "int_trunk_host_11_1",
"allowed_vlans": "all",
"native_vlan": 10,
"duplex": "auto",
"cmds": [
"no shutdown",
"no shutdown"
Expand Down Expand Up @@ -242,6 +245,7 @@
"port_type_fast": "False",
"policy": "int_access_host_11_1",
"ifname": "Ethernet1/31",
"duplex": "auto",
"cmds": [
"no shutdown",
"no shutdown"
Expand Down Expand Up @@ -462,6 +466,7 @@
"policy": "int_trunk_host_11_1",
"allowed_vlans": "all",
"native_vlan": 10,
"duplex": "auto",
"cmds": [
"no shutdown",
"no shutdown"
Expand Down Expand Up @@ -491,6 +496,7 @@
"policy": "int_trunk_host_11_1",
"allowed_vlans": "all",
"native_vlan": 10,
"duplex": "auto",
"cmds": [
"no shutdown",
"no shutdown"
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/modules/dcnm/fixtures/dcnm_intf_eth_payloads.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"BPDUGUARD_ENABLED": "True",
"ALLOWED_VLANS": "none",
"SPEED": "auto",
"PORT_DUPLEX_MODE": "auto",
"DESC": "eth interface acting as trunk",
"NATIVE_VLAN": "10"
},
Expand Down Expand Up @@ -50,6 +51,7 @@
"INTF_NAME": "Ethernet1/31",
"BPDUGUARD_ENABLED": "True",
"SPEED": "auto",
"PORT_DUPLEX_MODE": "auto",
"DESC": "eth interface acting as access"
},
"ifName": "Ethernet1/31",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@
"admin_state": "True",
"allowed_vlans": "none",
"native_vlan": "10",
"speed": "Auto",
"duplex": "auto",
"cmds": [
"no shutdown"
],
Expand Down Expand Up @@ -167,6 +169,7 @@
"no shutdown"
],
"speed": "Auto",
"duplex": "auto",
"ifname": "Ethernet1/10",
"fabric": "test_fabric"
},
Expand Down Expand Up @@ -245,6 +248,8 @@
"admin_state": "True",
"allowed_vlans": "none",
"native_vlan": "10",
"speed": "Auto",
"duplex": "auto",
"cmds": [
"spanning-tree bpduguard enable"
],
Expand Down Expand Up @@ -316,6 +321,7 @@
"spanning-tree bpduguard enable"
],
"speed": "Auto",
"duplex": "auto",
"ifname": "Ethernet1/10",
"fabric": "test_fabric"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"PO_ID": "Port-channel300",
"MTU": "jumbo",
"SPEED": "auto",
"PORT_DUPLEX_MODE": "auto",
"PRIORITY": "500",
"PORTTYPE_FAST_ENABLED": "True",
"PC_MODE": "on",
Expand Down Expand Up @@ -55,6 +56,7 @@
"fabricName": "test_fabric",
"nvPairs": {
"SPEED": "Auto",
"PORT_DUPLEX_MODE": "auto",
"MEMBER_INTERFACES": "e1/9",
"PC_MODE": "on",
"BPDUGUARD_ENABLED": "true",
Expand Down Expand Up @@ -133,6 +135,7 @@
"fabricName": "test_fabric",
"nvPairs": {
"SPEED": "auto",
"PORT_DUPLEX_MODE": "auto",
"BPDUGUARD_ENABLED": "true",
"PORTTYPE_FAST_ENABLED": "true",
"MTU": "jumbo",
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/modules/dcnm/fixtures/dcnm_intf_pc_configs.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@
"admin_state": "True",
"allowed_vlans": "none",
"native_vlan": "10",
"speed": "Auto",
"duplex": "auto",
"cmds": [
"no shutdown"
],
Expand Down Expand Up @@ -468,6 +470,8 @@
"admin_state": "False",
"allowed_vlans": "all",
"native_vlan": "10",
"speed": "Auto",
"duplex": "auto",
"cmds": [
"no shutdown",
"no shutdown"
Expand Down Expand Up @@ -574,6 +578,8 @@
"admin_state": "True",
"allowed_vlans": "none",
"native_vlan": "10",
"speed": "Auto",
"duplex": "auto",
"cmds": [
"no shutdown"
],
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/modules/dcnm/fixtures/dcnm_intf_pc_payloads.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"PO_ID": "Port-channel300",
"MTU": "jumbo",
"SPEED": "auto",
"PORT_DUPLEX_MODE": "auto",
"PRIORITY": "500",
"PORTTYPE_FAST_ENABLED": "True",
"PC_MODE": "on",
Expand Down Expand Up @@ -52,7 +53,8 @@
"FABRIC_NAME": "test_fabric",
"PO_ID": "Port-channel301",
"MTU": "default",
"SPEED": "auto",
"SPEED": "auto",
"PORT_DUPLEX_MODE": "auto",
"PRIORITY": "500",
"PORTTYPE_FAST_ENABLED": "True",
"PC_MODE": "on",
Expand Down