-
Hi, Is there an efficient way to directly filter for cables that are between sites? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Would it be less lookups to come at it from the other direction, get the list of device IDs (?brief=1) at each site, then the related interface IDs and then cables that are terminated on one of those interfaces. You may need to keep the interface ID lists separate so you know which site they belong to, so you can look for cables with one end in column A and another in column B.
Or maybe GraphQL allows for more complex filtering like this
—
Mark Tinberg ***@***.***>
Division of Information Technology-Network Services
University of Wisconsin-Madison
…________________________________
From: PaulR282 ***@***.***>
Sent: Wednesday, July 19, 2023 3:43 AM
To: netbox-community/netbox ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [netbox-community/netbox] Filter cables with ends in different sites (Discussion #13214)
Hi,
Is there an efficient way to directly filter for cables that are between sites?
My current solution is to loop through all cables, get the device objects of the devices on both ends, and compare their sites. This works but takes a long time (script runs for 1m 30s for 2000 cables).
—
Reply to this email directly, view it on GitHub<#13214>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAS7UM3I3NFLC6COCZXOJPTXQ6MZZANCNFSM6AAAAAA2PSINNE>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Similar to this? https://github.com/netbox-community/customizations/blob/master/reports/dcim-reports/CheckCableLocality.py You might find that judicious use of "prefetch_related" helps to speed things up. I think it's the only way: a cable doesn't cache which site(s) it's connected in. Note that a single cable can have multiple terminations at each end, and those terminations could (in principle) all go to devices in different sites. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the suggestions, but since I can't natively filter for what I want this is my final solution: Since cross-site cables aren't really dynamic, I have a Script that runs every hour and tags the cross-site cables. My primary script now filters for the tag and now only needs about 5s for everything including the cables. |
Beta Was this translation helpful? Give feedback.
Thanks for the suggestions, but since I can't natively filter for what I want this is my final solution: Since cross-site cables aren't really dynamic, I have a Script that runs every hour and tags the cross-site cables. My primary script now filters for the tag and now only needs about 5s for everything including the cables.