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

Netbox Datacenter: None #154

Closed
jczmok-iag opened this issue Jul 17, 2020 · 9 comments
Closed

Netbox Datacenter: None #154

jczmok-iag opened this issue Jul 17, 2020 · 9 comments

Comments

@jczmok-iag
Copy link

Traceback (most recent call last):
File "/usr/local/bin/netbox_agent", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/netbox_agent/cli.py", line 44, in main
return run(config)
File "/usr/local/lib/python3.5/dist-packages/netbox_agent/cli.py", line 36, in run
server.print_debug()
File "/usr/local/lib/python3.5/dist-packages/netbox_agent/server.py", line 299, in print_debug
print('Netbox Rack:', self.get_netbox_rack())
File "/usr/local/lib/python3.5/dist-packages/netbox_agent/server.py", line 91, in get_netbox_rack
site_id=self.get_netbox_datacenter().id,

please advise whats wrong here.
he finds out datacetner correctly
and the rack as well.

@Solvik
Copy link
Owner

Solvik commented Jul 17, 2020

do you still have the problem with the master branch?

@jczmok-iag
Copy link
Author

i just installed this on a new node (with pip3 install..). it should be the master branch.

@jczmok-iag
Copy link
Author

the full error message:

root@server-xx-xx:~# netbox_agent -c /etc/netbox_agent.yml --register --debug
Datacenter: SOMEDATACENTER
Netbox Datacenter: None
Rack: K3
Traceback (most recent call last):
File "/usr/local/bin/netbox_agent", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/netbox_agent/cli.py", line 44, in main
return run(config)
File "/usr/local/lib/python3.5/dist-packages/netbox_agent/cli.py", line 36, in run
server.print_debug()
File "/usr/local/lib/python3.5/dist-packages/netbox_agent/server.py", line 299, in print_debug
print('Netbox Rack:', self.get_netbox_rack())
File "/usr/local/lib/python3.5/dist-packages/netbox_agent/server.py", line 91, in get_netbox_rack
site_id=self.get_netbox_datacenter().id,
AttributeError: 'NoneType' object has no attribute 'id'

@Solvik
Copy link
Owner

Solvik commented Jul 19, 2020

pip3 install doesn't install the master branch but the latest release

from what I understand, you don't have any datacenter which slugs equals SOMEDATACENTER
is that correct ?

@jczmok-iag
Copy link
Author

Okay, so i use the latest release...

Regarding the data:
root@server-k3-05:~# more /etc/qualification
DATACENTER: SOMEDATACENTER
RACK: K3
TENANT: provider

i didn't found a way to define netboxdatacenter

and i used the respective parts in netbox.yaml:

config.yml.txt

@Solvik
Copy link
Owner

Solvik commented Jul 19, 2020

the datacenter is found with a search based on the slug attribute in Netbox
is your datacenter's slug attribute SOMEDATACENTER ?

@jczmok-iag
Copy link
Author

on /api/dcim/sites the slug is 'somedatacenter-ltd' and actually in /etc/qualification it is also lowercase.
strangely it does write uppercase "SOMEDATACENTER" and not "somedatacenter-ltd"

in the api :
"name": "Somedatacenter-ltd",
"slug": "somedatacenter-ltd",

But where is the definition (or where do you setup the " Netbox Datacenter and Netbocx Rack" ?

@jczmok-iag
Copy link
Author

Well. I sorted this out: "| tr [a-z] [A-Z]" does lower to uppercase transformation. bad for slugs.
it kinda works, but when updating:

DEBUG:urllib3.connectionpool:http://netbox.xxxxx:80 "GET /api/dcim/sites/?slug=somedatacenter-ltd HTTP/1.1" 200 798
Traceback (most recent call last):
File "/usr/local/bin/netbox_agent", line 11, in
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/netbox_agent/cli.py", line 44, in main
return run(config)
File "/usr/local/lib/python3.5/dist-packages/netbox_agent/cli.py", line 39, in run
server.netbox_create_or_update(config)
File "/usr/local/lib/python3.5/dist-packages/netbox_agent/server.py", line 287, in netbox_create_or_update
ret, server = self.update_netbox_location(server)
File "/usr/local/lib/python3.5/dist-packages/netbox_agent/server.py", line 72, in update_netbox_location
if rack and server.rack and server.rack.id != nb_rack.id:
AttributeError: 'NoneType' object has no attribute 'id'

@Solvik
Copy link
Owner

Solvik commented Jul 28, 2020

it's just a config example, but you're right I should change the example from uppercase to lowercase
In the master version, I've added more checks for location

it'd be better if you could test with it so you have a better error

thanks

@Solvik Solvik closed this as completed Nov 28, 2020
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