Skip to content
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

Support proto encoding for DASH_VNET_ROUTE #7

Draft
wants to merge 1 commit into
base: bluefield
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ stages:
- script: |
# PYTEST
sudo pip3 install -U pytest
sudo pip3 install -U protobuf==3.6.1

# REDIS
sudo apt-get install -y redis-server
Expand Down
2 changes: 1 addition & 1 deletion gnmi_server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
)

var (
supportedEncodings = []gnmipb.Encoding{gnmipb.Encoding_JSON, gnmipb.Encoding_JSON_IETF}
supportedEncodings = []gnmipb.Encoding{gnmipb.Encoding_JSON, gnmipb.Encoding_JSON_IETF, gnmipb.Encoding_PROTO}
)

// Server manages a single gNMI Server implementation. Each client that connects
Expand Down
26 changes: 22 additions & 4 deletions patches/gnmi_set.patch
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
- pathValuePair := strings.SplitN(item, ":", 2)
- // TODO (leguo): check if any path attribute contains ':'
+ modName := strings.SplitN(item, "/", 3)
+
+
+ pathValuePair := make([]string, 2)
+ lc := strings.LastIndex(modName[2],":")
+
+
+ if lc == -1 {
+ log.Exitf("invalid path-value pair: %v", item)
+ }
Expand Down Expand Up @@ -61,7 +61,25 @@
jsonFile := pathValuePair[1][1:]
jsonConfig, err := ioutil.ReadFile(jsonFile)
if err != nil {
@@ -144,8 +168,10 @@
@@ -81,6 +105,17 @@
JsonIetfVal: jsonConfig,
},
}
+ } else if pathValuePair[1][0] == '$' {
+ protoFile := pathValuePair[1][1:]
+ protoConfig, err := ioutil.ReadFile(protoFile)
+ if err != nil {
+ log.Exitf("cannot read data from file %v", protoFile)
+ }
+ pbVal = &pb.TypedValue{
+ Value: &pb.TypedValue_ProtoBytes{
+ ProtoBytes: protoConfig,
+ },
+ }
} else {
if strVal, err := strconv.Unquote(pathValuePair[1]); err == nil {
pbVal = &pb.TypedValue{
@@ -144,8 +179,10 @@
}
replaceList := buildPbUpdateList(replaceOpt)
updateList := buildPbUpdateList(updateOpt)
Expand All @@ -73,7 +91,7 @@
Delete: deleteList,
Replace: replaceList,
Update: updateList,
@@ -155,11 +181,17 @@
@@ -155,11 +192,17 @@
utils.PrintProto(setRequest)

cli := pb.NewGNMIClient(conn)
Expand Down
209 changes: 209 additions & 0 deletions proto/dash.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions proto/dash.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// dash.proto describes the message format for DASH table.
syntax = "proto3";

package gnmi.sonic;

message DashRoute {
string eni = 1;
string prefix = 2;
string ip_version = 3;
string routing_type = 4;
string vnet = 5;
string customer_addr = 6;
string appliance = 7;
string underlay_ip = 8;
string overlay_sip = 9;
string overlay_dip = 10;
string metering_bucket = 11;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this put a dependency on schema changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right.
This PR is a POC, if we want to support protobuf encoding with sonic db schema, then we have to manually create proto definition.
And we can support protobuf encoding with sonic yang schema in the future, because ygot can translate yang models to proto format.

}

message DashRouteTable {
repeated DashRoute routes = 1;
}
Loading