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

pygnmi doesn't send anything over the wire #57

Open
svautour opened this issue Apr 26, 2022 · 8 comments
Open

pygnmi doesn't send anything over the wire #57

svautour opened this issue Apr 26, 2022 · 8 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@svautour
Copy link

Test code:

from pygnmi.client import gNMIclient
if name == 'main':
host = ("172.16.18.9", "57400")
paths = ['openconfig-interfaces:interfaces', 'openconfig-network-instance:network-instances']
with gNMIclient(target=host, username="xxxx", password="xxxxxxx", insecure=True) as gc:
response = gc.capabilities()
print (response)

When I run:

(virtual3.9) root@squad3_1:~/virtual3.9# python pygnmitest.py
Traceback (most recent call last):
File "/root/virtual3.9/pygnmitest.py", line 7, in
with gNMIclient(target=host, username="xxxx", password="xxxxxxx", insecure=True) as gc:
File "/root/virtual3.9/lib/python3.9/site-packages/pygnmi/client.py", line 94, in enter
return self.connect()
File "/root/virtual3.9/lib/python3.9/site-packages/pygnmi/client.py", line 146, in connect
self.wait_for_connect(timeout)
File "/root/virtual3.9/lib/python3.9/site-packages/pygnmi/client.py", line 156, in wait_for_connect
grpc.channel_ready_future(self.__channel).result(timeout=timeout)
File "/root/virtual3.9/lib/python3.9/site-packages/grpc/_utilities.py", line 139, in result
self._block(timeout)
File "/root/virtual3.9/lib/python3.9/site-packages/grpc/_utilities.py", line 85, in _block
raise grpc.FutureTimeoutError()
grpc.FutureTimeoutError

I have tried this in a python 3.8 and 3.9 venv on 2 different Ubuntu VMs. Same result.

If I tcpdump the NIC, I see no traffic to the host on port 57400.

Thanks,
Serge

@akarneliuk
Copy link
Owner

Hello @svautour ,

sorry for the delay, I somehow overlooked your request. I'm afraid you don't provide any details of your setup. Please, provide the configuration of your network device you try to manage with pygnmi.

also, this part is not accurate:

if name == 'main':

It shall be:

if __name__ == "__main__":

Join our Zero-to-Hero Network Automation Training to learn more about Python for network automation

Best,
Anton

@akarneliuk akarneliuk added the help wanted Extra attention is needed label Jul 10, 2022
@akarneliuk
Copy link
Owner

Hey @svautour ,

Please, re-open if needed.

Best,
Anton

@svautour
Copy link
Author

Re-opening. Sorry for the delay, I was on vacation.

My code does have the underscore. It didn't come across correctly as I didn't paste it as a code block.

What information do you require that I did not include? What command outputs would you like?

The config on the router that I am trying to manage is irrelevant here as when I tcpdump the NIC on the server where I run the code, I see no outbound packets to my device on port 57400.

Thanks for creating and sharing. I am looking forward to a gnmi client for python. I will help if I can.

Serge

@akarneliuk akarneliuk reopened this Jul 20, 2022
@akarneliuk
Copy link
Owner

Hey @svautour ,

if pygnmi doesn't send anything to a wire, it may be something with your environment. Could you please suggest what is:

  • Your OS and its version
  • Your Python version
  • Output of pip freeze

Best,
Anton

@svautour
Copy link
Author

Using a venv:

(virtual3.8) root@xxxxxx-ubuntu:~/TrainingExamples# python3 -V
Python 3.8.0

(virtual3.8) root@xxxxxx-ubuntu:~/TrainingExamples# python3 pygnmitest.py
Traceback (most recent call last):
File "pygnmitest.py", line 7, in
with gNMIclient(target=host, username="svautour", password="xxxxxxx", insecure=True) as gc:
File "/root/TrainingExamples/virtual3.8/lib/python3.8/site-packages/pygnmi/client.py", line 94, in enter
return self.connect()
File "/root/TrainingExamples/virtual3.8/lib/python3.8/site-packages/pygnmi/client.py", line 146, in connect
self.wait_for_connect(timeout)
File "/root/TrainingExamples/virtual3.8/lib/python3.8/site-packages/pygnmi/client.py", line 156, in wait_for_connect
grpc.channel_ready_future(self.__channel).result(timeout=timeout)
File "/root/TrainingExamples/virtual3.8/lib/python3.8/site-packages/grpc/_utilities.py", line 139, in result
self._block(timeout)
File "/root/TrainingExamples/virtual3.8/lib/python3.8/site-packages/grpc/_utilities.py", line 85, in _block
raise grpc.FutureTimeoutError()
grpc.FutureTimeoutError

(virtual3.8) root@xxxxxx-ubuntu:~/TrainingExamples# uname -a
Linux xxxxxx-ubuntu 4.15.0-167-generic #175-Ubuntu SMP Wed Jan 5 01:56:07 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

(virtual3.8) root@xxxxxx-ubuntu:~/TrainingExamples# more /etc/os-release
NAME="Ubuntu"
VERSION="18.04.5 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.5 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

(virtual3.8) root@COVEP23tools-ubuntu:~/TrainingExamples# pip3 freeze
cffi==1.15.0
cryptography==36.0.2
dictdiffer==0.9.0
grpcio==1.44.0
grpcio-tools==1.44.0
kthread==0.2.3
protobuf==3.20.0
pycparser==2.21
pygnmi==0.6.9
six==1.16.0

(virtual3.8) root@COVEP23tools-ubuntu:~/TrainingExamples# pip freeze
cffi==1.15.0
cryptography==36.0.2
dictdiffer==0.9.0
grpcio==1.44.0
grpcio-tools==1.44.0
kthread==0.2.3
protobuf==3.20.0
pycparser==2.21
pygnmi==0.6.9
six==1.16.0

Thanks,
Serge

@akarneliuk akarneliuk self-assigned this Jul 23, 2022
@akarneliuk
Copy link
Owner

Hey @svautour ,

Try to build a new VM and see how it would work. I've just tested this:

if __name__ == "__main__":
    with gNMIclient(target=(ENV_HOSTNAME, ENV_PORT),
                    username=ENV_USERNAME,
                    password=ENV_PASSWORD,
                    insecure=True) as gconn:
        gconn.capabilities()

        result = gconn.get(path=["/"])
        print(result)

and got:

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked v1), capture size 262144 bytes
16:52:46.668450 IP 192.168.1.115.60630 > ***.***.***.***.57400: Flags [S], seq 2497241027, win 64240, options [mss 1460,sackOK,TS val 867433530 ecr 0,nop,wscale 7], length 0
16:52:46.672539 IP ***.***.***.***.57400 > 192.168.1.115.60630: Flags [S.], seq 1098571442, ack 2497241028, win 65160, options [mss 1460,sackOK,TS val 2456298786 ecr 867433530,nop,wscale 7], length 0
16:52:46.672583 IP 192.168.1.115.60630 > ***.***.***.***.57400: Flags [.], ack 1, win 502, options [nop,nop,TS val 867433534 ecr 2456298786], length 0

So it doesn't seem to be an issue with pygnmi, sir.

Best,
Anton

@svautour
Copy link
Author

svautour commented Dec 20, 2022 via email

@jbemmel
Copy link
Contributor

jbemmel commented Sep 11, 2023

If this is against SR Linux (or perhaps some other device with security by default), try insecure=False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants