openconfig / gnmic

gNMIc is a gNMI CLI client and collector
https://gnmic.openconfig.net
Apache License 2.0
186 stars 57 forks source link

The output of set-request command is missing objects. #453

Closed martimy closed 3 months ago

martimy commented 5 months ago

I am using gNMIc version 0.37.0 with Nokia srlinux 23.10.0. It seems there is an issue with the IPv4/IPv6 address objects not being populated in the generated output of the following 'set-request' command.

Am I missing something?

$ gnmic generate \
--dir srlinux-yang-models \
--file srlinux-yang-models/srl_nokia/models/interfaces/srl_nokia-interfaces.yang \
set-request \
--update interface/subinterface
updates:
- path: interface/subinterface
  value:
  - anycast-gw:
      anycast-gw-mac: []
      virtual-router-id:
      - "1"
    bridge-table:
      discard-unknown-src-mac:
      - "false"
      mac-duplication:
        action:
        - use-net-instance-action
      mac-learning:
        admin-state:
        - enable
        aging:
          admin-state:
          - enable
      mac-limit:
        maximum-entries:
        - "250"
        warning-threshold-pct:
        - "95"
    ipv4:
      address:
      - {}
      admin-state:
      - disable
      allow-directed-broadcast:
      - "false"
      unnumbered:
        admin-state:
        - disable
        interface: []
    ipv6:
      address:
      - {}
      admin-state:
      - disable
  encoding: JSON_IETF

Same here:

$ gnmic generate \
--dir srlinux-yang-models/ \
--file srlinux-yang-models/srl_nokia/models/interfaces/srl_nokia-interfaces.yang \
set-request \
--update interface/subinterface/ipv4
updates:
- path: interface/subinterface/ipv4
  value:
    address:
    - {}
    admin-state:
    - disable
    allow-directed-broadcast:
    - "false"
    unnumbered:
      admin-state:
      - disable
      interface: []
  encoding: JSON_IETF

Here is the partial output of pyang for the YANG model:

$ pyang -f tree -p srlinux-yang-models srlinux-yang-models/srl_nokia/models/interfaces/srl_nokia-interfaces.yang  | awk /--rw/

...
     |  +--rw synce! {srl_nokia-feat:sync}?
     |  |  +--rw ssm
     |  |     +--rw admin-state?   srl_nokia-comm:admin-state
     +--rw subinterface* [index]
     |  +--rw index               uint32
     |  +--rw type?               identityref
     |  +--rw description?        srl_nokia-comm:description
     |  +--rw admin-state?        srl_nokia-comm:admin-state
     |  +--rw ip-mtu?             uint16
     |  +--rw l2-mtu?             uint16 {srl_nokia-feat:bridged}?
     |  +--rw mpls-mtu?           uint16 {srl_nokia-feat:mpls}?
     |  +--rw ipv4
     |  |  +--rw admin-state?                srl_nokia-comm:admin-state
     |  |  +--rw address* [ip-prefix]
     |  |  |  +--rw ip-prefix     srl_nokia-comm:ipv4-prefix-with-host-bits
     |  |  |  +--rw anycast-gw?   boolean {srl_feat:anycast-gw}?
     |  |  |  +--rw primary?      empty
     |  |  +--rw allow-directed-broadcast?   boolean
     |  |  +--rw unnumbered {srl_feat:ipv4-unnumbered}?
     |  |  |  +--rw admin-state?                  srl_nokia-comm:admin-state
     |  |  |  +--rw interface?                    srl_nokia-comm:subinterface-all
     |  +--rw ipv6
     |  |  +--rw admin-state?   srl_nokia-comm:admin-state
     |  |  +--rw address* [ip-prefix]
...
karimra commented 4 months ago

Yes, that's a bug coming from poor handling of leaf vs leaf-list, should be fixed in #475

karimra commented 4 months ago

Could you give v0.38.0 a try?

martimy commented 4 months ago

It seems to be working. Thanks :-)

$ gnmic version
version : 0.38.0
 commit : 01ca8fa7
   date : 2024-07-11T06:10:14Z
 gitURL : https://github.com/openconfig/gnmic
   docs : https://gnmic.openconfig.net
$ gnmic generate \
> --dir srlinux-yang-models \
> --file srlinux-yang-models/srl_nokia/models/interfaces/srl_nokia-interfaces.yang \
> set-request \
> --update interface/subinterface
updates:
- path: interface/subinterface
  value:
  - admin-state: enable
    anycast-gw:
      anycast-gw-mac: ""
      virtual-router-id: "1"
    bridge-table:
      discard-unknown-src-mac: "false"
      mac-duplication:
        action: use-net-instance-action
      mac-learning:
        admin-state: enable
        aging:
          admin-state: enable
      mac-limit:
        maximum-entries: "250"
        warning-threshold-pct: "95"
    description: ""
    index: ""
    ip-mtu: ""
    ipv4:
      address:
      - anycast-gw: ""
        ip-prefix: ""
        primary: ""
      admin-state: disable
      allow-directed-broadcast: "false"
      unnumbered:
        admin-state: disable
        interface: ""
    ipv6:
      address:
      - anycast-gw: ""
        ip-prefix: ""
        primary: ""
        type: global-unicast
      admin-state: disable
    l2-mtu: ""
    mpls-mtu: ""
    type: ""
  encoding: JSON_IETF
$ gnmic generate \
> --dir srlinux-yang-models/ \
> --file srlinux-yang-models/srl_nokia/models/interfaces/srl_nokia-interfaces.yang \
> set-request \
> --update interface/subinterface/ipv4
updates:
- path: interface/subinterface/ipv4
  value:
    address:
    - anycast-gw: ""
      ip-prefix: ""
      primary: ""
    admin-state: disable
    allow-directed-broadcast: "false"
    unnumbered:
      admin-state: disable
      interface: ""
  encoding: JSON_IETF