Coder Social home page Coder Social logo

Comments (4)

aashaikh avatar aashaikh commented on August 17, 2024

Please see the explanation in the gNMI spec: https://github.com/openconfig/reference/blob/master/rpc/gnmi/gnmi-specification.md#222-paths

The key map is used to express a path element that requires one or more index values, such as a list in YANG:
/interfaces/interface[name=eth0]/state/oper-status

The second path element requires use of the key. There are examples of the encoding at the link above.

from gnmi.

dingrui37 avatar dingrui37 commented on August 17, 2024

Thank you for your reply . I think what you mean is like below, is it right?
For example, "/interfaces/interface[name=eth0]"

string name = 1;             -----------> name = "/interfaces/interface"
map<string, string> key = 2; ----------->  key = "name", value  = "eth0"

Why not use the full xpath string directly, just like "/interfaces/interface[name=eth0]"? I want to ask another question. If the path is "/interfaces/interface[name=eth0]/state/oper-status", the name field is
"/interfaces/interface/state/oper-status" or "/interfaces/interface[name=eth0]/state/oper-status"? and the key is null?

from gnmi.

robshakir avatar robshakir commented on August 17, 2024

We've iterated on the path specification a number of times -- the motivation for this format is that it is significantly simpler to work with than having string parsing throughout the code. The full proposal and discussion that Marcus, Carl, Anees and I put together is in this issue. You can see the discussion there.

The name field is a repeated -- so your example isn't correct, again please see the examples. This would be encoded using multiple PathElem messages, i.e.:

elem: <
  name: "interfaces"
>
elem: <
  name: "interface"
  key: <
    key: "name"
    value: "eth0"
  >
>

The second example just appends more elem entries onto the end of the repeated:

elem: <
  name: "interfaces"
>
elem: <
  name: "interface"
  key: <
    key: "name"
    value: "eth0"
  >
>
elem: <
 name: "state"
>
elem: <
  name: "oper-status"
>

(Using standard Go textproto encoding format)

In the case that there are no keys (i.e., an element is not a YANG list, if using YANG) then the key map is null.

from gnmi.

dingrui37 avatar dingrui37 commented on August 17, 2024

Thanks @robshakir. I overlooked that the name field is a repeated, I think I have already understood.

from gnmi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.