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 gNMI Capabilities/Get RPCs #3

Merged
merged 1 commit into from
Nov 5, 2018

Conversation

tanakatakafumi
Copy link
Contributor

This adds support for "Capabilities" and "Get" RPCs of gNMI.
Other RPCs ("Set" and "Subscribe") are not supported yet.

Usage example (Note: gRPC authentication is disabled)

  • server (from container)
$ docker run -it --rm -v /etc/oopt:/etc/oopt -p 10164:10164 oopt go run /go/src/github.com/osrg/oopt/gnmi/sample_server/run.go
  • client (Capabilities)
$ go run $GOPATH/src/github.com/osrg/oopt/gnmi/sample_client/gnmi_capabilities.go -target_addr localhost:10164

output

== capabilitiesResponse:
supported_models: <
  name: "packet-transport"
  organization: "Nippon Telegraph and Telephone Corporation"
  version: "0.7.0"
>
supported_encodings: JSON
supported_encodings: JSON_IETF
gNMI_version: "0.7.0"
  • client (Get)
$ go run $GOPATH/src/github.com/osrg/oopt/gnmi/sample_client/gnmi_get.go -target_addr localhost:10164 -xpath /packet-transponder/optical-modules/optical-module[name=Opt6]

output

== getRequest:
encoding: JSON_IETF

== getResponse:




== getRequest:
path: <
  elem: <
    name: "packet-transponder"
  >
  elem: <
    name: "optical-modules"
  >
  elem: <
    name: "optical-module"
    key: <
      key: "name"
      value: "Opt6"
    >
  >
>
encoding: JSON_IETF

== getResponse:
notification: <
  timestamp: 1540280436450145547
  update: <
    path: <
      elem: <
        name: "packet-transponder"
      >
      elem: <
        name: "optical-modules"
      >
      elem: <
        name: "optical-module"
        key: <
          key: "name"
          value: "Opt6"
        >
      >
    >
    val: <
      json_ietf_val: "{\"packet-transport:config\":{\"losi\":true,\"modulation-type\":\"DP_QPSK\",\"name\":\"Opt6\",\"prbs\":true},\"packet-transport:name\":\"Opt6\",\"packet-transport:optical-module-frequency\":{\"config\":{\"channel\":12,\"grid\":\"GRID_50GHZ\"}}}"
    >
  >
>

@ishidawataru
Copy link
Member

ishidawataru commented Oct 26, 2018

@tanakatakafumi Thanks for your contribution! This project tries to use the golang standard project layout.

https://github.com/golang-standards/project-layout

Please put gnmi/model.go and gnmi/server.go under /pkg directory.
Also put gnmi/sample_client and gnmi/sample_server under /cmd directory.
Two client applications (get and capability) should be put into different directories otherwise we can't make go build work.

Next, please update vendor directory by using dep.

https://golang.github.io/dep/docs/daily-dep.html

You can just run dep ensure and update every dependencies.

In general, please try to make the git history as simple as possilbe for the branch for PR.
Before opening a PR, rebase your branch onto the current master to avoid having a commit for comflict fix.
Also, you don't need to include commits which fix problems introduced by a commit which also exists in this PR. You can simply squash/ammend these fix commits to the original commits.

https://github.com/mockito/mockito/wiki/Using-git-to-prepare-your-PR-to-have-a-clean-history

@tanakatakafumi
Copy link
Contributor Author

Thank you for your kind instruction! I relocated gNMI files, updated vendor directory by running dep ensure, and simplified commits.

pkg/gnmi/server.go Outdated Show resolved Hide resolved
pkg/gnmi/server.go Outdated Show resolved Hide resolved
@ishidawataru
Copy link
Member

@tanakatakafumi thanks, added review comments. please reflect.
In a typical open source workflow, you add a new commit to your branch ( in this case tanakatakafumi/oopt ) to reflect review comments.
After you get LGTM, maintainers may ask you to squash these commits into original commit.
Then maintainers can merge it into the master branch.

@tanakatakafumi
Copy link
Contributor Author

@ishidawataru thanks, I reflected your comments.

@ishidawataru
Copy link
Member

@tanakatakafumi LGTM, please squash the fix commit into the first commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants