Skip to content

Add MAC model #289

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
38 changes: 38 additions & 0 deletions models/enterprise_sonic/mac/deleted_example_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Using deleted
#
# Before state:
# -------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 30
# MAC Move Dampening Interval : 20
# sonic# show running-configuration | grep mac
# mac address-table 00:11:11:11:11:11 Vlan1 Ethernet20
# mac address-table 00:22:22:22:22:22 Vlan2 Ethernet24
# mac address-table aging-time 10

- name: Delete MAC cofigurations
dellemc.enterprise_sonic.sonic_mac:
config:
- vrf_name: 'default'
mac:
aging_time: 10
dampening_interval: 20
dampening_threshold: 30
mac_table_entries:
- mac_address: '00:11:11:11:11:11'
vlan_id: 1
interface: 'Ethernet20'
- mac_address: '00:22:22:22:22:22'
vlan_id: 2
interface: 'Ethernet24'
state: deleted

# After state:
# ------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 5
# MAC Move Dampening Interval : 5
# sonic# show running-configuration | grep mac
# (No mac configuration pressent)
42 changes: 42 additions & 0 deletions models/enterprise_sonic/mac/merged_example_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Using merged
#
# Before state:
# -------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 5
# MAC Move Dampening Interval : 5
# sonic# show running-configuration | grep mac
# (No mac configuration pressent)

- name: Merge MAC configurations
dellemc.enterprise_sonic.sonic_mac:
config:
- vrf_name: 'default'
mac:
aging_time: 50
dampening_interval: 20
dampening_threshold: 30
mac_table_entries:
- mac_address: '00:00:5e:00:53:af'
vlan_id: 1
interface: 'Ethernet20'
- mac_address: '00:33:33:33:33:33'
vlan_id: 2
interface: 'Ethernet24'
- mac_address: '00:00:4e:00:24:af'
vlan_id: 3
interface: 'Ethernet28'
state: merged

# After state:
# ------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 30
# MAC Move Dampening Interval : 20
# sonic# show running-configuration | grep mac
# mac address-table 00:00:5e:00:53:af Vlan1 Ethernet20
# mac address-table 00:33:33:33:33:33 Vlan2 Ethernet24
# mac address-table 00:00:4e:00:24:af Vlan3 Ethernet28
# mac address-table aging-time 50
42 changes: 42 additions & 0 deletions models/enterprise_sonic/mac/overridden_example_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Using overridden
#
# Before state:
# -------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 60
# MAC Move Dampening Interval : 30
# sonic# show running-configuration | grep mac
# mac address-table 00:00:5e:00:53:af Vlan3 Ethernet24
# mac address-table 00:33:33:33:33:33 Vlan2 Ethernet24
# mac address-table 00:00:4e:00:24:af Vlan3 Ethernet28
# mac address-table 00:44:44:44:44:44 Vlan2 Ethernet20
# mac address-table aging-time 45

- name: Override MAC cofigurations
dellemc.enterprise_sonic.sonic_mac:
config:
- vrf_name: 'default'
mac:
aging_time: 10
dampening_interval: 20
dampening_threshold: 30
mac_table_entries:
- mac_address: '00:11:11:11:11:11'
vlan_id: 1
interface: 'Ethernet20'
- mac_address: '00:22:22:22:22:22'
vlan_id: 2
interface: 'Ethernet24'
state: overridden

# After state:
# ------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 30
# MAC Move Dampening Interval : 20
# sonic# show running-configuration | grep mac
# mac address-table 00:11:11:11:11:11 Vlan1 Ethernet20
# mac address-table 00:22:22:22:22:22 Vlan2 Ethernet24
# mac address-table aging-time 10
43 changes: 43 additions & 0 deletions models/enterprise_sonic/mac/replaced_example_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Using replaced
#
# Before state:
# -------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 30
# MAC Move Dampening Interval : 20
# sonic# show running-configuration | grep mac
# mac address-table 00:00:5e:00:53:af Vlan1 Ethernet20
# mac address-table 00:33:33:33:33:33 Vlan2 Ethernet24
# mac address-table 00:00:4e:00:24:af Vlan3 Ethernet28
# mac address-table aging-time 50

- name: Replace MAC configurations
dellemc.enterprise_sonic.sonic_mac:
config:
- vrf_name: 'default'
mac:
aging_time: 45
dampening_interval: 30
dampening_threshold: 60
mac_table_entries:
- mac_address: '00:00:5e:00:53:af'
vlan_id: 3
interface: 'Ethernet24'
- mac_address: '00:44:44:44:44:44'
vlan_id: 2
interface: 'Ethernet20'
state: replaced

# After state:
# ------------
#
# sonic# show mac dampening
# MAC Move Dampening Threshold : 60
# MAC Move Dampening Interval : 30
# sonic# show running-configuration | grep mac
# mac address-table 00:00:5e:00:53:af Vlan3 Ethernet24
# mac address-table 00:33:33:33:33:33 Vlan2 Ethernet24
# mac address-table 00:00:4e:00:24:af Vlan3 Ethernet28
# mac address-table 00:44:44:44:44:44 Vlan2 Ethernet20
# mac address-table aging-time 45
78 changes: 78 additions & 0 deletions models/enterprise_sonic/mac/sonic_mac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
GENERATOR_VERSION: '1.0'
NETWORK_OS: sonic
RESOURCE: mac
COPYRIGHT: Copyright 2024 Dell Inc. or its subsidiaries. All Rights Reserved.
DOCUMENTATION: |
module: sonic_mac
version_added: "2.1.0"
notes:
- Tested against Enterprise SONiC Distribution by Dell Technologies.
- Supports C(check_mode).
short_description: Manage MAC configuration on SONiC
description:
- This module provides configuration management of MAC for devices running SONiC
author: "Shade Talabi (@stalabi1)"
options:
config:
description:
- A list of MAC configurations.
type: list
elements: dict
suboptions:
vrf_name:
description:
- Specifies the VRF name.
type: str
default: 'default'
mac:
description:
- Configuration attributes for MAC.
type: dict
suboptions:
aging_time:
description:
- Time in seconds of inactivity before the MAC entry is timed out.
type: int
default: 600
dampening_interval:
description:
- Interval for which mac movements are observed before disabling MAC learning on a port.
type: int
default: 5
dampening_threshold:
description:
- Number of MAC movements allowed per second before disabling MAC learning on a port.
type: int
default: 5
mac_table_entries:
description:
- Configuration attributes for MAC table entries.
type: list
elements: dict
suboptions:
mac_address:
description:
- MAC address for the dynamic or static MAC table entry.
type: str
required: True
vlan_id:
description:
- ID number of VLAN on which the MAC address is present.
type: int
required: True
interface:
description:
- Specifies the interface for the MAC table entry.
type: str
state:
description:
- The state of the configuration after module completion
type: str
choices: ['merged', 'deleted', 'replaced', 'overridden']
default: merged
EXAMPLES:
- deleted_example_01.txt
- merged_example_01.txt
- overridden_example_01.txt
- replaced_example_01.txt