1.GET /api/dcim/console-ports/?limit=200&offset=0
2.GET /api/dcim/console-ports/?limit=200&offset=200 (and continue to have all)
List all console ports
If we compare all page, we have duplicate console ports and we have missing console ports.
If we do a Get with a limit greater than the number of console ports, we don't have any duplicate or missing console ports.
This applies to all device components and component templates (except interfaces), not just console ports. Code to reproduce:
import requests
url='http://localhost:8000/api/dcim/console-ports/'
params = {
'limit': 200,
'offset': 0,
}
r = requests.get(url, params)
ids = [obj['id'] for obj in r.json()['results']]
params['offset'] = 200
r = requests.get(url, params)
for obj in r.json()['results']:
if obj['id'] in ids:
print("Duplicate ID: {}".format(obj['id']))
The issue here is that DeviceComponentManager.get_queryset() orders objects only by name, not by unique ID. This is fine when the list is filtered by device, but does not ensure deterministic ordering when the query includes objects with the same name. Nice catch!
Most helpful comment
This applies to all device components and component templates (except interfaces), not just console ports. Code to reproduce:
The issue here is that
DeviceComponentManager.get_queryset()orders objects only by name, not by unique ID. This is fine when the list is filtered by device, but does not ensure deterministic ordering when the query includes objects with the same name. Nice catch!