Skip to content

Commit 79c5504

Browse files
mhines01Raj998
authored andcommitted
squash! Update system set package to use streaming rpc Update build files Update gnoi.Path to compliant with gnmi.Path Update simple test to use new path
1 parent 47d2738 commit 79c5504

File tree

6 files changed

+45
-29
lines changed

6 files changed

+45
-29
lines changed

file/BUILD.bazel

+6
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@ load("@io_bazel_rules_go//proto:go_proto_library.bzl", "go_proto_library")
33
proto_library(
44
name = "file_proto",
55
srcs = ["file.proto"],
6+
deps = [
7+
"//github.com/openconfig/reference/rpc/gnoi:go_default_library"
8+
],
69
)
710

811
go_proto_library(
912
name = "go_default_library",
1013
srcs = ["file.proto"],
14+
deps = [
15+
"//github.com/openconfig/reference/rpc/gnoi:go_default_library"
16+
],
1117
visibility = ["//visibility:public"],
1218
rules_go_repo_only_for_internal_use = "@",
1319
has_services = 1,

file/file.proto

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ syntax = "proto3";
1818

1919
package gnoi.file;
2020

21+
import "github.com/openconfig/reference/rpc/gnoi/types.proto";
22+
2123
service File {
2224
// Get read and streams the contents of a file from the target.
2325
// The file is streamed by sequential messages, each containing up to
@@ -73,7 +75,7 @@ message PutRequest {
7375
oneof request {
7476
Details open = 1;
7577
bytes contents = 2;
76-
bytes checksum = 3; // MD5 checksum of the file.
78+
gnoi.HashType hash = 3; // MD5 checksum of the file.
7779
}
7880
}
7981

system/system.proto

+11-5
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ service System {
4747

4848
// SetPackage places a software package (possibly including bootable images)
4949
// on the target.
50-
rpc SetPackage(SetPackageRequest) returns (SetPackageResponse) {}
50+
rpc SetPackage(stream SetPackageRequest) returns (SetPackageResponse) {}
5151

5252
// SwitchControlProcessor will switch from the current route processor to the
5353
// provided route processor. If the current route processor is the same as the
@@ -272,17 +272,23 @@ message TracerouteResponse {
272272
// Package defines a single package file to be placed on the target.
273273
message Package {
274274
string filename = 1; // Destination path and filename of the package.
275-
bytes data = 2; // Contents of the package.
276-
gnoi.HashType hash = 3; // Verification hash of data.
277275
string version = 4; // Version of the package. (vendor internal name)
278276
bool activate = 5; // For system packages this will take effect after reboot.
279277
}
280278

281279
// SetPackageRequest will place the package onto the target and optionally mark
282-
// it as the next bootable image.
280+
// it as the next bootable image. The initial message must be a package
281+
// message containing the filename and information about the file.
282+
// The final message must be a hash message contains the hash of the file
283+
// contents.
283284
message SetPackageRequest {
284-
repeated Package packages = 1;
285+
oneof request {
286+
Package package = 1;
287+
bytes contents = 2;
288+
gnoi.HashType hash = 3; // Verification hash of data.
289+
}
285290
}
286291

292+
287293
message SetPackageResponse {
288294
}

test/BUILD

-18
This file was deleted.

test/simple_test.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,17 @@ func TestGNOI(t *testing.T) {
1515
in proto.Message
1616
want string
1717
}{{
18-
desc: "gnoi",
18+
desc: "gnoi.Path",
1919
in: &gnoi.Path{
20-
Elements: []string{"foo", "path"},
20+
Origin: "oc",
21+
Elem: []*gnoi.PathElem{{name: "interfaces", key: map[string]string{"name": "Ethernet1/1/0"}}},
22+
},
23+
want: "elements: \"foo\"\nelements: \"path\"\n",
24+
}, {
25+
desc: "gnoi.HashType",
26+
in: &gnoi.HashType{
27+
Method: gnoi.HashMethod_MD5,
28+
Hash: []byte("foo"),
2129
},
2230
want: "elements: \"foo\"\nelements: \"path\"\n",
2331
}, {

types.proto

+15-3
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,25 @@ message HashType {
3232
UNSPECIFIED = 0;
3333
SHA256 = 1;
3434
SHA512 = 2;
35+
MD5 = 3;
3536
}
3637
HashMethod method = 1;
3738
bytes hash = 2;
3839
}
3940

40-
// OpenConfig path representation of the target.
41-
// eg. /interfaces/interface[name=et-1/0/0]
41+
// Path encodes a data tree path as a series of repeated strings, with
42+
// each element of the path representing a data tree node name and the
43+
// associated attributes.
44+
// Reference: gNMI Specification Section 2.2.2.
4245
message Path {
43-
repeated string elements = 1;
46+
string origin = 2; // Label to disambiguate path.
47+
repeated PathElem elem = 3; // Elements of the path.
48+
}
49+
50+
// PathElem encodes an element of a gNMI path, along with any attributes (keys)
51+
// that may be associated with it.
52+
// Reference: gNMI Specification Section 2.2.2.
53+
message PathElem {
54+
string name = 1; // The name of the element in the path.
55+
map<string, string> key = 2; // Map of key (attribute) name to value.
4456
}

0 commit comments

Comments
 (0)