akarneliuk / pygnmi

The pure Python implementation of the gNMI client.
https://training.karneliuk.com
BSD 3-Clause "New" or "Revised" License
126 stars 44 forks source link

Invalid Path error #135

Closed JahedulAnowar closed 10 months ago

JahedulAnowar commented 11 months ago

I seem to be getting "invalid path" error. But I can get data from the same path using gNMIc:

$ gnmic --config insecure.yml get --path "openconfig-interfaces:interfaces/interface"

[
  {
    "source": "192.168.100.100:51052",
    "timestamp": 1696003998802387748,
    "time": "2023-09-29T07:13:18.802387748+09:00",
    "updates": [
      {
        "Path": "openconfig-interfaces:interfaces/interface",
        "values": {
          "openconfig-interfaces:interfaces/interface": [
            {
              "config": {
                "link-pass-through": false,
                "mtu": 9600,
                "name": "logical-channel-23100101",
                "type": "iana-if-type:ethernetCsmacd"
              },
              "name": "logical-channel-23100101",
              "state": {
                "admin-status": "UP",
                "enabled": true,
                "hardware-port": "qsfp-1",
                "link-pass-through": false,
                "mtu": 9600,
                "name": "logical-channel-23100101",
                "oper-status": "UNKNOWN",
                "type": "iana-if-type:ethernetCsmacd"
              }
            },
.
.
.
            {
              "name": "logical-channel-24201201",
              "state": {
                "admin-status": "DOWN",
                "enabled": false,
                "hardware-port": "qsfp-12",
                "name": "logical-channel-24201201",
                "oper-status": "UNKNOWN",
                "type": "iana-if-type:ethernetCsmacd"
              }
            }
          ]
        }
      }
    ]
  }
]

My code:

from pygnmi.client import gNMIclient
from inventory import hosts

paths = [
    "openconfig-interfaces:interfaces/interface",
]

with gNMIclient(
    target=(hosts[1]["ip_address"], hosts[1]["port"]),
    username=hosts[1]["username"],
    password=hosts[1]["password"],
    debug=True,
    insecure=True,
    grpc_options=[("grpc.enable_http_proxy", 0)],
) as gc:
    result = gc.get(path=paths)

print(result)

Output:

GRPC Target
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
192.168.100.100:51052
-----------------------------------------------------------------------------------------------------------------------------------------------------------------

GRPC Channel options
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
[('grpc.enable_http_proxy', 0)]
-----------------------------------------------------------------------------------------------------------------------------------------------------------------

gNMI request
-----------------------------------------------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

gNMI response
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
supported_models {
  name: "openconfig-types"
  organization: "OpenConfig working group"
  version: "2019-04-16"
}
supported_models {
  name: "openconfig-yang-types"
  organization: "OpenConfig working group"
  version: "2021-07-14"
}
supported_models {
  name: "openconfig-extensions"
  organization: "OpenConfig working group"
  version: "2020-06-16"
}
supported_models {
  name: "openconfig-interfaces"
  organization: "OpenConfig working group"
  version: "2021-04-06"
}
supported_models {
  name: "openconfig-if-ethernet"
  organization: "OpenConfig working group"
  version: "2022-04-20"
}
supported_models {
  name: "openconfig-if-types"
  organization: "OpenConfig working group"
  version: "2018-11-21"
}
supported_models {
  name: "iana-if-type"
  organization: "IANA"
  version: "2017-01-19"
}
supported_models {
  name: "openconfig-platform"
  organization: "OpenConfig working group"
  version: "2022-06-10"
}
supported_models {
  name: "openconfig-platform-types"
  organization: "OpenConfig working group"
  version: "2022-03-27"
}
supported_models {
  name: "openconfig-platform-linecard"
  organization: "OpenConfig working group"
  version: "2022-04-21"
}
supported_models {
  name: "openconfig-platform-port"
  organization: "OpenConfig working group"
  version: "2021-10-01"
}
supported_models {
  name: "openconfig-platform-transceiver"
  organization: "OpenConfig working group"
  version: "2021-07-29"
}
supported_models {
  name: "openconfig-platform-fan"
  organization: "OpenConfig working group"
  version: "2018-11-21"
}
supported_models {
  name: "openconfig-platform-psu"
  organization: "OpenConfig working group"
  version: "2018-11-21"
}
supported_models {
  name: "openconfig-platform-cpu"
  organization: "OpenConfig working group"
  version: "2018-11-21"
}
supported_models {
  name: "openconfig-terminal-device"
  organization: "OpenConfig working group"
  version: "2021-07-29"
}
supported_models {
  name: "openconfig-transport-types"
  organization: "OpenConfig working group"
  version: "2021-07-29"
}
supported_models {
  name: "openconfig-transport-line-common"
  organization: "OpenConfig working group"
  version: "2019-06-03"
}
supported_models {
  name: "openconfig-system"
  organization: "OpenConfig working group"
  version: "2021-07-20"
}
supported_models {
  name: "openconfig-system-terminal"
  organization: "OpenConfig working group"
  version: "2018-11-21"
}
supported_models {
  name: "openconfig-telemetry"
  organization: "OpenConfig working group"
  version: "2018-11-21"
}
supported_models {
  name: "openconfig-telemetry-types"
  organization: "OpenConfig working group"
  version: "2018-11-21"
}
supported_models {
  name: "openconfig-terminal-device-properties"
  organization: "OpenConfig working group"
  version: "2022-04-26"
}
supported_models {
  name: "openconfig-terminal-device-property-types"
  organization: "OpenConfig working group"
  version: "2022-03-08"
}
supported_models {
  name: "openconfig-alarms"
  organization: "OpenConfig working group"
  version: "2019-07-09"
}
supported_models {
  name: "openconfig-alarm-types"
  organization: "OpenConfig working group"
  version: "2018-11-21"
}
supported_models {
  name: "ietf-alarms"
  organization: "IETF CCAMP Working Group"
  version: "2019-09-11"
}
supported_models {
  name: "nec-optical-alarm-type-id"
  organization: "NEC Corporation"
  version: "2023-01-16"
}
supported_models {
  name: "nec-optical-openconfig-alarms-notifications"
  organization: "NEC Corporation"
  version: "2022-12-05"
}
supported_models {
  name: "nec-optical-openconfig-system-snmp"
  organization: "NEC Corporation"
  version: "2022-10-01"
}
supported_models {
  name: "nec-optical-openconfig-system-config"
  organization: "NEC Corporation"
  version: "2022-11-16"
}
supported_models {
  name: "nec-optical-openconfig-platform-led"
  organization: "NEC Corporation"
  version: "2022-10-01"
}
supported_models {
  name: "nec-optical-openconfig-platform-fan"
  organization: "NEC Corporation"
  version: "2022-10-01"
}
supported_models {
  name: "nec-optical-openconfig-platform-sensor"
  organization: "NEC Corporation"
  version: "2022-10-01"
}
supported_models {
  name: "nec-optical-openconfig-platform-storage"
  organization: "NEC Corporation"
  version: "2022-10-01"
}
supported_models {
  name: "nec-optical-openconfig-platform-fabric"
  organization: "NEC Corporation"
  version: "2022-10-01"
}
supported_models {
  name: "nec-optical-openconfig-platform-optical-channel"
  organization: "NEC Corporation"
  version: "2022-12-02"
}
supported_models {
  name: "nec-optical-openconfig-terminal-device"
  organization: "NEC Corporation"
  version: "2023-01-16"
}
supported_models {
  name: "nec-optical-openconfig-interfaces"
  organization: "NEC Corporation"
  version: "2022-10-01"
}
supported_models {
  name: "nec-optical-openconfig-openflow-deviations"
  organization: "NEC Corporation"
  version: "2022-10-01"
}
supported_models {
  name: "nec-optical-openconfig-platform-cpu-deviations"
  organization: "NEC Corporation"
  version: "2022-10-01"
}
supported_models {
  name: "nec-optical-openconfig-platform-linecard-deviations"
  organization: "NEC Corporation"
  version: "2022-10-01"
}
supported_models {
  name: "nec-optical-openconfig-platform-psu-deviations"
  organization: "NEC Corporation"
  version: "2022-10-01"
}
supported_models {
  name: "nec-optical-openconfig-platform-deviations"
  organization: "NEC Corporation"
  version: "2022-10-01"
}
supported_models {
  name: "nec-optical-openconfig-system-deviations"
  organization: "NEC Corporation"
  version: "2023-01-16"
}
supported_encodings: JSON
gNMI_version: "0.6.0"

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

gNMI request
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
prefix {
}
path {
  origin: "openconfig-interfaces"
  elem {
    name: "interfaces"
  }
  elem {
    name: "interface"
  }
}

-----------------------------------------------------------------------------------------------------------------------------------------------------------------

GRPC ERROR Host: 192.168.100.100:51052, Error: failed to retrieve data from datastore. /interfaces/interface is invalid. /interfaces/interface: Invalid path
CRITICAL:pygnmi.client:GRPC ERROR Host: 192.168.100.100:51052, Error: failed to retrieve data from datastore. /interfaces/interface is invalid. /interfaces/interface: Invalid path
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.8/site-packages/pygnmi/client.py", line 432, in get
    gnmi_message_response = self.__stub.Get(gnmi_message_request, metadata=self.__metadata)
  File "/home/user/.local/lib/python3.8/site-packages/grpc/_channel.py", line 1030, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/home/user/.local/lib/python3.8/site-packages/grpc/_channel.py", line 910, in _end_unary_response_blocking
    raise _InactiveRpcError(state)  # pytype: disable=not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.INVALID_ARGUMENT
        details = "failed to retrieve data from datastore. /interfaces/interface is invalid. /interfaces/interface: Invalid path"
        debug_error_string = "UNKNOWN:Error received from peer ipv4:192.168.100.100:51052 {created_time:"2023-09-29T15:58:01.720540786+09:00", grpc_status:3, grpc_message:"failed to retrieve data from datastore. /interfaces/interface is invalid. /interfaces/interface: Invalid path"}"
>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 19, in <module>
    result = gc.get(path=paths)
  File "/home/user/.local/lib/python3.8/site-packages/pygnmi/client.py", line 520, in get
    raise gNMIException(f"GRPC ERROR Host: {self.__target_path}, Error: {err.details()}", err)
pygnmi.client.gNMIException: GRPC ERROR Host: 192.168.100.100:51052, Error: failed to retrieve data from datastore. /interfaces/interface is invalid. /interfaces/interface: Invalid path

Am I making a mistake somewhere? Thanks.

akarneliuk commented 10 months ago

Hey @JahedulAnowar ,

Thanks for your message. Try without the origin, simply as: /interfaces/interface. I know for the fact, that Arista has such an issue: it responds with the same error if you include openconfig-* origin, whilst it accepts eos_native origin.

Let me know.

Best, Anton

JahedulAnowar commented 10 months ago

@akarneliuk , Thank your for the response. I tried it, same error.

However, I added openconfig-platform: to the path as origin and it worked.

full path:

paths = [
    "openconfig-platform:openconfig-interfaces:interfaces/interface",
]

debug resposne snippet:

.
.
.
gNMI request
---------------------------------------------------------------------------------------------------------------------------------------------------------
prefix {
}
path {
  origin: "openconfig-platform"
  elem {
    name: "openconfig-interfaces:interfaces"
  }
  elem {
    name: "interface"
  }
}
.
.
.
akarneliuk commented 10 months ago

Thanks for trying this out. I would say, this is a question for gnmi implementation at NEC, as this not quite how the gnmi path is supposed to be defined: module name shall not be part of the key, which is in this case. Best Regards, Anton Karneliukhttps://karneliuk.com -------- Original message --------From: Jahedul Anowar @.>Date: Mon, 16 Oct 2023, 10:18To: akarneliuk/pygnmi @.>Cc: Anton Karneliuk @.>, Mention @.>Subject: Re: [akarneliuk/pygnmi] Invalid Path error (Issue #135) @akarneliuk , Thank your for the response. I tried it, same error. However, I added openconfig-platform: to the path as origin and it worked. full path: paths = [ "openconfig-platform:openconfig-interfaces:interfaces/interface", ]

debug resposne snippet: . . . gNMI request

prefix { } path { origin: "openconfig-platform" elem { name: "openconfig-interfaces:interfaces" } elem { name: "interface" } } . . .

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

JahedulAnowar commented 10 months ago

Thank you for the explanation.