Closed pspdbx closed 2 years ago
Filtering by rack name is not supported because rack names need not be unique. For example, filtering by ?rack=R101
would return devices belonging to any rack named R101, at any site. You could also limit the query by assigned site, but at that point it's more efficient to specify the rack by ID anyway.
That makes sense, thank you @jeremystretch . Would adding a field for fqrack to the Rack
model make sense? A fully qualified rack name that is guaranteed to be unique across all Sites.
No, that wouldn't make any sense.
Ack, thanks for reviewing the request!
NetBox version
2.11.2
Feature type
New functionality
Proposed functionality
To iterate over the Devices in a rack, the only way to do it currently is
nb.dcim.devices.filter(role="server", rack_id=<rack id integer>)
, wherenb
is an instance of pynetbox client.It requires tools that interact with Netbox make an additional call to check if the rack exists, and if it does, get its ID.
Proposed functionality:
nb.dcim.devices.filter(role="server", rack=<rack name string>)
is far easier to read and adopt.Use case
In many of datacenter automation workflows (think provisioning, dns/dhcp config gen, ip allocation etc.), it is common to iterate over racks. While I'm very glad there is a model in Netbox for Rack, it would be a huge benefit to be able to filter on
Device
based on rack name, without making additional calls to Netbox to fetch the rack ID.Database changes
None required.
External dependencies
None.