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

Add YANG model for FABRIC_PORT #14282

Closed
Show file tree
Hide file tree
Changes from 3 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
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 @@ -264,3 +264,14 @@ def test_vlan_crm(self):
"ipv6_neighbor_threshold_type": "used"
}
})

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 @@ -378,5 +378,17 @@
"ipv6_neighbor_threshold_type": "used"
}
}
},
"sonic-fabric-port:sonic-fabric-port": {
"sonic-fabric-port:FABRIC_PORT": {
"FABRIC_PORT_LIST": [
{
"name": "Fabric0",
"alias": "Fabric0",
"isolateStatus": "False",
"lanes": "0"
}
]
}
}
}
21 changes: 21 additions & 0 deletions src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Table of Contents
* [Device neighbor metada](#device-neighbor-metada)
* [DHCP_RELAY](#dhcp_relay)
* [DSCP_TO_TC_MAP](#dscp_to_tc_map)
* [FABRIC_PORT](#fabric-port)
* [FG_NHG](#fg_nhg)
* [FG_NHG_MEMBER](#fg_nhg_member)
* [FG_NHG_PREFIX](#fg_nhg_prefix)
Expand Down Expand Up @@ -985,6 +986,26 @@ 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 @@ -116,6 +116,7 @@ def run(self):
'./yang-models/sonic-events-swss.yang',
'./yang-models/sonic-events-syncd.yang',
'./yang-models/sonic-extension.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 @@ -204,6 +205,7 @@ def run(self):
'./cvlyang-models/sonic-events-syncd.yang',
'./cvlyang-models/sonic-device_neighbor_metadata.yang',
'./cvlyang-models/sonic-extension.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 @@ -1260,6 +1260,18 @@
"allow_insecure": "false"
}
},
"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"
}
]
}
}
}
}
59 changes: 59 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,59 @@
module sonic-fabric-port{

yang-version 1.1;

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

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add description of the leaf nodes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

description "Isolation status of a fabric port";
type string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the isolateStatus is not speicified should there be a default value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

pattern "False|True";
}
default "False";
}

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

leaf lanes {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, the fabric port configuration without specifying lanes is not valid, can we add this field as mandatory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

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 */