Skip to content

Add network policy model #295

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 2 commits 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
44 changes: 44 additions & 0 deletions models/enterprise_sonic/network_policy/deleted_example_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Using "deleted" state
#
# Before state:
# -------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
# voice vlan 2 cos 1 dscp 1
# voice-signaling vlan 3 untagged dscp 50
# !
# network-policy profile 2
# voice vlan 100 cos 7 dscp 12
# voice-signaling vlan 400 cos 7 dscp 45
# !
# network-policy profile 3
# voice-signaling vlan 80 cos 6 dscp 32
# !

- name: Delete network policy configuration
dellemc.enterprise_sonic.sonic_network_policy:
config:
- number: 1
applications:
- app_type: voice
dscp: 1
- number: 2
applications:
- app_type: voice
- number:3
state: deleted

# After state:
# ------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
# voice vlan 2 cos 1
# voice-signaling vlan 3 untagged dscp 50
# !
# network-policy profile 2
# voice-signaling vlan 400 cos 7 dscp 45
# !
29 changes: 29 additions & 0 deletions models/enterprise_sonic/network_policy/deleted_example_02.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Using "deleted" state
#
# Before state:
# -------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
# voice vlan 2 cos 1 dscp 1
# voice-signaling vlan 3 untagged dscp 50
# !
# network-policy profile 2
# voice vlan 100 cos 7 dscp 12
# voice-signaling vlan 400 cos 7 dscp 45
# !
# network-policy profile 3
# voice-signaling vlan 80 cos 6 dscp 32
# !

- name: Delete all network policy configuration
dellemc.enterprise_sonic.sonic_network_policy:
config:
state: deleted

# After state:
# ------------
#
# sonic# show running-configuration
# (No network policy configuration present)
32 changes: 32 additions & 0 deletions models/enterprise_sonic/network_policy/merged_example_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Using "merged" state
#
# Before state:
# -------------
#
# sonic# show running-configuration
# (No network policy configuration present)

- name: Merge network policy configuration
dellemc.enterprise_sonic.sonic_network_policy:
config:
- number: 1
applications:
- app_type: voice
vlan_id: 2
priority: 1
dscp: 1
- app_type: voice_signaling
vlan_id: 3
tagged: false
dscp: 50
state: merged

# After state:
# ------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
# voice vlan 2 cos 1 dscp 1
# voice-signaling vlan 3 untagged dscp 50
# !
36 changes: 36 additions & 0 deletions models/enterprise_sonic/network_policy/overridden_example_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Using "overridden" state
#
# Before state:
# -------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
# voice vlan 2 cos 1 dscp 1
# voice-signaling vlan 3 untagged dscp 50
# !
# network-policy profile 2
# voice vlan 100 cos 7 dscp 12
# voice-signaling vlan 400 cos 7 dscp 45
# !

- name: Override network policy configuration
dellemc.enterprise_sonic.sonic_network_policy:
config:
- number: 1
applications:
- app_type: voice
vlan_id: 1
tagged: true
priority: 0
dscp: 0
state: overridden

# After state:
# ------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
# voice vlan 1 cos 0 dscp 0
# !
40 changes: 40 additions & 0 deletions models/enterprise_sonic/network_policy/replaced_example_01.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Using "replaced" state
#
# Before state:
# -------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
# voice vlan 2 cos 1 dscp 1
# voice-signaling vlan 3 untagged dscp 50
# !
# network-policy profile 2
# voice vlan 100 cos 7 dscp 12
# voice-signaling vlan 400 cos 7 dscp 45
# !

- name: Replace network policy configuration
dellemc.enterprise_sonic.sonic_network_policy:
config:
- number: 1
applications:
- app_type: voice
vlan_id: 1
tagged: true
priority: 0
dscp: 0
state: replaced

# After state:
# ------------
#
# sonic# show running-configuration
# !
# network-policy profile 1
# voice vlan 1 cos 0 dscp 0
# !
# network-policy profile 2
# voice vlan 100 cos 7 dscp 12
# voice-signaling vlan 400 cos 7 dscp 45
# !
67 changes: 67 additions & 0 deletions models/enterprise_sonic/network_policy/sonic_network_policy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
GENERATOR_VERSION: '1.0'
NETWORK_OS: sonic
RESOURCE: network_policy
COPYRIGHT: Copyright 2025 Dell Inc. or its subsidiaries. All Rights Reserved.
DOCUMENTATION: |
module: sonic_network_policy
version_added: 3.1.0
notes:
- Tested against Enterprise SONiC Distribution by Dell Technologies.
- Supports C(check_mode).
short_description: Manage network policy configuration on SONiC
description:
- This module provides configuration management of network policy for devices running SONiC
author: S. Talabi (@stalabi1)
options:
config:
description:
- List of network policy configurations
type: list
elements: dict
suboptions:
number:
description:
- Network policy number, range 1-128
type: int
required: true
applications:
description:
- List of network policy application configurations
type: list
elements: dict
suboptions:
app_type:
description:
- Media type of the application
type: str
choices: ['voice', 'voice_signaling']
required: true
vlan_id:
description:
- VLAN identifier, range 1-4094
type: int
tagged:
description:
- Indicates that the application is using a tagged VLAN
type: bool
priority:
description:
- Priority of VLAN, range 0-7
type: int
dscp:
description:
- DSCP value of VLAN, range 0-63
type: int
state:
description:
- The state of the configuration after module completion
type: str
choices: ['merged', 'deleted', 'replaced', 'overridden']
default: merged
EXAMPLES:
- deleted_example_01.txt
- deleted_example_02.txt
- merged_example_01.txt
- overridden_example_01.txt
- replaced_example_01.txt