Invalid yang regex?

109 views
Skip to first unread message

Xianlong Qin

unread,
Mar 4, 2020, 12:59:29 PM3/4/20
to sonic-mgmt...@googlegroups.com
Hello,

Is the pattern correct for ifname? I have tried the pattern on
https://yangcatalog.org/yangre/ , it complains {3} and {2} are invalid
syntax. I have an interface Ethernet100, got below error. Anybody can
check? Thanks.

rest-server I0304 17:40:12.095627 17 xlate.go:358] Payload
generated:{"INTERFACE":{"INTERFACE_IPADDR_LIST":[{},{"ip_prefix":"10.10.10.100/24","portname":"Ethernet100"}],"INTERFACE_LIST":[{"portname":"Ethernet100"},{}]}}
rest-server E0304 17:40:12.095859 17 handler.go:59] [REST-12]
Translib error *errors.errorString - Portname field doesn't have a
valid value

src/sonic-mgmt-framework/models/yang/sonic/sonic-port.yang:
leaf ifname {
type string {
pattern
"Ethernet([1-3][0-9]{3}|[1-9][0-9]{2}|[1-9][0-9]|[0-9])" {
error-message "Invalid interface name";
error-app-tag interface-name-invalid;
}
}
}


Regards,
Xianlong

Kwangs...@dell.com

unread,
Mar 4, 2020, 8:57:46 PM3/4/20
to rain...@gmail.com, sonic-mgmt...@googlegroups.com
Hi Xianlong,

I think the regex is ok.
Can you please check the physical ports configuration in /etc/sonic/config_db.json?
The Ethernet100 may not be available in your device.

Best,
Kwan

-----Original Message-----
From: sonic-mgmt...@googlegroups.com <sonic-mgmt...@googlegroups.com> On Behalf Of Xianlong Qin
Sent: Wednesday, March 4, 2020 9:59 AM
To: sonic-mgmt...@googlegroups.com
Subject: Invalid yang regex?


[EXTERNAL EMAIL]
--
You received this message because you are subscribed to the Google Groups "sonic-mgmt-workgroup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonic-mgmt-workg...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonic-mgmt-workgroup/CAPGx2p6NQ%3DY7pWzHrFa_19AafZ%3DSwkhm3jUb-gWNzLqq%3DWRs-Q%40mail.gmail.com.

Jeff...@dell.com

unread,
Mar 5, 2020, 1:19:58 PM3/5/20
to rain...@gmail.com, sonic-mgmt...@googlegroups.com, Justin...@dell.com
Hi Xianlong,

The request payload seems ok. Can you provide the output from "show version"? Wondering what build you're currently running.

Thanks,
Jeff

-----Original Message-----
From: sonic-mgmt...@googlegroups.com <sonic-mgmt...@googlegroups.com> On Behalf Of Xianlong Qin
Sent: Wednesday, March 4, 2020 9:59 AM
To: sonic-mgmt...@googlegroups.com
Subject: Invalid yang regex?


[EXTERNAL EMAIL]

Xianlong Qin

unread,
Mar 5, 2020, 7:09:39 PM3/5/20
to Jeff...@dell.com, sonic-mgmt...@googlegroups.com, Justin...@dell.com
Thanks Kwan and Jeff for the reply. Looks like the regex is ok. I
tried GET one Interface is ok. But GET ALL interfaces doesn't work.
Looks like line #186 is expecting portname in the request payload,
since it's get ALL portname is not provided, that's why processGet
failed. Can anyone confirm if this is a bug?

root@switch12:/home/admin# curl -X GET
"https://172.29.151.35/restconf/data/sonic-interface:sonic-interface"
-H "accept: application/yang-data+json" -k
{"ietf-restconf:errors":{"error":[{"error-type":"application","error-tag":"operation-failed"}]}}
root@switch12:/home/admin#
root@switch12:/home/admin# curl -X GET
"https://172.29.151.35/restconf/data/sonic-interface:sonic-interface/INTERFACE/INTERFACE_LIST=Ethernet100"
-H "accept: application/yang-data+json" -k
{"sonic-interface:INTERFACE_LIST":[{"portname":"Ethernet100"}]}

173 func (app *CommonApp) processGet(dbs [db.MaxDB]*db.DB)
(GetResponse, error) {
174 var err error
175 var payload []byte
176 var resPayload []byte
177 log.Info("processGet:path =", app.pathInfo.Path)
178
179 payload, err =
transformer.GetAndXlateFromDB(app.pathInfo.Path, app.ygotRoot, dbs)
180 if err != nil {
181 log.Error("transformer.transformer.GetAndXlateFromDB
failure. error:", err)
182 return GetResponse{Payload: payload, ErrSrc: AppErr}, err
183 }
184 targetObj, _ := (*app.ygotTarget).(ygot.GoStruct)
185 if targetObj != nil {
186 err = ocbinds.Unmarshal(payload, targetObj)
187 if err != nil {
188 log.Error("ocbinds.Unmarshal() failed. error:", err)
189 return GetResponse{Payload: payload, ErrSrc: AppErr}, err
190 }
191

Error Message:
Mar 5 15:52:31.900466 switch12 INFO mgmt-framework#supervisord:
rest-server I0305 23:52:31.900331 17 xlate.go:358] Payload
generated:{"INTERFACE":{"INTERFACE_IPADDR_LIST":[{"ip_prefix":"10.10.96.96/24","portname":"Ethernet96"},{},{"ip_prefix":"10.10.10.100/24","portname":"Ethernet100"},{}],"INTERFACE_LIST":[{},{"portname":"Ethernet96"},{},{"portname":"Ethernet100"}]}}
Mar 5 15:52:31.900772 switch12 INFO mgmt-framework#supervisord:
rest-server E0305 23:52:31.900606 17 common_app.go:189]
ocbinds.Unmarshal() failed. error:Portname field doesn't have a valid
value
Mar 5 15:52:31.900910 switch12 INFO mgmt-framework#supervisord:
rest-server E0305 23:52:31.900681 17 handler.go:59] [REST-13]
Translib error *errors.errorString - Portname field doesn't have a
valid value

Thanks,
Xianlong

Xianlong Qin

unread,
Mar 5, 2020, 7:46:06 PM3/5/20
to Jeff...@dell.com, sonic-mgmt...@googlegroups.com, Justin...@dell.com
Adding more info. I have added a debug message to print the payload,
there are some empty {} under "INTERFACE_LIST", not sure if that
causes the issue? We have below interfaces on switch.

root@switch12:/home/admin# show ip interfaces
Interface Master IPv4 address/mask Admin/Oper BGP Neighbor
Neighbor IP
----------- -------- ------------------- ------------
-------------- -------------
Ethernet96 10.10.96.96/24 up/down N/A N/A
Ethernet100 10.10.10.100/24 up/down N/A N/A
Loopback0 10.1.0.32/32 up/up N/A N/A
docker0 240.127.1.1/24 up/down N/A N/A
eth0 172.29.151.35/24 up/up N/A N/A
lo 127.0.0.1/8 up/up N/A N/A


Mar 5 16:23:43.887301 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 00:23:43.887169 17 xlate.go:358] Payload
generated:{"INTERFACE":{"INTERFACE_IPADDR_LIST":[{},{"ip_prefix":"10.10.10.100/24","portname":"Ethernet100"},{},{"ip_prefix":"10.10.96.96/24","portname":"Ethernet96"}],"INTERFACE_LIST":[{"portname":"Ethernet100"},{},{"portname":"Ethernet96"},{}]}}
Mar 5 16:23:43.887396 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 00:23:43.887199 17 common_app.go:184] TEST
payload{"INTERFACE":{"INTERFACE_IPADDR_LIST":[{},{"ip_prefix":"10.10.10.100/24","portname":"Ethernet100"},{},{"ip_prefix":"10.10.96.96/24","portname":"Ethernet96"}],"INTERFACE_LIST":[{"portname":"Ethernet100"},{},{"portname":"Ethernet96"},{}]}}
Mar 5 16:23:43.887498 switch12 INFO mgmt-framework#supervisord:
rest-server E0306 00:23:43.887381 17 common_app.go:189]
ocbinds.Unmarshal() failed. error:Portname field doesn't have a valid
value
Mar 5 16:23:43.887611 switch12 INFO mgmt-framework#supervisord:
rest-server E0306 00:23:43.887452 17 handler.go:59] [REST-2]
Translib error *errors.errorString - Portname field doesn't have a
valid value
Mar 5 16:23:43.887752 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 00:23:43.887628 17 handler.go:72] [REST-2]
Sending response 500, type=application/yang-data+json,
data={"ietf-restconf:errors":{"error":[{"error-type":"application","error-tag":"operation-failed"}]}}

Thanks,
Xianlong

Kwangs...@dell.com

unread,
Mar 5, 2020, 9:50:07 PM3/5/20
to rain...@gmail.com, Jeff...@dell.com, sonic-mgmt...@googlegroups.com, Justin...@dell.com
Hi Xianlong,

Yes, it looks like your version has a bug. Can you read the software version?
You can query like below:

curl -X GET "https://172.29.151.35/restconf/data/openconfig-platform:components/component" -H "accept: application/yang-data+json" -k

Thanks.
Kwan

-----Original Message-----
From: sonic-mgmt...@googlegroups.com <sonic-mgmt...@googlegroups.com> On Behalf Of Xianlong Qin
Sent: Thursday, March 5, 2020 4:46 PM
To: Yin, Jeff
Cc: sonic-mgmt...@googlegroups.com; Jose, Justine
Subject: Re: Invalid yang regex?


[EXTERNAL EMAIL]

To view this discussion on the web visit https://groups.google.com/d/msgid/sonic-mgmt-workgroup/CAPGx2p5DJrqLfFFKwC-CDOXfksrS_GRFc96f7SOxDvP%2Bp-JNDA%40mail.gmail.com.

Xianlong Qin

unread,
Mar 6, 2020, 2:14:24 PM3/6/20
to Kwangs...@dell.com, Jeff...@dell.com, sonic-mgmt...@googlegroups.com, Justin...@dell.com
Hi Kwan,

I got an error by running this command:

root@switch12:/home/admin# curl -X GET
{"ietf-restconf:errors":{"error":[{"error-type":"application","error-tag":"invalid-value","error-message":"Information
not available or Not supported"}]}}

My image is based on 201911 branch, last commit is 887ea003 on
02/15/2020. Have already patched below 3 commits and rest-server is
running.

564508 "Removing explicit libyang plugin path settings. Libyang debian
package installs the extensions in standard location."
af4e842 "Start RestAPI container when sonic boots"
398929c "[mgmt-framework] start after syncd"

Syslog:
Mar 6 11:09:43.842847 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842395 17 router.go:122] [REST-7]
Recevied GetListOpenconfigPlatformComponentsComponent request from
172.29.151.35:34378
Mar 6 11:09:43.842847 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842461 17 handler.go:47] [REST-7] GET
/restconf/data/openconfig-platform:components/component; content-len=0
Mar 6 11:09:43.842847 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842470 17 handler.go:92] [REST-7] No
body
Mar 6 11:09:43.842847 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842478 17 handler.go:55] [REST-7]
Translated path = /openconfig-platform:components/component
Mar 6 11:09:43.842847 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842487 17 translib.go:395] Received
Get request for path = /openconfig-platform:components/component
Mar 6 11:09:43.842887 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842495 17 app_interface.go:128]
getAppModule called for path
=/openconfig-platform:components/component
Mar 6 11:09:43.842887 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842502 17 app_interface.go:135] found
the entry in the map for path =/openconfig-platform:components
Mar 6 11:09:43.842972 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842511 17 app_interface.go:166] cast
to appInterface worked&{<nil> [] <nil> <nil>}
Mar 6 11:09:43.842972 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842735 17 pfm_app.go:62]
initialize:if:path =/openconfig-platform:components/component
Mar 6 11:09:43.842972 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842802 17 db.go:324] NewDB: Init
indication not requested
Mar 6 11:09:43.842972 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842824 17 pfm_app.go:115] PlatformApp:
translateGet - path: /openconfig-platform:components/component
Mar 6 11:09:43.842994 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842831 17 pfm_app.go:154] Received GET
for PlatformApp Template: /openconfig-platform:components/component
,path: /openconfig-platform:components/component, vars: map[]
Mar 6 11:09:43.843105 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842872 17 pfm_app.go:347] Preparing
json for system eeprom
Mar 6 11:09:43.843105 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842953 17 pfm_app.go:206]
getSysEepromFromFile Enter
Mar 6 11:09:43.843124 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.842975 17 pfm_app.go:209]
syseeprom.json open failed
Mar 6 11:09:43.843124 switch12 INFO mgmt-framework#supervisord:
rest-server E0306 19:09:43.842985 17 handler.go:59] [REST-7]
Translib error tlerr.NotFoundError - Information not available or Not
supported
Mar 6 11:09:43.843249 switch12 INFO mgmt-framework#supervisord:
rest-server I0306 19:09:43.843033 17 handler.go:72] [REST-7]
Sending response 404, type=application/yang-data+json,
data={"ietf-restconf:errors":{"error":[{"error-type":"application","error-tag":"invalid-value","error-message":"Information
not available or Not supported"}]}}

Thanks,
Xianlong

Jeff...@dell.com

unread,
Mar 6, 2020, 2:20:52 PM3/6/20
to rain...@gmail.com, Kwangs...@dell.com, sonic-mgmt...@googlegroups.com, Justin...@dell.com
Looks like it failed to read the system EEPROM. What kind of device is this? Or is this a VM?

Thanks,
Jeff

-----Original Message-----
From: sonic-mgmt...@googlegroups.com <sonic-mgmt...@googlegroups.com> On Behalf Of Xianlong Qin
Sent: Friday, March 6, 2020 11:14 AM
To: Kim, Kwan
Cc: Yin, Jeff; sonic-mgmt...@googlegroups.com; Jose, Justine
Subject: Re: Invalid yang regex?


[EXTERNAL EMAIL]

> generated:{"INTERFACE":{"INTERFACE_IPADDR_LIST":[{},{"ip_prefix":"10.1
> 0.10.100/24","portname":"Ethernet100"},{},{"ip_prefix":"10.10.96.96/24
> ","portname":"Ethernet96"}],"INTERFACE_LIST":[{"portname":"Ethernet100
> "},{},{"portname":"Ethernet96"},{}]}}
> Mar 5 16:23:43.887396 switch12 INFO mgmt-framework#supervisord:
> rest-server I0306 00:23:43.887199 17 common_app.go:184] TEST
> payload{"INTERFACE":{"INTERFACE_IPADDR_LIST":[{},{"ip_prefix":"10.10.1
To view this discussion on the web visit https://groups.google.com/d/msgid/sonic-mgmt-workgroup/CAPGx2p4nPW_uVGwB2UcHy8fx%3DSAv%2B2Ky%2BsK9Ab2izrMUQ0g3sg%40mail.gmail.com.

Xianlong Qin

unread,
Mar 6, 2020, 2:56:29 PM3/6/20
to Jeff...@dell.com, Kwangs...@dell.com, sonic-mgmt...@googlegroups.com, Justin...@dell.com
Hi Jeff,

It's Cisco hardware device. It's running with SONiC without problems
for other features, do we need to do any special change to enable
mgmt-framework? I assume mgmt-framework is Platform Independent.

Thanks,
Xianlong

Jeff...@dell.com

unread,
Mar 6, 2020, 3:28:29 PM3/6/20
to rain...@gmail.com, Kwangs...@dell.com, sonic-mgmt...@googlegroups.com, Justin...@dell.com
Yes, management framework itself is platform independent. The features exposed by the management framework do need to be supported by that platform though. In this case, this platform feature (openconfig-platform:components/component) is failing because of a failure to read data from the system EEPROM.

> Mar 6 11:09:43.843105 switch12 INFO mgmt-framework#supervisord:
> rest-server I0306 19:09:43.842953 17 pfm_app.go:206]
> getSysEepromFromFile Enter
> Mar 6 11:09:43.843124 switch12 INFO mgmt-framework#supervisord:
> rest-server I0306 19:09:43.842975 17 pfm_app.go:209]
> syseeprom.json open failed

Platform vendors need to implement support for SONiC's way of fetching info from the system EEPROM (ref: sonic-buildimage/src/sonic-utilities/scripts/decode-syseeprom)

On your system, when you execute "show platform syseeprom" from the Bash shell (on the host, not in the container), what's the output?

Anyway, all of the above is just troubleshooting why the GET on openconfig-platform:components/component is failing, not your original problem with GET of all interfaces.

@Kim, Kwan can you recommend an alternative command to get the software version info that you are requesting?

Xianlong Qin

unread,
Mar 6, 2020, 3:43:39 PM3/6/20
to Jeff...@dell.com, Kwangs...@dell.com, sonic-mgmt...@googlegroups.com, Justin...@dell.com
Thanks Jeff. We do have
sonic-buildimage/src/sonic-utilities/scripts/decode-syseeprom
implemented. Any special code need to write for mgmt-framework?

root@switch12:/home/admin# show platform syseeprom
Name Value
-------------------- ---------------
Card Index 21148
Part Number 73-18766-03
Serial Number FDO222306ZN
Product Name N9K-C9336C-FX2
Part Revision A0
MAC Addresses 156
Base MAC Address 50:2f:a8:a7:15:34
Hardware Change Bit 0
Hardware Revision 1.0
(checksum valid)

Thanks,
Xianlong

Kwangs...@dell.com

unread,
Mar 6, 2020, 4:50:47 PM3/6/20
to rain...@gmail.com, Jeff...@dell.com, sonic-mgmt...@googlegroups.com, Justin...@dell.com
Hi Xianlong,

To get the software version, please run "show version" or read /etc/sonic/sonic_version.yml.
> > > > 6.96/24","portname":"Ethernet96"},{},{"ip_prefix":"10.10.10.100/
> > > > 24
> > > > ",
> > > > "p

Xianlong Qin

unread,
Mar 6, 2020, 5:29:22 PM3/6/20
to Kwangs...@dell.com, Jeff...@dell.com, sonic-mgmt...@googlegroups.com, Justin...@dell.com
Hi Kwan,

Below are the version info. It may not so useful as we have some
private patches for the platform, these patches are not meant for
mgmt-framework.

root@switch12:/home/admin# cat /etc/sonic/sonic_version.yml
build_version: 'cisco-201911-feb16.0-dirty-20200303.130452'
debian_version: '9.12'
kernel_version: '4.9.0-9-2-amd64'
asic_type: cisco
commit_id: '79b54117'
github_commit_id: 887ea003
build_date: Tue Mar 3 21:20:24 UTC 2020
build_number: 0
built_by: xianqin@insbu-saidev2

Thanks,
Xianlong

Xianlong Qin

unread,
Mar 11, 2020, 6:07:19 PM3/11/20
to Kwangs...@dell.com, Jeff...@dell.com, sonic-mgmt...@googlegroups.com, Justin...@dell.com
Have anyone seen similar issue?

Thanks,
Xianlong
Reply all
Reply to author
Forward
0 new messages