-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Serhiy Boiko <[email protected]>
- Loading branch information
1 parent
961cdc0
commit d532022
Showing
5 changed files
with
256 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
src/sonic-yang-models/tests/yang_model_pytests/test_poe_port.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 */ |