Skip to content

Commit

Permalink
Merge pull request #44 from hakasapl/main
Browse files Browse the repository at this point in the history
FX2 Racks 1 and 2 Networking
  • Loading branch information
hakasapl authored Dec 6, 2023
2 parents f73ce0f + 400c673 commit a9b7e9e
Show file tree
Hide file tree
Showing 22 changed files with 1,821 additions and 159 deletions.
88 changes: 64 additions & 24 deletions filter_plugins/dell_os9.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ def os9_ip4(man_fields, running_fields, default_port):

out = []

if "port-channel-protocol lacp" in running_fields:
out.append("no port-channel-protocol lacp")
#! this only works for LACP, what if interface is in a normal LAG?

if "ip4" in man_fields:
# ip4 attribute exists in the manifest
conf_line = f"ip address {man_fields['ip4']}"
Expand Down Expand Up @@ -377,6 +381,10 @@ def os9_ip6(man_fields, running_fields, default_port):

out = []

if "port-channel-protocol lacp" in running_fields:
out.append("no port-channel-protocol lacp")
#! this only works for LACP, what if interface is in a normal LAG?

if "ip6" in man_fields:
# ip6 attribute exists in the manifest
conf_line = f"ipv6 address {man_fields['ip6']}"
Expand All @@ -389,35 +397,67 @@ def os9_ip6(man_fields, running_fields, default_port):

return out

def os9_edgeport(man_fields, running_fields, default_port):
"""
Create OS9 commands for "edge-port" attribute
:param man_fields: Manifest fields for current interface
:type man_fields: dict
:param running_fields: Interface attributes in the running config
:type running_fields: list
:param default_port: If true, this port is being defaulted
:type default_port: boolean
:return: List of OS9 commands to set edge-port
:rtype: list
"""
def os9_stp(man_fields, running_fields, default_port):

out = []

# Every edge port interface will be defined as an edge port for all 3 protocols
os9_stp_types = ["rstp", "pvst", "mstp"]

is_edgeport = "stp-edge" in man_fields and man_fields["stp-edge"]
# enable/disable
stp_disabled = "stp" in man_fields and "disabled" in man_fields["stp"] and man_fields["stp"]["disabled"]
if stp_disabled:
# stp should be disabled
conf_line = f"no spanning-tree"
if conf_line not in running_fields and not default_port:
out.append(conf_line)
elif "no spanning-tree" in running_fields:
conf_line = "spanning-tree"
out.append(conf_line)

for stp_type in os9_stp_types:
# Loop through each stp type available
conf_line = f"spanning-tree {stp_type} edge-port"
if is_edgeport:
if conf_line not in running_fields or default_port:
out.append(conf_line) # add to out only if not already in switch conf
else:
if conf_line in running_fields and not default_port:
out.append(f"no {conf_line}")
if "stp" in man_fields:
stp_fields = man_fields["stp"]

# Edgeport settings
if "edgeport" in stp_fields and stp_fields["edgeport"]:
# this port is an edge port
conf_line = f"spanning-tree {stp_type} edge-port"
if "bpduguard" in stp_fields and stp_fields["bpduguard"]:
conf_line += " bpduguard shutdown-on-violation"
elif any("bpduguard" in item for item in running_fields):
# existing bpduguard where it shouldn't be
out.append(f"no spanning-tree {stp_type} edge-port")

if conf_line not in running_fields or default_port:
out.append(conf_line)
elif any(item.startswith(f"spanning-tree {stp_type} edge-port") for item in running_fields):
out.append(f"no spanning-tree {stp_type} edge-port")

# Rootguard settings
if "rootguard" in stp_fields and stp_fields["rootguard"]:
# enable rootguard
conf_line = f"spanning-tree {stp_type} rootguard"

if conf_line not in running_fields or default_port:
out.append(conf_line)
elif f"spanning-tree {stp_type} rootguard" in running_fields:
out.append(f"no spanning-tree {stp_type} rootguard")

# Loopguard settings
if "loopguard" in stp_fields and stp_fields["loopguard"]:
# enable loopguard
conf_line = f"spanning-tree {stp_type} loopguard"

if conf_line not in running_fields or default_port:
out.append(conf_line)
elif f"spanning-tree {stp_type} loopguard" in running_fields:
out.append(f"no spanning-tree {stp_type} loopguard")
elif any(item.startswith(f"spanning-tree {stp_type} edge-port") for item in running_fields):
out.append(f"no spanning-tree {stp_type} edge-port")
elif f"spanning-tree {stp_type} rootguard" in running_fields:
out.append(f"no spanning-tree {stp_type} rootguard")
elif f"spanning-tree {stp_type} loopguard" in running_fields:
out.append(f"no spanning-tree {stp_type} loopguard")

return out

Expand Down Expand Up @@ -846,7 +886,7 @@ def os9_mlag(man_fields, running_fields, default_port):
cur_intf_cfg += portmode_out
cur_intf_cfg += os9_mlag(intf_fields, running_config, default_port)
# STP
cur_intf_cfg += os9_edgeport(intf_fields, running_config, default_port)
cur_intf_cfg += os9_stp(intf_fields, running_config, default_port)

# these go directly to output because they are controlling other interfaces
cleanvlan_list = os9_cleanvlans(intf_label, sw_config, intf_fields, default_port, managed_vlan_list)
Expand Down
3 changes: 3 additions & 0 deletions group_vars/all/vlans.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,9 @@ vlans:
630:
name: ESI-630
description: ESI Vlan 630
700:
name: "ESI-Provisioning-NEW"
description: "Testing VLAN for new ESI deployment"
701:
name: "ENGAGE1-FOREMAN"
description: "Foreman Provisioning. SNMP for OpenStack and Ceph"
Expand Down
6 changes: 2 additions & 4 deletions host_vars/MOC-CORE-1/interfaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ interfaces:
- 520:622
- 623
- 624:630
- 911
- 930
- 3801
- 3802
- 3803
Expand All @@ -112,8 +110,6 @@ interfaces:
- 520:622
- 623
- 624:630
- 911
- 930
- 3801
- 3802
- 3803
Expand All @@ -133,6 +129,8 @@ interfaces:
- 2470:2473
- 2476:2478
mtu: 9216
stp:
disabled: true
lacp-rate: "fast"
lacp-members-active:
- "hundredGigE 1/25"
Expand Down
2 changes: 2 additions & 0 deletions host_vars/MOC-CORE-2/interfaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ interfaces:
- 2470:2473
- 2476:2478
mtu: 9216
stp:
disabled: true
lacp-rate: "fast"
lacp-members-active:
- "hundredGigE 1/25"
Expand Down
69 changes: 66 additions & 3 deletions host_vars/MOC-CORE-3/interfaces.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
interfaces:
hundredGigE 1/1:
state: "down"
description: "MOC-R4PAC##-SW-TORS-A Port 30"
state: "up"
mtu: 9216
hundredGigE 1/2:
state: "down"
description: "MOC-R4PAC##-SW-TORS-A Port 30"
state: "up"
mtu: 9216
hundredGigE 1/3:
state: "down"
description: "MOC-R4PAC##-SW-TORS-A Port 30"
state: "up"
mtu: 9216
hundredGigE 1/4:
state: "down"
hundredGigE 1/5:
Expand Down Expand Up @@ -97,6 +103,63 @@ interfaces:
- "hundredGigE 1/29"
- "hundredGigE 1/30"
mlag: "Port-channel 10"
Port-channel 20:
description: "MOC-R4PAC## Link"
state: "up"
portmode: "trunk"
tagged:
- 10
- 213
- 351:499
- 520:622
- 623
- 624:630
- 3801
- 3802
- 3803
mtu: 9216
lacp-rate: "fast"
lacp-members-active:
- "hundredGigE 1/1"
mlag: "Port-channel 20"
Port-channel 30:
description: "MOC-R4PAC## Link"
state: "up"
portmode: "trunk"
tagged:
- 10
- 213
- 351:499
- 520:622
- 623
- 624:630
- 3801
- 3802
- 3803
mtu: 9216
lacp-rate: "fast"
lacp-members-active:
- "hundredGigE 1/2"
mlag: "Port-channel 30"
Port-channel 40:
description: "MOC-R4PAC## Link"
state: "up"
portmode: "trunk"
tagged:
- 10
- 213
- 351:499
- 520:622
- 623
- 624:630
- 3801
- 3802
- 3803
mtu: 9216
lacp-rate: "fast"
lacp-members-active:
- "hundredGigE 1/3"
mlag: "Port-channel 40"
Port-channel 100:
description: "MOC-CORE-4 VLT LAG"
state: "up"
Expand Down
69 changes: 66 additions & 3 deletions host_vars/MOC-CORE-4/interfaces.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
interfaces:
hundredGigE 1/1:
state: "down"
description: "MOC-R4PAC##-SW-TORS-B Port 30"
state: "up"
mtu: 9216
hundredGigE 1/2:
state: "down"
description: "MOC-R4PAC##-SW-TORS-B Port 30"
state: "up"
mtu: 9216
hundredGigE 1/3:
state: "down"
description: "MOC-R4PAC##-SW-TORS-B Port 30"
state: "up"
mtu: 9216
hundredGigE 1/4:
state: "down"
hundredGigE 1/5:
Expand Down Expand Up @@ -97,6 +103,63 @@ interfaces:
- "hundredGigE 1/29"
- "hundredGigE 1/30"
mlag: "Port-channel 10"
Port-channel 20:
description: "MOC-R4PAC## Link"
state: "up"
portmode: "trunk"
tagged:
- 10
- 213
- 351:499
- 520:622
- 623
- 624:630
- 3801
- 3802
- 3803
mtu: 9216
lacp-rate: "fast"
lacp-members-active:
- "hundredGigE 1/1"
mlag: "Port-channel 20"
Port-channel 30:
description: "MOC-R4PAC## Link"
state: "up"
portmode: "trunk"
tagged:
- 10
- 213
- 351:499
- 520:622
- 623
- 624:630
- 3801
- 3802
- 3803
mtu: 9216
lacp-rate: "fast"
lacp-members-active:
- "hundredGigE 1/2"
mlag: "Port-channel 30"
Port-channel 40:
description: "MOC-R4PAC## Link"
state: "up"
portmode: "trunk"
tagged:
- 10
- 213
- 351:499
- 520:622
- 623
- 624:630
- 3801
- 3802
- 3803
mtu: 9216
lacp-rate: "fast"
lacp-members-active:
- "hundredGigE 1/3"
mlag: "Port-channel 40"
Port-channel 100:
description: "MOC-CORE-4 VLT LAG"
state: "up"
Expand Down
6 changes: 4 additions & 2 deletions host_vars/MOC-MCORE-1/interfaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ interfaces:
state: "up"
portmode: "access"
untagged: 930
stp-edge: true
stp:
edgeport: true
GigabitEthernet 1/2:
description: "MOC-CORE-2 MGMT"
state: "up"
portmode: "access"
untagged: 930
stp-edge: true
stp:
edgeport: true
GigabitEthernet 1/3:
state: "down"
GigabitEthernet 1/4:
Expand Down
6 changes: 4 additions & 2 deletions host_vars/MOC-MCORE-2/interfaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ interfaces:
state: "up"
portmode: "access"
untagged: 930
stp-edge: true
stp:
edgeport: true
GigabitEthernet 1/2:
description: "MOC-CORE-4 MGMT"
state: "up"
portmode: "access"
untagged: 930
stp-edge: true
stp:
edgeport: true
GigabitEthernet 1/3:
description: "MOC-R4PAC##-SW-MGMT"
state: "up"
Expand Down
Loading

0 comments on commit a9b7e9e

Please sign in to comment.