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

[SONiC-gRPC telemetry] - Facing issue while performing "gnmi_get" operation in the telemetry container. #148

Open
donbharath21 opened this issue Sep 5, 2023 · 0 comments
Assignees

Comments

@donbharath21
Copy link

  1. First like mentioned in the link https://karneliuk.com/2023/01/automation-19-enabling-ocp-sonic-to-be-managed-via-gnmi-with-pygnmi/ we have made a connection between Linux machine and SONiC switch.

  2. Configured all the things like hostname, ip-address, up and running the telemetry container.

  3. Performed the set of commands to create a certification:

admin@sonic:~$ sudo openssl req -x509 -newkey rsa:4096 -keyout /etc/sonic/telemetry/dsmsroot.key
-out /etc/sonic/telemetry/dsmsroot.cer -sha256 -days 365 -nodes -subj '/CN=lab-ca'

admin@sonic:~$ sudo openssl req -new -newkey rsa:4096 -nodes
-keyout /etc/sonic/telemetry/streamingtelemetryserver.key -out /etc/sonic/telemetry/streamingtelemetryserver.csr
-subj "/CN=dev-pygnmi-sonic-003" --> Here is used hostname and CN as "sonic".

admin@sonic:~$ sudo openssl x509 -req -in /etc/sonic/telemetry/streamingtelemetryserver.csr
-CA /etc/sonic/telemetry/dsmsroot.cer -CAkey /etc/sonic/telemetry/dsmsroot.key
-CAcreateserial -out /etc/sonic/telemetry/streamingtelemetryserver.cer
-days 365 -sha512

  1. Then conformed the port is listening to the "50051"
image
  1. While testing with pygnmi using the script :

$ cat test.py

from pygnmi.client import gNMIclient

import json

host = {
"ip_address": "50.0.0.20",
"port": 50051,
"username": "admin",
"password": "YourPaSsWoRd",
}

if name == "main":
with gNMIclient(
target=(host["ip_address"], host["port"]),
username=host["username"],
password=host["password"],
path_root="/etc/sonic/telemetry/certs/ca.pem",
path_cert="/etc/sonic/telemetry/certs/server.pem",
path_key="/etc/sonic/telemetry/certs/server.key",
override="sonic",
#override="dev-pygnmi-sonic-003",
) as gc:
result = gc.capabilities()
print(json.dumps(result, indent=4))

  1. Iam getting a proper output of the capabilities: $ python3 test.py
    {
    "supported_models": [
    {
    "name": "openconfig-acl",
    "organization": "OpenConfig working group",
    "version": "1.0.2"
    },
    {
    "name": "openconfig-acl",
    "organization": "OpenConfig working group",
    "version": "1.0.2"
    },
    {
    "name": "openconfig-interfaces",
    "organization": "OpenConfig working group",
    "version": "1.0.2"
    },
    {
    "name": "openconfig-lldp",
    "organization": "OpenConfig working group",
    "version": "1.0.2"
    },
    {
    "name": "openconfig-platform",
    "organization": "OpenConfig working group",
    "version": "1.0.2"
    },
    {
    "name": "openconfig-system",
    "organization": "OpenConfig working group",
    "version": "1.0.2"
    },
    {
    "name": "ietf-yang-library",
    "organization": "IETF NETCONF (Network Configuration) Working Group",
    "version": "2016-06-21"
    },
    {
    "name": "sonic-db",
    "organization": "SONiC",
    "version": "0.1.0"
    }
    ],
    "supported_encodings": [
    "json",
    "json_ietf"
    ],
    "gnmi_version": "0.7.0"
    }

  2. Like this if i try to perform the get/set operation iam facing issue.

$ python3 get.py
Traceback (most recent call last):
File "get.py", line 15, in
password=host["password"], insecure=True) as gc:
File "/usr/local/lib/python3.6/dist-packages/pygnmi/client.py", line 136, in enter
return self.connect()
File "/usr/local/lib/python3.6/dist-packages/pygnmi/client.py", line 259, in connect
self.wait_for_connect(timeout)
File "/usr/local/lib/python3.6/dist-packages/pygnmi/client.py", line 281, in wait_for_connect
grpc.channel_ready_future(self.__channel).result(timeout=timeout)
File "/usr/local/lib/python3.6/dist-packages/grpc/_utilities.py", line 139, in result
self._block(timeout)
File "/usr/local/lib/python3.6/dist-packages/grpc/_utilities.py", line 85, in _block
raise grpc.FutureTimeoutError()
grpc.FutureTimeoutError

--> script to run the get operation:

image
  1. Next i tried directly in the SONiC switch the steps which is mentioned in the this link: https://github.com/sonic-net/sonic-gnmi/blob/master/doc/grpc_telemetry.md

gnmi_get -xpath_target COUNTERS_DB -xpath COUNTERS_PORT_NAME_MAP -target_addr 50.0.0.20:50051 -alsologtostderr -insecure true

gnmi_get -xpath_target COUNTERS_DB -xpath COUNTERS/eth0 -target_addr 50.0.0.20:50051 -alsologtostderr -insecure true

Both command troughed the same issue:
issue

  1. When i checked in the telemetry container their is no dail-in client.:
image
  1. Output for : $ show platform summary
image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants