-
Notifications
You must be signed in to change notification settings - Fork 92
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 subscription support for ethernet interfaces. #140
Conversation
63a9064
to
39bbe9d
Compare
Ping @sachinholla @anand-kumar-subramanian @mbalachandar for review. |
translib/transformer/xfmr_intf.go
Outdated
if inParams.oper == SUBSCRIBE { | ||
var _intfTypeList []E_InterfaceType | ||
|
||
if idx == "*" || idx != "0" { |
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.
Shouldn't it be if idx != "*" && idx != "0" {/* error */}
. Current condition rejects the wildcard key and hence blocks traget_defined subscription at a higher level like interface list
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 the PR @sachinholla. I have addressed the comments. Please review.
if strings.HasPrefix(targetUriPath, "/openconfig-interfaces:interfaces/interface/config") { | ||
tblList = append(tblList, "PORT") | ||
} else if strings.HasPrefix(targetUriPath, "/openconfig-interfaces:interfaces/interface/state") { | ||
tblList = append(tblList, "PORT_TABLE") |
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.
What about /interfaces/interface/state/counters
path? It should have been mapped to COUNTERS, right?
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.
The Subscribe_intf_get_counters_xfmr handles the mapping of interfaces/interface/state/counters to COUNTERS_PORT_NAME_MAP
translib/transformer/xfmr_intf.go
Outdated
@@ -725,7 +752,9 @@ var DbToYang_intf_eth_port_config_xfmr SubTreeXfmrDbToYang = func(inParams XfmrP | |||
intfsObj := getIntfsRoot(inParams.ygRoot) | |||
pathInfo := NewPathInfo(inParams.uri) | |||
uriIfName := pathInfo.Var("name") | |||
ifName := uriIfName | |||
ifName := *(&uriIfName) |
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.
What does this do? How it is different from normal assignment??
translib/transformer/xfmr_intf.go
Outdated
ifName := uriIfName | ||
ifName := *(&uriIfName) | ||
|
||
log.Infof("DbToYang_intf_eth_port_config_xfmr: Interface name : %s ", ifName) |
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 can be a verbose log
translib/transformer/xfmr_intf.go
Outdated
var result XfmrSubscOutParams | ||
|
||
if inParams.subscProc == TRANSLATE_SUBSCRIBE { | ||
log.Info("Subscribe_intf_eth_port_config_xfmr: inParams.subscProc: ", inParams.subscProc) |
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.
I feel this log is unnecessary.. You have already checked for the inParams.subscProc
value and taken a decision. Make it a verbose log if you want to retain
translib/transformer/xfmr_intf.go
Outdated
|
||
if ifName == "" { | ||
ifName = "*" | ||
} |
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.
Shorthand: ifName := pathInfo.StringVar("name", "*")
translib/transformer/xfmr_intf.go
Outdated
result.dbDataMap = RedisDbSubscribeMap{db.ConfigDB: { | ||
"PORT": {ifName: {"autoneg": "auto-negotiate", "speed": "port-speed"}}}} | ||
|
||
log.Info("Subscribe_intf_eth_port_config_xfmr: result ", result) |
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.
Change to verbose log please
translib/transformer/xfmr_intf.go
Outdated
} | ||
|
||
var DbToYangPath_intf_eth_port_config_path_xfmr PathXfmrDbToYangFunc = func(params XfmrDbToYgPathParams) error { | ||
log.Info("DbToYangPath_intf_eth_port_config_path_xfmr: params: ", params) |
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.
User verbose log while logging the whole struct..
translib/transformer/xfmr_intf.go
Outdated
} | ||
|
||
if (params.tblName == "PORT") && (len(params.tblKeyComp) > 0) { | ||
params.ygPathKeys[intfRoot+"/name"] = *(¶ms.tblKeyComp[0]) |
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.
Why *(&xyz)
do?
translib/transformer/xfmr_intf.go
Outdated
ifKey = "*" | ||
} else { | ||
sonicIfName := &uriIfName | ||
ifKey = *sonicIfName |
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.
Why take an address and then dereference? I think just the following is sufficient -- ifKey := pathInfo.StringVar("name", "*")
b3ab98b
to
eb56bf4
Compare
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.
Changes look fine.. Please verify target_defined subscription for /interfaces/interface[name=*]
path as well.
What I did:
Added gNMI subscription transformer support for OpenConfig Ethernet Interfaces.
Why I did it?
Replacing existing intf_app.go code with transformer code.
How did I verify the changes?
Verified by manually testing gNMI subscription.
Log files for gNMI subscription manual run:
UT logs community subscription ON change IPv4v6.docx
UT logs Community subscription SAMPLE IPv4v6.docx
UT logs Community subscription TARGET DEFINED IPv4v6.docx
UT logs community subscription - onchange Eth.docx
UT logs community subscription TARGET DEFINED ETH.docx
UT LOGS community subscription SAMPLE Eth.docx
UT logs community gnmi subscription TARGET DEFINED intf top level.docx
UT logs community ON CHANGE intf top level.docx
UT logs community subscription SAMPLE intf top level.docx