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

Removing map-leaf and map-list sonic yang extensions. #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Removing map-leaf and map-list sonic yang extensions as nested list c…
…an be handled from CVL code.
maheshwari-mayank committed Jul 19, 2021
commit 39bccf34ed61d60ee9ca6bc7ace38d51237577aa
9 changes: 7 additions & 2 deletions cvl/internal/yparser/yparser.go
Original file line number Diff line number Diff line change
@@ -732,6 +732,13 @@ func getModelChildInfo(l *YParserListInfo, node *C.struct_lys_node,

for sChild := node.child; sChild != nil; sChild = sChild.next {
switch sChild.nodetype {
case C.LYS_LIST:
nodeInnerList := (*C.struct_lys_node_list)(unsafe.Pointer(sChild))
innerListkeys := (*[10]*C.struct_lys_node_leaf)(unsafe.Pointer(nodeInnerList.keys))
for idx := 0; idx < int(nodeInnerList.keys_size); idx++ {
keyName := C.GoString(innerListkeys[idx].name)
l.MapLeaf = append(l.MapLeaf, keyName)
}
case C.LYS_USES:
nodeUses := (*C.struct_lys_node_uses)(unsafe.Pointer(sChild))
if (nodeUses.when != nil) {
@@ -965,8 +972,6 @@ func GetModelListInfo(module *YParserModule) []*YParserListInfo {
l.RedisKeyDelim = argVal
case "key-pattern":
l.RedisKeyPattern = argVal
case "map-leaf":
l.MapLeaf = strings.Split(argVal, " ")
}
}

8 changes: 1 addition & 7 deletions cvl/testdata/schema/sonic-cablelength.yang
Original file line number Diff line number Diff line change
@@ -2,10 +2,6 @@ module sonic-cablelength {
namespace "https://github.com/Azure/sonic-cablelength";
prefix scl;

import sonic-extension {
prefix sonic-ext;
}

import sonic-port {
prefix prt;
}
@@ -24,14 +20,12 @@ module sonic-cablelength {
"Initial revision.";
}

container sonic-cablelength {
container sonic-cablelength {

container CABLE_LENGTH {

list CABLE_LENGTH_LIST {
key "name";
sonic-ext:map-list true; //special conversion for map tables
sonic-ext:map-leaf "port length"; //every key:value pair is mapped to list keys, e.g. "1":"7" ==> tc_num=1, dscp=7

leaf name {
type string;
8 changes: 1 addition & 7 deletions cvl/testdata/schema/sonic-dscp-tc-map.yang
Original file line number Diff line number Diff line change
@@ -2,10 +2,6 @@ module sonic-dscp-tc-map {
namespace "https://github.com/Azure/sonic-dscp-tc-map";
prefix dtm;

import sonic-extension {
prefix sonic-ext;
}

organization
"SONiC";

@@ -20,14 +16,12 @@ module sonic-dscp-tc-map {
"Initial revision.";
}

container sonic-dscp-tc-map {
container sonic-dscp-tc-map {

container DSCP_TO_TC_MAP {

list DSCP_TO_TC_MAP_LIST {
key "name";
sonic-ext:map-list true; //special conversion for map tables
sonic-ext:map-leaf "dscp tc_num"; //every key:value pair is mapped to list keys, e.g. "1":"7" ==> tc_num=1, dscp=7

leaf name {
type string;
8 changes: 1 addition & 7 deletions cvl/testdata/schema/sonic-pfc-priority-queue-map.yang
Original file line number Diff line number Diff line change
@@ -2,10 +2,6 @@ module sonic-pfc-priority-queue-map {
namespace "https://github.com/Azure/sonic-pfc-priority-queue-map";
prefix ppq;

import sonic-extension {
prefix sonic-ext;
}

organization
"SONiC";

@@ -20,14 +16,12 @@ module sonic-pfc-priority-queue-map {
"Initial revision.";
}

container sonic-pfc-priority-queue-map {
container sonic-pfc-priority-queue-map {

container MAP_PFC_PRIORITY_TO_QUEUE {

list MAP_PFC_PRIORITY_TO_QUEUE_LIST {
key "name";
sonic-ext:map-list true; //special conversion for map tables
sonic-ext:map-leaf "pfc_priority qindex"; //every key:value pair is mapped to list keys, e.g. "1":"7" ==> tc_num=1, dscp=7

leaf name {
type string;
6 changes: 0 additions & 6 deletions cvl/testdata/schema/sonic-tc-priority-group-map.yang
Original file line number Diff line number Diff line change
@@ -2,10 +2,6 @@ module sonic-tc-priority-group-map {
namespace "https://github.com/Azure/sonic-tc-priority-group-map";
prefix tpg;

import sonic-extension {
prefix sonic-ext;
}

organization
"SONiC";

@@ -26,8 +22,6 @@ module sonic-tc-priority-group-map {

list TC_TO_PRIORITY_GROUP_MAP_LIST {
key "name";
sonic-ext:map-list "true"; //special conversion for map tables
sonic-ext:map-leaf "tc_num pg_num"; //every key:value pair is mapped to list keys, e.g. "1":"7" ==> tc_num=1, dscp=7

leaf name {
type string;
6 changes: 0 additions & 6 deletions cvl/testdata/schema/sonic-tc-queue-map.yang
Original file line number Diff line number Diff line change
@@ -2,10 +2,6 @@ module sonic-tc-queue-map {
namespace "https://github.com/Azure/sonic-tc-queue-map";
prefix tqm;

import sonic-extension {
prefix sonic-ext;
}

organization
"SONiC";

@@ -26,8 +22,6 @@ module sonic-tc-queue-map {

list TC_TO_QUEUE_MAP_LIST {
key "name";
sonic-ext:map-list "true"; //special conversion for map tables
sonic-ext:map-leaf "tc_num qindex"; //every key:value pair is mapped to list keys, e.g. "1":"7" ==> tc_num=1, qindex=7

leaf name {
type string;
18 changes: 3 additions & 15 deletions models/yang/sonic/common/sonic-extension.yang
Original file line number Diff line number Diff line change
@@ -35,22 +35,10 @@ module sonic-extension {
argument "value";
}

extension map-list {
description
"If it is a map list";
argument "value";
}

extension map-leaf {
description
"Map leaf names";
argument "value";
}

extension custom-validation {
description
"Extension for custom validation.
Platform specific validation can be implemented using custom validation.";
argument "handler";
"Extension for custom validation.
Platform specific validation can be implemented using custom validation.";
argument "handler";
}
}