Skip to content
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

[yang] Add yang model for POE_PORT #21005

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
19 changes: 19 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Table of Contents
* [Port](#port)
* [Port Channel](#port-channel)
* [Portchannel member](#portchannel-member)
* [PoE Port](#poe-port)
* [Scheduler](#scheduler)
* [Port QoS Map](#port-qos-map)
* [Queue](#queue)
Expand Down Expand Up @@ -1997,6 +1998,24 @@ name as object key and member list as attribute.
}

```

### PoE Port

This table stores PoE port configuration. The interface name
is used as the key.

```
{
"POE_PORT": {
"Ethernet0": {
"enabled": "enable",
"pwr_limit": "50.0",
"priority": "high"
}
}
}
```

### Scheduler

```
Expand Down
2 changes: 2 additions & 0 deletions src/sonic-yang-models/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def run(self):
'./yang-models/sonic-ssh-server.yang',
'./yang-models/sonic-pbh.yang',
'./yang-models/sonic-port.yang',
'./yang-models/sonic-poe.yang',
'./yang-models/sonic-policer.yang',
'./yang-models/sonic-portchannel.yang',
'./yang-models/sonic-pfcwd.yang',
Expand Down Expand Up @@ -251,6 +252,7 @@ def run(self):
'./cvlyang-models/sonic-ssh-server.yang',
'./cvlyang-models/sonic-policer.yang',
'./cvlyang-models/sonic-port.yang',
'./cvlyang-models/sonic-poe.yang',
'./cvlyang-models/sonic-portchannel.yang',
'./cvlyang-models/sonic-pfcwd.yang',
'./cvlyang-models/sonic-route-common.yang',
Expand Down
42 changes: 42 additions & 0 deletions src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,48 @@
"LOGOUTPUT": "SYSLOG"
}
},
"POE_PORT": {
"Ethernet0": {
"enabled": "enable",
"pwr_limit": "50.0",
"priority": "high"
},
"Ethernet1": {
"enabled": "enable",
"pwr_limit": "50.0",
"priority": "high"
},
"Ethernet2": {
"enabled": "enable",
"pwr_limit": "50.0",
"priority": "high"
},
"Ethernet3": {
"enabled": "enable",
"pwr_limit": "50.0",
"priority": "high"
},
"Ethernet4": {
"enabled": "enable",
"pwr_limit": "50.0",
"priority": "high"
},
"Ethernet5": {
"enabled": "enable",
"pwr_limit": "50.0",
"priority": "high"
},
"Ethernet6": {
"enabled": "enable",
"pwr_limit": "50.0",
"priority": "high"
},
"Ethernet7": {
"enabled": "enable",
"pwr_limit": "50.0",
"priority": "crit"
}
},
"ACL_TABLE": {
"V4-ACL-TABLE": {
"type": "L3",
Expand Down
116 changes: 116 additions & 0 deletions src/sonic-yang-models/tests/yang_model_pytests/test_poe_port.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
import pytest


class TestPoePort:

def test_valid_data(self, yang_model):
data = {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth8",
"description": "Ethernet0",
"lanes": "65",
"mtu": 9000,
"name": "Ethernet0",
"speed": 25000
}
]
}
},
"sonic-poe:sonic-poe": {
"sonic-poe:POE_PORT": {
"POE_PORT_LIST": [
{
"ifname": "Ethernet0",
"enabled": "enable",
"pwr_limit": "50",
"priority": "high"
}
]
}
}
}

yang_model.load_data(data)

@pytest.mark.parametrize(
"enabled, error_message", [
("enable", None),
("disable", None),
("xyz", 'Invalid value "xyz" in "enabled" element.')]
)
def test_enabled_field(self, yang_model, enabled, error_message):
data = {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth8",
"description": "Ethernet0",
"lanes": "65",
"mtu": 9000,
"name": "Ethernet0",
"speed": 25000
}
]
}
},
"sonic-poe:sonic-poe": {
"sonic-poe:POE_PORT": {
"POE_PORT_LIST": [
{
"ifname": "Ethernet0",
"enabled": enabled,
"pwr_limit": "50",
"priority": "high"
}
]
}
}
}

yang_model.load_data(data, error_message)

@pytest.mark.parametrize(
"priority, error_message", [
("low", None),
("high", None),
("crit", None),
("xyz", 'Invalid value "xyz" in "priority" element.')]
)
def test_priority_field(self, yang_model, priority, error_message):
data = {
"sonic-port:sonic-port": {
"sonic-port:PORT": {
"PORT_LIST": [
{
"admin_status": "up",
"alias": "eth8",
"description": "Ethernet0",
"lanes": "65",
"mtu": 9000,
"name": "Ethernet0",
"speed": 25000
}
]
}
},
"sonic-poe:sonic-poe": {
"sonic-poe:POE_PORT": {
"POE_PORT_LIST": [
{
"ifname": "Ethernet0",
"enabled": "enable",
"pwr_limit": "50",
"priority": priority
}
]
}
}
}

yang_model.load_data(data, error_message)
77 changes: 77 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-poe.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
module sonic-poe {
yang-version 1.1;

namespace "http://github.com/sonic-net/sonic-poe";

prefix poe;

import sonic-types {
prefix stypes;
}

import sonic-port {
prefix port;
}

organization
"SONiC";

contact
"SONiC";

description
"PoE YANG Module for SONiC OS";

revision 2024-06-13 {
description
"First Revision";
}

container sonic-poe {

container POE_PORT {

description "Power over Ethernet configuration (POE_PORT table in config_db.json)";

typedef poe-priority {

type enumeration {
enum crit;
enum high;
enum low;
}
}

list POE_PORT_LIST {
key "ifname";
leaf ifname {
type leafref {
path /port:sonic-port/port:PORT/port:PORT_LIST/port:name;
}
description "Interface name from the PORT table in config_db.json";
}
leaf enabled {
type stypes:mode-status;
default disable;
description "PoE status on port. [enable/disable]";
}
leaf pwr_limit {
mandatory true;
type string {
length 1..255;
}
description "Power limit on PoE port. [0..999]";
}
leaf priority {
type poe-priority;
default high;
description "Port priority level. [crit/high/low]";
}
}
/* end of POE_PORT_LIST */
}
/* end of container POE_PORT */
}
/* end of top-level container sonic-poe */
}
/* end of module sonic-poe */
Loading