Skip to content

Commit e103fef

Browse files
authored
Access interface parameters (#431)
* new parameters for access interface v1 * CDP/PFC/Monitor control for access/trunk phy/po interfaces * correcting CDP related key in test payloads * fixing documentation errors * fix boolean comparison for ENABLE_PFC, ENABLE_MONITOR, CDP_ENABLE * updated documentation with newly supported interface settings * corrected pep8 issues
1 parent 48fbf78 commit e103fef

9 files changed

+262
-6
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ This collection is intended for use with the following release versions:
1212
<!--start requires_ansible-->
1313
## Ansible version compatibility
1414

15-
This collection has been tested against following Ansible versions: **>=2.15.0**.
15+
This collection has been tested against the following Ansible versions: **>=2.15.0**.
1616

17-
For collections that support Ansible 2.9, please ensure you update your `network_os` to use the
18-
fully qualified collection name (for example, `cisco.ios.ios`).
1917
Plugins and modules within a collection may be tested with only specific Ansible versions.
2018
A collection may contain metadata that identifies these versions.
2119
PEP440 is the schema used to describe the versions of Ansible.

docs/cisco.dcnm.dcnm_interface_module.rst

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,69 @@ Parameters
562562
<div>Duplex of the interface. Speed must be set to use duplex.</div>
563563
</td>
564564
</tr>
565+
<tr>
566+
<td class="elbow-placeholder"></td>
567+
<td class="elbow-placeholder"></td>
568+
<td colspan="1">
569+
<div class="ansibleOptionAnchor" id="parameter-"></div>
570+
<b>enable_cdp</b>
571+
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
572+
<div style="font-size: small">
573+
<span style="color: purple">boolean</span>
574+
</div>
575+
</td>
576+
<td>
577+
<ul style="margin: 0; padding: 0"><b>Choices:</b>
578+
<li>no</li>
579+
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
580+
</ul>
581+
</td>
582+
<td>
583+
<div>State of CDP protocol on the interface</div>
584+
</td>
585+
</tr>
586+
<tr>
587+
<td class="elbow-placeholder"></td>
588+
<td class="elbow-placeholder"></td>
589+
<td colspan="1">
590+
<div class="ansibleOptionAnchor" id="parameter-"></div>
591+
<b>enable_monitor</b>
592+
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
593+
<div style="font-size: small">
594+
<span style="color: purple">boolean</span>
595+
</div>
596+
</td>
597+
<td>
598+
<ul style="margin: 0; padding: 0"><b>Choices:</b>
599+
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
600+
<li>yes</li>
601+
</ul>
602+
</td>
603+
<td>
604+
<div>State of Switchport Monitor for SPAN/ERSPAN</div>
605+
</td>
606+
</tr>
607+
<tr>
608+
<td class="elbow-placeholder"></td>
609+
<td class="elbow-placeholder"></td>
610+
<td colspan="1">
611+
<div class="ansibleOptionAnchor" id="parameter-"></div>
612+
<b>enable_pfc</b>
613+
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
614+
<div style="font-size: small">
615+
<span style="color: purple">boolean</span>
616+
</div>
617+
</td>
618+
<td>
619+
<ul style="margin: 0; padding: 0"><b>Choices:</b>
620+
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
621+
<li>yes</li>
622+
</ul>
623+
</td>
624+
<td>
625+
<div>State of Priority Flow Control (PFC) on the interface</div>
626+
</td>
627+
</tr>
565628
<tr>
566629
<td class="elbow-placeholder"></td>
567630
<td class="elbow-placeholder"></td>
@@ -1105,6 +1168,69 @@ Parameters
11051168
<div>Duplex of the interface. Speed must be set to use duplex.</div>
11061169
</td>
11071170
</tr>
1171+
<tr>
1172+
<td class="elbow-placeholder"></td>
1173+
<td class="elbow-placeholder"></td>
1174+
<td colspan="1">
1175+
<div class="ansibleOptionAnchor" id="parameter-"></div>
1176+
<b>enable_cdp</b>
1177+
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
1178+
<div style="font-size: small">
1179+
<span style="color: purple">boolean</span>
1180+
</div>
1181+
</td>
1182+
<td>
1183+
<ul style="margin: 0; padding: 0"><b>Choices:</b>
1184+
<li>no</li>
1185+
<li><div style="color: blue"><b>yes</b>&nbsp;&larr;</div></li>
1186+
</ul>
1187+
</td>
1188+
<td>
1189+
<div>State of CDP protocol on the interface</div>
1190+
</td>
1191+
</tr>
1192+
<tr>
1193+
<td class="elbow-placeholder"></td>
1194+
<td class="elbow-placeholder"></td>
1195+
<td colspan="1">
1196+
<div class="ansibleOptionAnchor" id="parameter-"></div>
1197+
<b>enable_monitor</b>
1198+
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
1199+
<div style="font-size: small">
1200+
<span style="color: purple">boolean</span>
1201+
</div>
1202+
</td>
1203+
<td>
1204+
<ul style="margin: 0; padding: 0"><b>Choices:</b>
1205+
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
1206+
<li>yes</li>
1207+
</ul>
1208+
</td>
1209+
<td>
1210+
<div>State of Switchport Monitor for SPAN/ERSPAN</div>
1211+
</td>
1212+
</tr>
1213+
<tr>
1214+
<td class="elbow-placeholder"></td>
1215+
<td class="elbow-placeholder"></td>
1216+
<td colspan="1">
1217+
<div class="ansibleOptionAnchor" id="parameter-"></div>
1218+
<b>enable_pfc</b>
1219+
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
1220+
<div style="font-size: small">
1221+
<span style="color: purple">boolean</span>
1222+
</div>
1223+
</td>
1224+
<td>
1225+
<ul style="margin: 0; padding: 0"><b>Choices:</b>
1226+
<li><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
1227+
<li>yes</li>
1228+
</ul>
1229+
</td>
1230+
<td>
1231+
<div>State of Priority Flow Control (PFC) on the interface</div>
1232+
</td>
1233+
</tr>
11081234
<tr>
11091235
<td class="elbow-placeholder"></td>
11101236
<td class="elbow-placeholder"></td>

plugins/modules/dcnm_interface.py

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,21 @@
181181
type: str
182182
choices: ['auto', 'full', 'half']
183183
default: auto
184+
enable_pfc:
185+
description:
186+
- State of Priority Flow Control (PFC) on the interface
187+
type: bool
188+
default: false
189+
enable_cdp:
190+
description:
191+
- State of CDP protocol on the interface
192+
type: bool
193+
default: true
194+
enable_monitor:
195+
description:
196+
- State of Switchport Monitor for SPAN/ERSPAN
197+
type: bool
198+
default: false
184199
profile_vpc:
185200
description:
186201
- Though the key shown here is 'profile_vpc' the actual key to be used in playbook
@@ -564,6 +579,21 @@
564579
- Administrative state of the interface
565580
type: bool
566581
default: true
582+
enable_pfc:
583+
description:
584+
- State of Priority Flow Control (PFC) on the interface
585+
type: bool
586+
default: false
587+
enable_cdp:
588+
description:
589+
- State of CDP protocol on the interface
590+
type: bool
591+
default: true
592+
enable_monitor:
593+
description:
594+
- State of Switchport Monitor for SPAN/ERSPAN
595+
type: bool
596+
default: false
567597
profile_svi:
568598
description:
569599
- Though the key shown here is 'profile_svi' the actual key to be used in playbook
@@ -1920,6 +1950,9 @@ def __init__(self, module):
19201950
"DCI_ROUTING_PROTO": "dci_routing_proto",
19211951
"DCI_ROUTING_TAG": "dci_routing_tag",
19221952
"ENABLE_ORPHAN_PORT": "orphan_port",
1953+
"ENABLE_PFC": "enable_pfc",
1954+
"ENABLE_MONITOR": "enable_monitor",
1955+
"CDP_ENABLE": "enable_cdp",
19231956
}
19241957

19251958
# New Interfaces
@@ -2268,6 +2301,9 @@ def dcnm_intf_validate_port_channel_input(self, config):
22682301
description=dict(type="str", default=""),
22692302
admin_state=dict(type="bool", default=True),
22702303
orphan_port=dict(type="bool", default=False),
2304+
enable_cdp=dict(type="bool", default=True),
2305+
enable_monitor=dict(type="bool", default=False),
2306+
enable_pfc=dict(type="bool", default=False),
22712307
duplex=dict(
22722308
type="str", default="auto", choices=["auto", "full", "half"]),
22732309
)
@@ -2285,6 +2321,9 @@ def dcnm_intf_validate_port_channel_input(self, config):
22852321
description=dict(type="str", default=""),
22862322
admin_state=dict(type="bool", default=True),
22872323
orphan_port=dict(type="bool", default=False),
2324+
enable_cdp=dict(type="bool", default=True),
2325+
enable_monitor=dict(type="bool", default=False),
2326+
enable_pfc=dict(type="bool", default=False),
22882327
duplex=dict(
22892328
type="str", default="auto", choices=["auto", "full", "half"]),
22902329
)
@@ -2487,6 +2526,9 @@ def dcnm_intf_validate_ethernet_interface_input(self, cfg):
24872526
description=dict(type="str", default=""),
24882527
admin_state=dict(type="bool", default=True),
24892528
orphan_port=dict(type="bool", default=False),
2529+
enable_cdp=dict(type="bool", default=True),
2530+
enable_monitor=dict(type="bool", default=False),
2531+
enable_pfc=dict(type="bool", default=False),
24902532
duplex=dict(
24912533
type="str", default="auto", choices=["auto", "full", "half"]),
24922534
)
@@ -2504,6 +2546,9 @@ def dcnm_intf_validate_ethernet_interface_input(self, cfg):
25042546
description=dict(type="str", default=""),
25052547
admin_state=dict(type="bool", default=True),
25062548
orphan_port=dict(type="bool", default=False),
2549+
enable_cdp=dict(type="bool", default=True),
2550+
enable_monitor=dict(type="bool", default=False),
2551+
enable_pfc=dict(type="bool", default=False),
25072552
duplex=dict(
25082553
type="str", default="auto", choices=["auto", "full", "half"]),
25092554
)
@@ -2843,6 +2888,12 @@ def dcnm_intf_get_pc_payload(self, delem, intf, profile):
28432888
intf["interfaces"][0]["nvPairs"]["PO_ID"] = ifname
28442889
intf["interfaces"][0]["nvPairs"][
28452890
"ENABLE_ORPHAN_PORT"] = delem[profile]["orphan_port"]
2891+
intf["interfaces"][0]["nvPairs"][
2892+
"CDP_ENABLE"] = delem[profile]["enable_cdp"]
2893+
intf["interfaces"][0]["nvPairs"][
2894+
"ENABLE_PFC"] = delem[profile]["enable_pfc"]
2895+
intf["interfaces"][0]["nvPairs"][
2896+
"ENABLE_MONITOR"] = delem[profile]["enable_monitor"]
28462897
intf["interfaces"][0]["nvPairs"][
28472898
"PORT_DUPLEX_MODE"] = delem[profile]["duplex"]
28482899
if delem[profile]["mode"] == "access":
@@ -2870,6 +2921,12 @@ def dcnm_intf_get_pc_payload(self, delem, intf, profile):
28702921
intf["interfaces"][0]["nvPairs"]["PO_ID"] = ifname
28712922
intf["interfaces"][0]["nvPairs"][
28722923
"ENABLE_ORPHAN_PORT"] = delem[profile]["orphan_port"]
2924+
intf["interfaces"][0]["nvPairs"][
2925+
"CDP_ENABLE"] = delem[profile]["enable_cdp"]
2926+
intf["interfaces"][0]["nvPairs"][
2927+
"ENABLE_PFC"] = delem[profile]["enable_pfc"]
2928+
intf["interfaces"][0]["nvPairs"][
2929+
"ENABLE_MONITOR"] = delem[profile]["enable_monitor"]
28732930
intf["interfaces"][0]["nvPairs"][
28742931
"PORT_DUPLEX_MODE"] = delem[profile]["duplex"]
28752932
if delem[profile]["mode"] == "l3":
@@ -3241,6 +3298,12 @@ def dcnm_intf_get_eth_payload(self, delem, intf, profile):
32413298
intf["interfaces"][0]["nvPairs"]["INTF_NAME"] = ifname
32423299
intf["interfaces"][0]["nvPairs"][
32433300
"ENABLE_ORPHAN_PORT"] = delem[profile]["orphan_port"]
3301+
intf["interfaces"][0]["nvPairs"][
3302+
"CDP_ENABLE"] = delem[profile]["enable_cdp"]
3303+
intf["interfaces"][0]["nvPairs"][
3304+
"ENABLE_PFC"] = delem[profile]["enable_pfc"]
3305+
intf["interfaces"][0]["nvPairs"][
3306+
"ENABLE_MONITOR"] = delem[profile]["enable_monitor"]
32443307
intf["interfaces"][0]["nvPairs"][
32453308
"PORT_DUPLEX_MODE"] = delem[profile]["duplex"]
32463309
if delem[profile]["mode"] == "access":
@@ -3259,6 +3322,12 @@ def dcnm_intf_get_eth_payload(self, delem, intf, profile):
32593322
intf["interfaces"][0]["nvPairs"]["INTF_NAME"] = ifname
32603323
intf["interfaces"][0]["nvPairs"][
32613324
"ENABLE_ORPHAN_PORT"] = delem[profile]["orphan_port"]
3325+
intf["interfaces"][0]["nvPairs"][
3326+
"CDP_ENABLE"] = delem[profile]["enable_cdp"]
3327+
intf["interfaces"][0]["nvPairs"][
3328+
"ENABLE_PFC"] = delem[profile]["enable_pfc"]
3329+
intf["interfaces"][0]["nvPairs"][
3330+
"ENABLE_MONITOR"] = delem[profile]["enable_monitor"]
32623331
intf["interfaces"][0]["nvPairs"][
32633332
"PORT_DUPLEX_MODE"] = delem[profile]["duplex"]
32643333
if delem[profile]["mode"] == "routed":
@@ -3884,7 +3953,7 @@ def dcnm_intf_compare_elements(
38843953
else:
38853954
t_e2 = e2
38863955

3887-
if k == 'ENABLE_ORPHAN_PORT':
3956+
if k in ['ENABLE_ORPHAN_PORT', 'ENABLE_PFC', 'ENABLE_MONITOR', 'CDP_ENABLE']:
38883957
# This is a special case where the value is a boolean and we need to compare it as such
38893958
t_e1 = str(t_e1).lower()
38903959
t_e2 = str(t_e2).lower()

tests/unit/modules/dcnm/fixtures/dcnm_intf_eth_configs.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@
9494
"allowed_vlans": "none",
9595
"native_vlan": 10,
9696
"orphan_port": false,
97+
"enable_pfc": false,
98+
"enable_cdp": true,
99+
"enable_monitor": false,
97100
"duplex": "auto",
98101
"cmds": [
99102
"no shutdown"
@@ -219,6 +222,9 @@
219222
"allowed_vlans": "all",
220223
"native_vlan": 10,
221224
"orphan_port": false,
225+
"enable_pfc": false,
226+
"enable_cdp": true,
227+
"enable_monitor": false,
222228
"duplex": "auto",
223229
"cmds": [
224230
"no shutdown",
@@ -469,6 +475,9 @@
469475
"allowed_vlans": "all",
470476
"native_vlan": 10,
471477
"orphan_port": false,
478+
"enable_pfc": false,
479+
"enable_cdp": true,
480+
"enable_monitor": false,
472481
"duplex": "auto",
473482
"cmds": [
474483
"no shutdown",
@@ -500,6 +509,9 @@
500509
"allowed_vlans": "all",
501510
"native_vlan": 10,
502511
"orphan_port": false,
512+
"enable_pfc": false,
513+
"enable_cdp": true,
514+
"enable_monitor": false,
503515
"duplex": "auto",
504516
"cmds": [
505517
"no shutdown",

tests/unit/modules/dcnm/fixtures/dcnm_intf_eth_payloads.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
"PORT_DUPLEX_MODE": "auto",
2222
"DESC": "eth interface acting as trunk",
2323
"NATIVE_VLAN": "10",
24-
"ENABLE_ORPHAN_PORT": false
24+
"ENABLE_ORPHAN_PORT": false,
25+
"ENABLE_PFC": false,
26+
"CDP_ENABLE": true,
27+
"ENABLE_MONITOR": false
2528
},
2629
"ifName": "Ethernet1/30",
2730
"serialNumber": "SAL1819SAN8",
@@ -53,6 +56,9 @@
5356
"BPDUGUARD_ENABLED": "True",
5457
"SPEED": "auto",
5558
"ENABLE_ORPHAN_PORT": false,
59+
"ENABLE_PFC": false,
60+
"CDP_ENABLE": true,
61+
"ENABLE_MONITOR": false,
5662
"PORT_DUPLEX_MODE": "auto",
5763
"DESC": "eth interface acting as access"
5864
},

0 commit comments

Comments
 (0)