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

utils.sw.install gives int() argument must be a string, a bytes-like object or a number, not 'NoneType' #1184

Closed
Aaron-MJohn opened this issue Jun 23, 2022 · 6 comments
Assignees

Comments

@Aaron-MJohn
Copy link

Aaron-MJohn commented Jun 23, 2022

I am trying to upgrade the EX2300 with 48 POE+ switch using below code. I don't set any time out parameters in install function. Everything is using the default value.

with Device(host=hostname, user=junos_username, passwd=junos_password) as dev:
        print("Connecting to {}".format(hostname))
        if dev.connected:
            print("Device connected")
            sw = SW(dev)`
            ok = sw.install(
                package=firware_update_files,
                progress=my_progress,
                no_copy=True,
                validate=False,
                cleanfs=True,
            )

I get this exception

192.168.1.2:request-package-checks-pending-install rpc is not supported on given device
192.168.1.2:installing software ... please be patient ...
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/jnpr/junos/device.py", line 227, in timeout
    self._conn.timeout = int(value)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/jnpr/junos/decorators.py", line 24, in wrapper
    dev.timeout = restore_timeout
  File "/usr/local/lib/python3.8/dist-packages/jnpr/junos/device.py", line 229, in timeout
    raise RuntimeError(
RuntimeError: could not convert timeout value of None to an integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/jnpr/junos/device.py", line 227, in timeout
    self._conn.timeout = int(value)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/..../devel/ros_ws/src/bg_sandbox/juno_config/scripts/juno_update.py", line 62, in <module>
    main()
  File "/home/..../devel/ros_ws/src/bg_sandbox/juno_config/scripts/juno_update.py", line 37, in main
    ok = sw.install(
  File "/usr/local/lib/python3.8/dist-packages/jnpr/junos/utils/sw.py", line 990, in install
    add_ok = self.pkgadd(
  File "/usr/local/lib/python3.8/dist-packages/jnpr/junos/utils/sw.py", line 240, in pkgadd
    rsp = self.rpc.request_package_add(**args)
  File "/usr/local/lib/python3.8/dist-packages/jnpr/junos/rpcmeta.py", line 364, in _exec_rpc
    return self._junos.execute(rpc, **dec_args)
  File "/usr/local/lib/python3.8/dist-packages/jnpr/junos/decorators.py", line 76, in wrapper
    return function(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/jnpr/junos/decorators.py", line 27, in wrapper
    dev.timeout = restore_timeout
  File "/usr/local/lib/python3.8/dist-packages/jnpr/junos/device.py", line 229, in timeout
    raise RuntimeError(
RuntimeError: could not convert timeout value of None to an integer
@francoisv100
Copy link

related error
getting the following error for device timeout as well , when using version 2.6.4 , version 2.6.3 works correctly,

Python code:
rpc = dev.rpc.get_interface_information(dev_timeout=360, level_extra='descriptions')

Error below for version 2.6.4:

Traceback (most recent call last):
File "/Users/francoisvanheerden/PycharmProjects/venv/lib/python3.7/site-packages/jnpr/junos/device.py", line 227, in timeout
self._conn.timeout = int(value)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/francoisvanheerden/PycharmProjects/venv/lib/python3.7/site-packages/jnpr/junos/decorators.py", line 24, in wrapper
dev.timeout = restore_timeout
File "/Users/francoisvanheerden/PycharmProjects/venv/lib/python3.7/site-packages/jnpr/junos/device.py", line 230, in timeout
"could not convert timeout value of %s to an " "integer" % (value)
RuntimeError: could not convert timeout value of None to an integer

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/francoisvanheerden/PycharmProjects/venv/lib/python3.7/site-packages/jnpr/junos/device.py", line 227, in timeout
self._conn.timeout = int(value)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./junos-ez-interface-description-account-no-only.py", line 41, in
rpc = dev.rpc.get_interface_information(dev_timeout="360", level_extra='descriptions')
File "/Users/francoisvanheerden/PycharmProjects/venv/lib/python3.7/site-packages/jnpr/junos/rpcmeta.py", line 364, in _exec_rpc
return self._junos.execute(rpc, **dec_args)
File "/Users/francoisvanheerden/PycharmProjects/venv/lib/python3.7/site-packages/jnpr/junos/decorators.py", line 76, in wrapper
return function(*args, **kwargs)
File "/Users/francoisvanheerden/PycharmProjects/venv/lib/python3.7/site-packages/jnpr/junos/decorators.py", line 27, in wrapper
dev.timeout = restore_timeout
File "/Users/francoisvanheerden/PycharmProjects/venv/lib/python3.7/site-packages/jnpr/junos/device.py", line 230, in timeout
"could not convert timeout value of %s to an " "integer" % (value)
RuntimeError: could not convert timeout value of None to an integer

@chidanandpujar
Copy link
Collaborator

Hi,

Please try with option dev.timeout .

from jnpr.junos import Device
from lxml import etree

dev = Device(host='xx.xx.xx.xx', user='xyz', password='xyz', gather_facts=False)
dev.open()
dev.timeout = 360
op = dev.rpc.get_interface_information(dev_timeout=360)
print (etree.tostring(op))
dev.close()

Thanks & Regards
Chidanand

@Aaron-MJohn
Copy link
Author

Aaron-MJohn commented Jul 5, 2022

Yes setting device.timeout solved the issue. Thanks

@volans-
Copy link

volans- commented Jul 20, 2022

I got the same issue and I had to pass the conn_open_timeout parameter to the call to Device in my case to fix the issue.

It seems to me that the culprit, at least in my case, is this commit 84fe8c6 because it uses None as default value for:

self._conn_open_timeout = kvargs.get('conn_open_timeout', None)

that is later used as a value for the timeout parameter inside open() at line 1312:

timeout=self._conn_open_timeout,

wmfgerrit pushed a commit to wikimedia/homer that referenced this issue Jul 21, 2022
* In the latest version of the upstream JunOS Python library
  py-junos-eznc there is a regression that requires to always set the
  'conn_open_timeout' parameter when creating a new Device instance to
  prevent to get an error of the type:
    could not convert timeout value of None to an integer
* See Juniper/py-junos-eznc#1184

Change-Id: I561181b8b292465b1c9e50fb311bf9ae0af37be2
dineshbaburam91 added a commit that referenced this issue Jul 21, 2022
@chidanandpujar
Copy link
Collaborator

Issue fixed via commit #1192

@Bischoff
Copy link

Thanks @chidanandpujar . I was also getting it from junos salt-proxy when trying to apply a Salt state.

wmfgerrit pushed a commit to wikimedia/operations-software-homer-deploy that referenced this issue Aug 4, 2022
To include this fix:
Juniper/py-junos-eznc#1184

Change-Id: I36709a4fc049db8c43404f5edeca5a7def6807ba
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

6 participants