Skip to content
This repository was archived by the owner on Oct 28, 2022. It is now read-only.

Issue with JSON formatting when Requested-path ! = Response-prefix #598

@yashikakn

Description

@yashikakn

When trying to retrieve ip-addresses data using GNMI subscribe request, I see the ip addresses data is received from the DUT (please refer to attached file <json.encoding.raw>) but looks like the tool has some issue with JSON formatting when Requested-path ! = Response-prefix.
(file <json.encoding.formatted>)

Here, requested path is :/interfaces/interface[name=lo0]/subinterfaces/subinterface[index=0]/

Same works with –encoding proto. Please refer to attached files < proto.encoding.raw, proto.encoding.formatted>

Sample outputs:

  1. With encoding 'json'
    gnmic -a 10.92.196.149:50051 sub --path "/interfaces/interface[name="lo0"]/subinterfaces/subinterface[index=0]" -u root -p Embe1mpls --insecure --encoding json --mode once{
    "source": "10.92.196.149:50051",
    "subscription-name": "default-1652375785",
    "timestamp": 1652375789566454228,
    "time": "2022-05-12T10:16:29.566454228-07:00",
    "prefix": "interfaces/interface[name=lo0]/subinterfaces/subinterface[index=0]",
    "updates": [
    {
    "Path": "state/index",
    "values": {
    "state/index": 0
    }
    },
    {
    "Path": "state/description",
    "values": {
    "state/description": ""
    }
    },
    {
    "Path": "state/enabled",
    "values": {
    "state/enabled": 1
    }
    },
    {
    "Path": "state/name",
    "values": {
    "state/name": "lo0.0"
    }
    },
    {
    "Path": "state/ifindex",
    "values": {
    "state/ifindex": 16
    }
    },
    {
    "Path": "state/admin-status",
    "values": {
    "state/admin-status": "UP"
    }
    },
    {
    "Path": "state/oper-status",
    "values": {
    "state/oper-status": "UP"
    }
    },
    {
    "Path": "state/last-change",
    "values": {
    "state/last-change": 0
    }
    },
    {
    "Path": "state/logical",
    "values": {
    "state/logical": 1
    }
    }
    ]
    }
    {
    "source": "10.92.196.149:50051",
    "subscription-name": "default-1652375785",
    "timestamp": 1652375789570389796,
    "time": "2022-05-12T10:16:29.570389796-07:00",
    "prefix": "interfaces/interface[name=lo0]/subinterfaces/subinterface[index=0]",
    "updates": [
    {
    "Path": "ipv4/state/enabled",
    "values": {
    "ipv4/state/enabled": 1
    }
    },
    {
    "Path": "ipv4/state/mtu",
    "values": {
    "ipv4/state/mtu": 65535
    }
    }
    ]
    }
    {
    "source": "10.92.196.149:50051",
    "subscription-name": "default-1652375785",
    "timestamp": 1652375789572884485,
    "time": "2022-05-12T10:16:29.572884485-07:00",
    "prefix": "interfaces/interface[name=lo0]/subinterfaces/subinterface[index=0]",
    "updates": [
    {
    "Path": "ipv6/state/enabled",
    "values": {
    "ipv6/state/enabled": 1
    }
    },
    {
    "Path": "ipv6/state/mtu",
    "values": {
    "ipv6/state/mtu": 4294967295
    }
    }
    ]
    }

  2. With encoding 'proto':
    gnmic -a 10.92.196.149:50051 sub --path "/interfaces/interface[name="lo0"]/subinterfaces/subinterface[index=0]" -u root -p Embe1mpls --insecure --encoding proto --mode once
    {
    "source": "10.92.196.149:50051",
    "subscription-name": "default-1652375806",
    "timestamp": 1652375809449870735,
    "time": "2022-05-12T10:16:49.449870735-07:00",
    "prefix": "interfaces/interface[name=lo0]/subinterfaces/subinterface[index=0]",
    "updates": [
    {
    "Path": "state/index",
    "values": {
    "state/index": 0
    }
    },
    {
    "Path": "state/description",
    "values": {
    "state/description": ""
    }
    },
    {
    "Path": "state/enabled",
    "values": {
    "state/enabled": true
    }
    },
    {
    "Path": "state/name",
    "values": {
    "state/name": "lo0.0"
    }
    },
    {
    "Path": "state/ifindex",
    "values": {
    "state/ifindex": 16
    }
    },
    {
    "Path": "state/admin-status",
    "values": {
    "state/admin-status": "UP"
    }
    },
    {
    "Path": "state/oper-status",
    "values": {
    "state/oper-status": "UP"
    }
    },
    {
    "Path": "state/last-change",
    "values": {
    "state/last-change": 0
    }
    },
    {
    "Path": "state/logical",
    "values": {
    "state/logical": true
    }
    }
    ]
    }
    {
    "source": "10.92.196.149:50051",
    "subscription-name": "default-1652375806",
    "timestamp": 1652375809450004641,
    "time": "2022-05-12T10:16:49.450004641-07:00",
    "prefix": "interfaces/interface[name=lo0]/subinterfaces/subinterface[index=0]/ipv4/addresses/address[ip=10.255.2.76]",
    "updates": [
    {
    "Path": "state/ip",
    "values": {
    "state/ip": "10.255.2.76"
    }
    },
    {
    "Path": "state/prefix-length",
    "values": {
    "state/prefix-length": 32
    }
    },
    {
    "Path": "state/origin",
    "values": {
    "state/origin": "STATIC"
    }
    }
    ]
    }
    {
    "source": "10.92.196.149:50051",
    "subscription-name": "default-1652375806",
    "timestamp": 1652375809450139391,
    "time": "2022-05-12T10:16:49.450139391-07:00",
    "prefix": "interfaces/interface[name=lo0]/subinterfaces/subinterface[index=0]/ipv4/addresses/address[ip=127.0.0.1]",
    "updates": [
    {
    "Path": "state/ip",
    "values": {
    "state/ip": "127.0.0.1"
    }
    },
    {
    "Path": "state/prefix-length",
    "values": {
    "state/prefix-length": 32
    }
    },
    {
    "Path": "state/origin",
    "values": {
    "state/origin": "STATIC"
    }
    }
    ]
    }
    {
    "source": "10.92.196.149:50051",
    "subscription-name": "default-1652375806",
    "timestamp": 1652375809450262600,
    "time": "2022-05-12T10:16:49.4502626-07:00",
    "prefix": "interfaces/interface[name=lo0]/subinterfaces/subinterface[index=0]/ipv4/addresses/address[ip=127.0.0.64]",
    "updates": [
    {
    "Path": "state/ip",
    "values": {
    "state/ip": "127.0.0.64"
    }
    },
    {
    "Path": "state/prefix-length",
    "values": {
    "state/prefix-length": 32
    }
    },
    {
    "Path": "state/origin",
    "values": {
    "state/origin": "STATIC"
    }
    }
    ]
    }
    {
    "source": "10.92.196.149:50051",
    "subscription-name": "default-1652375806",
    "timestamp": 1652375809452684011,
    "time": "2022-05-12T10:16:49.452684011-07:00",
    "prefix": "interfaces/interface[name=lo0]/subinterfaces/subinterface[index=0]",
    "updates": [
    {
    "Path": "ipv4/state/enabled",
    "values": {
    "ipv4/state/enabled": true
    }
    },
    {
    "Path": "ipv4/state/mtu",
    "values": {
    "ipv4/state/mtu": 65535
    }
    }
    ]
    }
    {
    "source": "10.92.196.149:50051",
    "subscription-name": "default-1652375806",
    "timestamp": 1652375809452796022,
    "time": "2022-05-12T10:16:49.452796022-07:00",
    "prefix": "interfaces/interface[name=lo0]/subinterfaces/subinterface[index=0]/ipv6/addresses/address[ip=abcd::10:255:2:76]",
    "updates": [
    {
    "Path": "state/ip",
    "values": {
    "state/ip": "abcd::10:255:2:76"
    }
    },
    {
    "Path": "state/prefix-length",
    "values": {
    "state/prefix-length": 128
    }
    },
    {
    "Path": "state/origin",
    "values": {
    "state/origin": "STATIC"
    }
    },
    {
    "Path": "state/status",
    "values": {
    "state/status": "PREFERRED"
    }
    }
    ]
    }
    {
    "source": "10.92.196.149:50051",
    "subscription-name": "default-1652375806",
    "timestamp": 1652375809452936008,
    "time": "2022-05-12T10:16:49.452936008-07:00",
    "prefix": "interfaces/interface[name=lo0]/subinterfaces/subinterface[index=0]/ipv6/addresses/address[ip=fe80::2c5:2cf0:3:f03d]",
    "updates": [
    {
    "Path": "state/ip",
    "values": {
    "state/ip": "fe80::2c5:2cf0:3:f03d"
    }
    },
    {
    "Path": "state/prefix-length",
    "values": {
    "state/prefix-length": 128
    }
    },
    {
    "Path": "state/origin",
    "values": {
    "state/origin": "RANDOM"
    }
    },
    {
    "Path": "state/status",
    "values": {
    "state/status": "PREFERRED"
    }
    }
    ]
    }
    {
    "source": "10.92.196.149:50051",
    "subscription-name": "default-1652375806",
    "timestamp": 1652375809455088976,
    "time": "2022-05-12T10:16:49.455088976-07:00",
    "prefix": "interfaces/interface[name=lo0]/subinterfaces/subinterface[index=0]",
    "updates": [
    {
    "Path": "ipv6/state/enabled",
    "values": {
    "ipv6/state/enabled": true
    }
    },
    {
    "Path": "ipv6/state/mtu",
    "values": {
    "ipv6/state/mtu": 4294967295
    }
    }
    ]
    }

json.encoding.raw.txt
json.encoding.formatted.txt
proto.encoding.formatted.txt
proto.encoding.raw.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions