Skip to content

Commit

Permalink
Add YANG model for FABRIC_PORT (sonic-net#15629)
Browse files Browse the repository at this point in the history
#### Why I did it

Introduce YANG model for FABRIC in CONFIG_DB, which was added in sonic-net#14170.

#### How I did it

This is a clone of @jfeng-arista's PR sonic-net#14282 to resolve conflicts with upstream changes. 

#### How to verify it

Passing pipeline build is sufficient.
  • Loading branch information
kenneth-arista authored and mssonicbld committed Sep 3, 2023
1 parent 7b89066 commit 04989ec
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/sonic-config-engine/tests/test_cfggen_from_yang.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,14 @@ def test_fabric_monitor_data_table(self):
"monPollThreshRecovery": "8"
}
})

def test_fabric_port_table(self):
arg = ["--var-json", "FABRIC_PORT"]
output = json.loads(self.run_script_with_yang_arg(arg))
assert(output == {\
"Fabric0": {
"alias": "Fabric0",
"isolateStatus": "False",
"lanes": "0"
}
})
12 changes: 12 additions & 0 deletions src/sonic-config-engine/tests/test_yang_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -388,5 +388,17 @@
"monPollThreshRecovery": "8"
}
}
},
"sonic-fabric-port:sonic-fabric-port": {
"sonic-fabric-port:FABRIC_PORT": {
"FABRIC_PORT_LIST": [
{
"name": "Fabric0",
"alias": "Fabric0",
"isolateStatus": "False",
"lanes": "0"
}
]
}
}
}
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 @@ -34,6 +34,7 @@ Table of Contents
* [FG_NHG_MEMBER](#fg_nhg_member)
* [FG_NHG_PREFIX](#fg_nhg_prefix)
* [FABRIC_MONITOR](#fabric-monitor)
* [FABRIC_PORT](#fabric-port)
* [FLEX_COUNTER_TABLE](#flex_counter_table)
* [Hash](#hash)
* [IPv6 Link-local] (#ipv6-link-local)
Expand Down Expand Up @@ -1063,6 +1064,24 @@ The FG_NHG_PREFIX table provides the FG_NHG_PREFIX for which FG behavior is desi
```

### FABRIC_PORT
```
{
"FABRIC_PORT": {
"Fabric0": {
"alias": "Fabric0",
"isolateStatus": "False",
"lanes": "0"
},
"Fabric1": {
"alias": "Fabric1",
"isolateStatus": "False",
"lanes": "1"
}
}
}
```

### MPLS_TC_TO_TC_MAP
```
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 @@ -117,6 +117,7 @@ def run(self):
'./yang-models/sonic-events-syncd.yang',
'./yang-models/sonic-extension.yang',
'./yang-models/sonic-fabric-monitor.yang',
'./yang-models/sonic-fabric-port.yang',
'./yang-models/sonic-flex_counter.yang',
'./yang-models/sonic-fine-grained-ecmp.yang',
'./yang-models/sonic-feature.yang',
Expand Down Expand Up @@ -209,6 +210,7 @@ def run(self):
'./cvlyang-models/sonic-device_neighbor_metadata.yang',
'./cvlyang-models/sonic-extension.yang',
'./cvlyang-models/sonic-fabric-monitor.yang',
'./cvlyang-models/sonic-fabric-port.yang',
'./cvlyang-models/sonic-flex_counter.yang',
'./cvlyang-models/sonic-feature.yang',
'./cvlyang-models/sonic-fine-grained-ecmp.yang',
Expand Down
12 changes: 12 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 @@ -1275,6 +1275,18 @@
"monPollThreshRecovery": "8"
}
},
"FABRIC_PORT": {
"Fabric0": {
"alias": "Fabric0",
"isolateStatus": "False",
"lanes": "0"
},
"Fabric1": {
"alias": "Fabric1",
"isolateStatus": "False",
"lanes": "1"
}
},
"FLEX_COUNTER_TABLE": {
"PFCWD": {
"FLEX_COUNTER_STATUS": "enable"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"FABRIC_PORT_POSITIVE_CONFIG": {
"desc": "Configure FABRIC_PORT no failure."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"FABRIC_PORT_POSITIVE_CONFIG": {
"sonic-fabric-port:sonic-fabric-port": {
"sonic-fabric-port:FABRIC_PORT": {
"FABRIC_PORT_LIST": [
{
"name": "Fabric0",
"alias": "Fabric0",
"isolateStatus": "False",
"lanes": "0"
}
]
}
}
}
}
61 changes: 61 additions & 0 deletions src/sonic-yang-models/yang-models/sonic-fabric-port.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
module sonic-fabric-port{

yang-version 1.1;

namespace "https://github.com/sonic-net/sonic-fabric-port";
prefix fabric-port;

import sonic-types {
prefix stypes;
}

description "FABRIC_PORT yang Module for SONiC OS";

revision 2023-03-14 {
description "First Revision";
}

container sonic-fabric-port {

container FABRIC_PORT {

description "FABRIC_PORT part of config_db.json";

list FABRIC_PORT_LIST {

key "name";

leaf name {
type string {
length 1..128;
}
}

leaf isolateStatus {
description "Isolation status of a fabric port";
type stypes:boolean_type;
default "False";
}

leaf alias {
description "Alias of a fabric port";
type string {
length 1..128;
}
}

leaf lanes {
description "Lanes of a fabric port";
mandatory true;
type string {
length 1..128;
}
}

} /* end of list FABRIC_PORT_LIST */

} /* end of container FABRIC_PORT */

} /* end of container sonic-fabric-port */

} /* end of module sonic-fabric-port */

0 comments on commit 04989ec

Please sign in to comment.