onosproject / onos-config

Configuration subsystem for ONOS (µONOS Architecture)
45 stars 57 forks source link

gNMI southbound should send attribute values in the format defined in the model (not just string) #303

Closed SeanCondon closed 5 years ago

SeanCondon commented 5 years ago

To date when setting attributes on the gNMI southbound we have always used the string_val type assuming the target device will know how to cast it in to the right data type.

In the case of DeviceSim this is not the case. e.g. setting the value of enabled with:

gnmi_cli -address localhost:5150 -set     -proto "update: <path: <target: 'localhost:10161', elem: <name: 'interfaces'> elem:<name:'interface' key: <key: 'name' value: 'eth1'>> elem: <name: 'config'> elem: <name: 'enabled'>> val: <bool_val: false>>"     -timeout 5s -alsologtostderr     -client_crt pkg/southbound/testdata/client1.crt     -client_key pkg/southbound/testdata/client1.key     -ca_crt pkg/southbound/testdata/onfca.crt

gives

2019/06/05 13:11:49 SetResponse  target returned RPC error for Set("update:<path:<elem:<name:\"interfaces\" > elem:<name:\"interface\" key:<key:\"name\" value:\"eth1\" > > elem:<name:\"config\" > elem:<name:\"enabled\" > > val:<string_val:\"false\" > > ") : rpc error: code = Internal desc = error in creating config struct from IETF JSON data: got string type for field enabled, expect bool
SeanCondon commented 5 years ago

There are 2 options for solving this:

  1. Keep the type of attribute with the value when we store it. This has the disadvantage that the user would have to know the data type to use when setting a value. Also there is a risk the user could specify a different type each time.
  2. Allow the integration with YGOT to look up the type from the model and assign the correct type. This would have to happen for configs sent southbound and for GetResponses northbound
Andrea-Campanella commented 5 years ago

in option 1 you can use ygot at the time the user asks for storing something, in case 2 you are using it when it's stored to a device.

SeanCondon commented 5 years ago

Closed by #491