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

Device sync limited to 500. #15

Open
shauntilyard opened this issue May 3, 2023 · 3 comments
Open

Device sync limited to 500. #15

shauntilyard opened this issue May 3, 2023 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@shauntilyard
Copy link

Hello, I have DNAC/Netbox integrated but I am hitting a device sync limit I believe. I can only ever discover 500 devices? I can sync them all with no issues. Is there a limit coded somewhere?

@robertcsapo
Copy link
Owner

@shauntilyard this would require pagination support in the code.

def devices(self, tenant):
"""
Get Devices from Cisco DNA Center
"""
return tenant.devices.get_device_list().response

# Get devices from Cisco DNA Center
for device in tenants.devices(tenant=dnac):

Ref cisco-en-programmability/dnacentersdk#70

@robertcsapo robertcsapo added help wanted Extra attention is needed good first issue Good for newcomers labels May 20, 2023
@fue36
Copy link

fue36 commented May 2, 2024

Bump, same issue here. No pagination is performed on device import.

@fue36
Copy link

fue36 commented May 2, 2024

I just followed comment cisco-en-programmability/dnacentersdk#70 (comment) in the link robertcsapo referred to. I didn't use a debugger, or anything, just vim. Worked for me. Just in time for robertcsapo to merge in time for Cisco Live 2024. :)

My working dir was /opt/netbox/venv/lib/python3.9/site-packages/ciscodnacnetbox/ciscodnac. Restart netbox & netbox-rq after making the changes.

--- __init__.py.orig	2024-05-02 16:20:15.155869824 -0400
+++ __init__.py	2024-05-02 17:03:51.544401637 -0400
@@ -66,7 +66,16 @@
         """
         Get Devices from Cisco DNA Center
         """
-        return tenant.devices.get_device_list().response
+        max_items = 2 #Here goes API Limit elements per page.
+        devices = []
+        offset = 1
+        items = max_items
+        while items >= max_items:
+            devices_api = tenant.devices.get_device_list(offset=offset, limit = max_items)
+            devices.extend(devices_api.response)
+            offset += max_items
+            items = len(devices_api.response)
+        return devices
 
     def sites(self, tenant):
         """

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants