Dear SONiC Management Workgroup,
My name is Brian, and I am a developer that is subscribing SONiC project. Recently I am trying to analyze and make some implementation in docker-sonic-mgmt-framework and got some problem that I don't know if it is issue.
I tried to write Transformer call back function to map my Openconfig Yang to SONiC Yang with mapping is shared in attached figure.

After writing key-xfmr and field-xfmr, I got this error when raising get request for uri:
/openconfig-vlan:vlans/vlan - common_app.go:298] ocbinds.Unmarshal() returned : key field vlan-id (*uint16) has nil value <nil>
- handler.go:70] [REST-2] Translib error *errors.errorString - key field vlan-id (*uint16) has nil value <nil>
- handler.go:90] [REST-2] Sending response 500, type=application/yang-data+json, size=96
- I checked the result mapping for return data and found that leaf key vlan-id was not filled in this map:
- map[vlan:[map[config:map[status:Disable vlan-id:200] state:map[status:Disable vlan-id:200]]]]
- The expected result map should be:
- map[vlan:[map[config:map[status:Disable vlan-id:200] vlan-id:200 state:map[status:Disable vlan-id:200]]]]
When I trace source code from Transformer core function, I found that in
xlate_from_db.go (
function yangListInstanceDataFill())file we have one condition that we just apply to fill key leaf when
dbKey is equal with
keyFromCurUri:
if dbKey == keyFromCurUri {
for k, kv := range curKeyMap {
curMap[k] = kv
}
}
In my case, due to the key from Openconfig Yang is
vlan-id (uint16) is not equal with dbKey is
vlanName (string) so key leaf cannot be filled in map result.
- So I wonder this is issue from Transformer Function or I need to use other transformer function instead of key and field-xfmr.
- Is there any one can help me to explain why do we need the condition above?
I hope that I can receive answer from teams,
Thank you very much!
Best Regards,
Brian