-
Notifications
You must be signed in to change notification settings - Fork 82
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
Adding support for OC YANG interfaces #125
Adding support for OC YANG interfaces #125
Conversation
dc1deea
to
1803bc2
Compare
@sayedsaquibbrcm will help review |
@nagarwal03 pls clear EasyCLA and build failures |
ee21a68
to
b13d276
Compare
@adyeung Fixed EasyCLA and build failures. |
Co-authored-by: Satoru-Shinohara <satoru.shinohara@dell.com> Co-authored-by: Nikita Agarwal <nikita_agarwal1@dell.com>
Co-authored-by: Satoru-Shinohara <satoru.shinohara@dell.com> Co-authored-by: Nikita Agarwal <nikita_agarwal1@dell.com>
a25aa92
to
471426b
Compare
deviate not-supported; | ||
} | ||
|
||
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv6/oc-ip:state { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Openconfig mandates that every attribute under "config" container should be mirrored in "state" container too.
Here, interfaces/interface/subinterfaces/subinterface/ipv4/config/enabled is present(see line 164),
but interfaces/interface/subinterfaces/subinterface/ipv4/state is pruned.
This is inconsistent with OpenConfig guidelines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be corrected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing this @sayedsaquibbrcm.
The two ipv4 containers are not supported and are marked correctly in the PR. (Attached lines)
-
interfaces/interface/subinterfaces/subinterface/ipv4/config
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv4/oc-ip:config { -
interfaces/interface/subinterfaces/subinterface/ipv4/state
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv4/oc-ip:state {
The ipv6 config enabled attribute is supported and the corresponding ipv6 state attribute is now marked as supported.
- interfaces/interface/subinterfaces/subinterface/ipv6/config/enabled ===> Supported already
- interfaces/interface/subinterfaces/subinterface/ipv6/state/enabled ===> Addressed in a new commit and marked as supported.
translib/transformer/xfmr_intf.go
Outdated
|
||
idx := pathInfo.Var("index") | ||
|
||
if idx != "0" && idx != "*" && idx != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HLD mentions that routed subinterfaces are not supported. We should remove this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the code.
translib/transformer/xfmr_intf.go
Outdated
} | ||
var idx string | ||
|
||
if strings.Contains(inParams.key, ".") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per HLD, we do not support subinterfaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this.
deviate not-supported; | ||
} | ||
|
||
deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv6/oc-ip:state { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be corrected
|
||
if idx != "" { | ||
i64, _ := strconv.ParseUint(idx, 10, 32) | ||
i32 = uint32(i64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should return error if i32 != 0, because subinterface is not supported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sayedsaquibbrcm I've addressed the review comments.
log.Errorf("Extracting Interface type for Interface: %s failed!", ifName) | ||
return "", tlerr.New(ierr.Error()) | ||
} | ||
err = performIfNameKeyXfmrOp(&inParams, &requestUriPath, &ifName, intfType, i32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function is also not returning error if subintfid != 0.
We should ensure that operations on URIs with subinterface index > 0, return error, instead of succeeding and modifying unintended config.
translib/transformer/xfmr_intf.go
Outdated
if xpath == "/openconfig-interfaces:interfaces/interface/subinterfaces/subinterface/ipv6/config/enabled" { | ||
if len(inParams.subOpDataMap) > 0 { | ||
dbMap := make(map[string]map[string]db.Value) | ||
if inParams.subOpDataMap[4] != nil && (*inParams.subOpDataMap[4])[db.ConfigDB] != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use const for brevity
https://github.com/sonic-net/sonic-mgmt-common/blob/master/translib/transformer/xconst.go#L73
const (
GET Operation = iota + 1
CREATE
REPLACE
UPDATE
DELETE
SUBSCRIBE
MAXOPER
)
(*inParams.dbDataMap)[db.ConfigDB]["SUBINTF_TBL"]["0"].Field["NULL"] = "NULL" | ||
} | ||
tblList = append(tblList, "SUBINTF_TBL") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in the else case, should we return error is idx != 0 to avoid inadvertent issues?
|
||
idx := pathInfo.Var("index") | ||
|
||
subintf_key = idx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, idx > 0 should return error...
getIntfTypeByName(ifName) will not be returning error for subif id > 0, which make the type of interface as subinterface.
rmap := make(map[string]interface{}) | ||
var err error | ||
i64, _ := strconv.ParseUint(idx, 10, 32) | ||
rmap["index"] = i64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here
id := pathInfo.Var("index") | ||
log.Info("DbToYang_subif_index_xfmr: Sub-interface Index = ", id) | ||
i64, _ := strconv.ParseUint(id, 10, 32) | ||
res_map["index"] = i64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here also
translib/transformer/xfmr_intf.go
Outdated
|
||
var subIdxStr string | ||
var name string | ||
if strings.Contains(intfName, ".") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code may be irrelevant ... pls remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls see previous comments
41a6d8a
to
5b2f5fa
Compare
Why I did it Build pipeline is broken, and build error is introduced bye sonic-mgmt-common: sonic-net/sonic-mgmt-common#125 How I did it Disable related test How to verify it Run azure pipeline to verify build
What we did:
Added transformer support for OpenConfig Interfaces as specified in the HLD
Why we did it?
Earlier, intf_app.go was used for interfaces configuration. Replacing it with xfmr_intf.go to add transformer support for OpenConfig YANG interfaces configuration via REST and gNMI.
How did we verify the changes?
Verified by adding unit test files for REST and gNMI.
Unit test file changes:
testapp.log
Log files for REST manual run:
REST_ETHERNET.log
REST_SUBINTERFACE.log
REST_TOP.log
Log files for gNMI manual run:
GNMI_ETH.log
GNMI_SUB.log
GNMI_TOP.log
Translib.test Logs:
translib.test log
Support added: