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

fails to create IP even when its passed as str. #34

Open
shinde505 opened this issue Feb 9, 2021 · 4 comments
Open

fails to create IP even when its passed as str. #34

shinde505 opened this issue Feb 9, 2021 · 4 comments

Comments

@shinde505
Copy link

netbox.ipam.create_ip_address(str(ipaddress))

File "ipscan.py", line 44, in
netbox.ipam.create_ip_address(str(ipaddress))
File "/home/ec2-admin/.local/lib/python3.8/site-packages/netbox/ipam.py", line 62, in create_ip_address
return self.netbox_con.post('/ipam/ip-addresses/', required_fields, **kwargs)
File "/home/ec2-admin/.local/lib/python3.8/site-packages/netbox/connection.py", line 129, in post
raise exceptions.CreateException(resp_data)
File "/home/ec2-admin/.local/lib/python3.8/site-packages/netbox/exceptions.py", line 36, in init
self.err = ''.join('{} '.format(val[0]) for key, val in resp_data.items())
File "/home/ec2-admin/.local/lib/python3.8/site-packages/netbox/exceptions.py", line 36, in
self.err = ''.join('{} '.format(val[0]) for key, val in resp_data.items())
TypeError: 'int' object is not subscriptable

$ pip install python-netbox
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: python-netbox in /home/ec2-admin/.local/lib/python3.8/site-packages (0.0.18)
Requirement already satisfied: ipaddress in /home/ec2-admin/.local/lib/python3.8/site-packages (from python-netbox) (1.0.23)
Requirement already satisfied: requests in /home/ec2-admin/.local/lib/python3.8/site-packages (from python-netbox) (2.23.0)
Requirement already satisfied: chardet<4,>=3.0.2 in /home/ec2-admin/.local/lib/python3.8/site-packages (from requests->python-netbox) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /home/ec2-admin/.local/lib/python3.8/site-packages (from requests->python-netbox) (1.25.9)
Requirement already satisfied: idna<3,>=2.5 in /home/ec2-admin/.local/lib/python3.8/site-packages (from requests->python-netbox) (2.9)
Requirement already satisfied: certifi>=2017.4.17 in /home/ec2-admin/.local/lib/python3.8/site-packages (from requests->python-netbox) (2020.4.5.1)

@jagter
Copy link
Owner

jagter commented Feb 20, 2021

Could you tell me the version of Netbox you are using?

@shinde505
Copy link
Author

V2.9.7

@jagter
Copy link
Owner

jagter commented Mar 7, 2021

You found a bug in the exception handling. Unfortunately I cannot reproduce this error. I'll refactor the exception so that you receive more useful information from netbox.

@jagter
Copy link
Owner

jagter commented Mar 7, 2021

would you edit this file:
/home/ec2-admin/.local/lib/python3.8/site-packages/netbox/exceptions.py

Add the following code to line 34:
print(resp_data)

Run the create ip address again and send me the details.

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

No branches or pull requests

2 participants