netbox-community / netbox

The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/free-netbox-cloud/
http://netboxlabs.com/oss/netbox/
Apache License 2.0
16.15k stars 2.58k forks source link

Negation filter not working for cables - termination type #14394

Closed amk1969 closed 7 months ago

amk1969 commented 11 months ago

NetBox version

v3.6.6

Python version

3.8

Steps to Reproduce

Connect cables between different endpoint types. List cables of one type connected to a device List cables of the other types connected to a device

Expected Behavior

Filter expression termination_a_type__n should return cables with termination type other than queried.

Observed Behavior

Filter expression termination_a_type__n returns the same result as termination_a_type

amk1969 commented 11 months ago

Encountered a problem to determine type of a cable endpoint. Is there a property that would return termination_type of a particular cable object? With pynetbox I am getting the interface/console object itself, is there a way to get the value of 'object_type' used to create the cable?

Trying to workaround the above problem, I try to enumerate cables of various types. Here I found the problem when trying to confirm there is no cable connected to other endpoint than interface or console. Issue is reproducible also with current demo version, queries like https://demo.netbox.dev/dcim/cables/?device=mysampledevice1&termination_a_type=dcim.consoleport and https://demo.netbox.dev/dcim/cables/?device=mysampledevice1&termination_a_type__n=dcim.consoleport return the same results.

Could this be related to https://github.com/netbox-community/netbox/issues/11819 ?

Attached script reproduces the issue in the demo instance. cables-by-type.txt

github-actions[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

jeremystretch commented 7 months ago

Beginning with NetBox v3.7.0, the object type-specific cable termination filters introduced in #14434 should be used, as the generic filters (termination_a_type & termination_b_type) are inherently very limited in their functionality.