ciscodnacnetbox icon indicating copy to clipboard operation
ciscodnacnetbox copied to clipboard

Device Sync Issue

Open prnzngr opened this issue 2 years ago • 15 comments

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

prnzngr avatar Jun 18 '22 19:06 prnzngr

@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

robertcsapo avatar Jul 15 '22 08:07 robertcsapo

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`

ghost avatar Jul 27 '22 07:07 ghost

@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.

prnzngr avatar Jul 27 '22 07:07 prnzngr

@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 avatar Aug 01 '22 22:08 robertcsapo

@robertcsapo Thanks you! Verified working on kubernetes!

ghost avatar Aug 02 '22 02:08 ghost

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'

prnzngr avatar Aug 02 '22 10:08 prnzngr

@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 avatar Aug 17 '22 07:08 robertcsapo

@robertcsapo no it's not mapped to a site. In this case, it's an Accesspoint which is under "Unassigned Devices"

prnzngr avatar Aug 17 '22 11:08 prnzngr

@netzbus how would you like to map the device(s) under NetBox, that isn't assigned to any site?

robertcsapo avatar Aug 18 '22 11:08 robertcsapo

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

prnzngr avatar Aug 19 '22 08:08 prnzngr

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?

robertcsapo avatar Aug 25 '22 05:08 robertcsapo

Yes I have because of "Internal Error" in DNA

prnzngr avatar Aug 25 '22 12:08 prnzngr

@netzbus

If the device has an error state and no serial number, we could avoid syncing them with NetBox. Would that be doable?

robertcsapo avatar Aug 26 '22 13:08 robertcsapo

that would be an good option

prnzngr avatar Aug 29 '22 15:08 prnzngr

@netzbus could you try this version? pip install ciscodnacnetbox==3.2.3

https://github.com/robertcsapo/ciscodnacnetbox/blob/6566c4ed0a4f59d745a266113dd405d323f71905/ciscodnacnetbox/ciscodnac/data.py#L279

robertcsapo avatar Aug 30 '22 09:08 robertcsapo