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

Getting subtree encoded as JSON in one update message #20

Closed
CoCumis opened this issue Jul 2, 2018 · 5 comments · Fixed by #28
Closed

Getting subtree encoded as JSON in one update message #20

CoCumis opened this issue Jul 2, 2018 · 5 comments · Fixed by #28
Assignees
Labels

Comments

@CoCumis
Copy link

CoCumis commented Jul 2, 2018

Hi guys, I have question regarding encoding of data. According to gNMI specification, section 2.3.1, I assumed, that when I will send get request to target, with a path which does not point to leaf node, then in response message will be one notification with one update message which value will be JSON encoded subtree located under this path.

But instead in response message I receive notification message with separate update message for each leaf node in that subtree. My question is, if I am missing something from official gNMI specification, or I had to setup gnxi target in some special way in order to receive whole subtree as JSON encoded value of one update message.

@CoCumis CoCumis changed the title Question about JSON encoding Getting subtree encoded as JSON in one update message Jul 2, 2018
@samribeiro
Copy link
Member

Hi CoCumis, you should get an encoded subtree as per gNMI spec:
https://github.com/google/gnxi/blob/master/gnmi/server.go#L530

which client and target are you using? Can you provide examples of the get and the response?

@CoCumis
Copy link
Author

CoCumis commented Jul 4, 2018

Thanks for response.

I am using docker image provided by faucet which you are mentioning in your README. For get request I use script provided in this docker image. Here is example:

#!/bin/sh
gnmi_get \
  -target_addr $GNMI_TARGET:$GNMI_PORT \
  -key $HOME/certs/client.key \
  -cert $HOME/certs/client.crt \
  -ca $HOME/certs/ca.crt \
  -target_name server.com \
  -alsologtostderr \
  -xpath "/system/openflow/controllers/controller[name=main]/"

I would expect it will send response with one update message which contains JSON encoded subtree. But instead I get this (just excerpt):

notification: <                                                                                                                                                
  timestamp: 1530705017155554011                                                                                                                               
  prefix: <                                                                                                                                                    
    elem: <                                                                                                                                                    
      name: "system"                                                                                                                                           
    >                                                                                                                                                          
    elem: <                                                                                                                                                    
      name: "openflow"                                                                                                                                         
    >                                                                                                                                                          
    elem: <                                                                                                                                                    
      name: "controllers"                                                                                                                                      
    >                                                                                                                                                          
    elem: <                                                                                                                                                    
      name: "controller"                                                                                                                                       
      key: <                                                                                                                                                   
        key: "name"                                                                                                                                            
        value: "main"                                                                                                                                          
      >                                                                                                                                                        
    >                                                                                                                                                          
  >                                                                                                                                                            
  update: <                                                                                                                                                    
    path: <                                                                                                                                                    
      elem: <                                                                                                                                                  
        name: "connections"                                                                                                                                    
      >                                                                                                                                                        
      elem: <                                                                                                                                                  
        name: "connection"                                                                                                                                     
        key: <
          key: "aux-id"
          value: "0"
        >
      >
      elem: <
        name: "config"
      >
      elem: <
        name: "transport"
      >
    >
    val: <
      string_val: "TLS"
    >
  >
  update: <
    path: <
      elem: <
        name: "connections"
      >
      elem: <
        name: "connection"
        key: <
          key: "aux-id"
          value: "0"
        >
      >
      elem: <
        name: "state"
      >
      elem: <
        name: "address"
      >
    >
    val: <
      string_val: "192.0.2.10"
    >
  >
  update: <
    path: <
      elem: <
        name: "connections"
      >
      elem: <
        name: "connection"
        key: <
          key: "aux-id"
          value: "0"
        >
      >
      elem: <
        name: "state"
      >
      elem: <
        name: "aux-id"
      >
    >
    val: <
      uint_val: 0
    >
  >
...                                                                                                                                                                                                                                             

I also get the same result, if I try it with java client (generated from gnmi.proto). Is there something I had to configure in order to get whole subtree encoded as JSON instead of separate update message for each leaf?

@samribeiro
Copy link
Member

Should be fixed now. Please reopen if something is amiss.

@Pyro2266
Copy link

Hi, bugfix you provided fixes this problem only when the encoding is set to IETF_JSON (as title says). However I encountered this problem again when the encoding is set to JSON, which is the default one (is used when no encoding is specified).

Please, can you reopen this issue?

@samribeiro samribeiro reopened this Jul 19, 2018
@samribeiro
Copy link
Member

Thanks I have a potential fix here: https://github.com/samribeiro/gnxi/tree/gnmi
But I need to test it first.

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

Successfully merging a pull request may close this issue.

3 participants