ciscodnacnetbox
ciscodnacnetbox copied to clipboard
Device Sync Issue
I installed this plugin and Site sync is working but Device Sync or Full Sync not. I get this error:
ciscodnacnetbox.ciscodnac.data.full_sync | Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.9/site-packages/rq/worker.py", line 1061, in perform_job rv = job.perform() File "/opt/netbox/venv/lib/python3.9/site-packages/rq/job.py", line 821, in perform self._result = self._execute() File "/opt/netbox/venv/lib/python3.9/site-packages/rq/job.py", line 844, in _execute result = self.func(*self.args, **self.kwargs) File "/opt/netbox/venv/lib/python3.9/site-packages/ciscodnacnetbox/ciscodnac/data.py", line 23, in full_sync devices = Data.sync_devices(**kwargs) File "/opt/netbox/venv/lib/python3.9/site-packages/ciscodnacnetbox/ciscodnac/data.py", line 322, in sync_devices slug=site_members[device.serialNumber], KeyError: 'FGL245AVBXN' |
---|
netbox is running inside a docker container:
Python version: 3.9.5 NetBox version: 3.2.4 DNA Center version: 1.6.706
@netzbus it might be that the sites isn't properly synced. If you look at Cisco DNA Center and Netbox sites/location, do they match in name and count?
Because it's trying to get a Site in Netbox https://github.com/robertcsapo/ciscodnacnetbox/blob/56de961ec5473548da0840a1459266d1d109d9e6/ciscodnacnetbox/ciscodnac/data.py#L321-L324
Getting the same issue with a newly deployed netbox. Tried syncing with our local DNA-C and cisco sandbox, same results:
Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.10/site-packages/rq/worker.py", line 1061, in perform_job rv = job.perform() File "/opt/netbox/venv/lib/python3.10/site-packages/rq/job.py", line 821, in perform self._result = self._execute() File "/opt/netbox/venv/lib/python3.10/site-packages/rq/job.py", line 844, in _execute result = self.func(*self.args, **self.kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/ciscodnacnetbox/ciscodnac/data.py", line 22, in full_sync sites = Data.sync_sites(**kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/ciscodnacnetbox/ciscodnac/data.py", line 201, in sync_sites for site in tenants.sites(tenant=dnac): File "/opt/netbox/venv/lib/python3.10/site-packages/ciscodnacnetbox/ciscodnac/__init__.py", line 75, in sites return tenant.sites.get_site().response AttributeError: 'NoneType' object has no attribute 'sites'
Server Error: `<class 'AttributeError'>
'NoneType' object has no attribute 'sites'
Python version: 3.10.4 NetBox version: 3.2.7`
@netzbus it might be that the sites isn't properly synced. If you look at Cisco DNA Center and Netbox sites/location, do they match in name and count?
Because it's trying to get a Site in Netbox
https://github.com/robertcsapo/ciscodnacnetbox/blob/56de961ec5473548da0840a1459266d1d109d9e6/ciscodnacnetbox/ciscodnac/data.py#L321-L324
It was a fresh installed netbox.
@netzbus @rcalma Could you try with latest version?
pip3 install ciscodnacnetbox==3.2.2
I've tested this with Cisco DNA Center Sandbox (sandboxdnac.cisco.com).
@robertcsapo Thanks you! Verified working on kubernetes!
no, it's not working:
Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.10/site-packages/rq/worker.py", line 1068, in perform_job rv = job.perform() File "/opt/netbox/venv/lib/python3.10/site-packages/rq/job.py", line 847, in perform self._result = self._execute() File "/opt/netbox/venv/lib/python3.10/site-packages/rq/job.py", line 870, in _execute result = self.func(*self.args, **self.kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/ciscodnacnetbox/ciscodnac/data.py", line 23, in full_sync devices = Data.sync_devices(**kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/ciscodnacnetbox/ciscodnac/data.py", line 325, in sync_devices slug=site_members[device.serialNumber], KeyError: 'FGL1234L0MN'
@netzbus could you check if FGL1234L0MN is mapped to any sites? https://github.com/robertcsapo/ciscodnacnetbox/blob/56de961ec5473548da0840a1459266d1d109d9e6/ciscodnacnetbox/ciscodnac/init.py#L89-L93
If yes, can you check the Site members? Is FGL1234L0MN being listed under device
array?
/dna/intent/api/v1/site/Global
(change to FGL1234L0MN site name)
/dna/intent/api/v1/membership/b73390ce-b713-49c1-899b-1605853c321d
(change UUID from the results above)
- https://developer.cisco.com/docs/dna-center/#!get-site
- https://developer.cisco.com/docs/dna-center/#!get-membership
@robertcsapo no it's not mapped to a site. In this case, it's an Accesspoint which is under "Unassigned Devices"
@netzbus how would you like to map the device(s) under NetBox, that isn't assigned to any site?
Ok, I think I understand your hint. Now I assigned every Device to a Site but getting now a diffrent error.
Traceback (most recent call last): File "/opt/netbox/venv/lib/python3.10/site-packages/rq/worker.py", line 1068, in perform_job rv = job.perform() File "/opt/netbox/venv/lib/python3.10/site-packages/rq/job.py", line 847, in perform self._result = self._execute() File "/opt/netbox/venv/lib/python3.10/site-packages/rq/job.py", line 870, in _execute result = self.func(*self.args, **self.kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/ciscodnacnetbox/ciscodnac/data.py", line 23, in full_sync devices = Data.sync_devices(**kwargs) File "/opt/netbox/venv/lib/python3.10/site-packages/ciscodnacnetbox/ciscodnac/data.py", line 338, in sync_devices sync_status = Netbox.Sync.device(tenant=tenant, device=device) File "/opt/netbox/venv/lib/python3.10/site-packages/ciscodnacnetbox/ciscodnac/netbox.py", line 232, in device device.serialNumber = device.serialNumber[0:50] TypeError: 'NoneType' object is not subscriptable
device.serialNumber = device.serialNumber[0:50] TypeError: 'NoneType' object is not subscriptable
https://github.com/robertcsapo/ciscodnacnetbox/blob/56de961ec5473548da0840a1459266d1d109d9e6/ciscodnacnetbox/ciscodnac/netbox.py#L232
Do you have devices without serial numbers in Cisco DNA Center?
Yes I have because of "Internal Error" in DNA
@netzbus
If the device has an error state and no serial number, we could avoid syncing them with NetBox. Would that be doable?
that would be an good option
@netzbus could you try this version?
pip install ciscodnacnetbox==3.2.3
https://github.com/robertcsapo/ciscodnacnetbox/blob/6566c4ed0a4f59d745a266113dd405d323f71905/ciscodnacnetbox/ciscodnac/data.py#L279