Skip to content

Conversation

earies
Copy link
Contributor

@earies earies commented Oct 18, 2025

Handle leading slash for flat format when origin is not included in prefix or
prefix is non-existant

Prior behavior:

$ gnmic -a r1:32767 -u user -p pass --insecure subscribe -e proto --format flat --mode once --stream-mode sample --path openconfig:/system/state
openconfig:/system/state/boot-time: 1760805556938250028
openconfig:/system/state/current-datetime: 2025-10-18T19:04:40Z
openconfig:/system/state/domain-name:
openconfig:/system/state/hostname: r1
openconfig:/system/state/software-version: 26.1I20251016234041-_cd-builder-1
openconfig:/system/state/up-time: 8719716420835

openconfig:system/state/login-banner:

openconfig:system/state/motd-banner: --- JUNOS 26.1I20251016234041-_cd-builder-1 Linux (none) 5.15.164-10.22.33.18-yocto-standard-juniper-17166-g088c19cd4948 #1 SMP PREEMPT Mon Oct 6 04:26:49 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

openconfig:system/state/last-configuration-timestamp: 1760805868949826900

When a prefix is included in the Notification, a leading slash is emitted

update:  {
  timestamp:  1760812704326423058
  prefix:  {
    origin:  "openconfig"
  }
  update:  {
    path:  {
      elem:  {
        name:  "system"
      }
      elem:  {
        name:  "state"
      }
      elem:  {
        name:  "hostname"
      }
    }
    val:  {
      string_val:  "r1"
    }
  }
  ...

However, when the Notification does not include a prefix and/or the origin is
excluded from the prefix Path, a leading slash is omitted

update:  {
  timestamp:  1760812704788924249
  update:  {
    path:  {
      origin:  "openconfig"
      elem:  {
        name:  "system"
      }
      elem:  {
        name:  "state"
      }
      elem:  {
        name:  "login-banner"
      }
    }
    val:  {
      string_val:  ""
    }
  }
}

Behavior post fix:

$ ./gnmic -a r1:32767 -u user -p pass --insecure subscribe -e proto --format flat --mode once --stream-mode sample --path openconfig:/system/state
openconfig:/system/state/boot-time: 1760805556938250028
openconfig:/system/state/current-datetime: 2025-10-18T19:16:34Z
openconfig:/system/state/domain-name:
openconfig:/system/state/hostname: r1
openconfig:/system/state/software-version: 26.1I20251016234041-_cd-builder-1
openconfig:/system/state/up-time: 9429717100519

openconfig:/system/state/login-banner:

openconfig:/system/state/motd-banner: --- JUNOS 26.1I20251016234041-_cd-builder-1 Linux (none) 5.15.164-10.22.33.18-yocto-standard-juniper-17166-g088c19cd4948 #1 SMP PREEMPT Mon Oct 6 04:26:49 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

openconfig:/system/state/last-configuration-timestamp: 1760805868949826900

Without origin population either in Notification prefix or Update

$ ./gnmic -a eos1:6030 -u admin -p admin --insecure subscribe -e proto --format flat --mode once --stream-mode sample --path /system/state
/system/state/boot-time: 1760811567867886066

/system/state/current-datetime: 2025-10-18T19:18:11Z

/system/state/hostname: eos1

/system/state/last-configuration-timestamp: 1760811955880948250

/system/state/software-version: 4.35.0F

  - Handle leading slash for flat format when origin is not included in
    prefix or prefix is non-existant
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.

1 participant