Add 'get_cable_peer()' data in CableTerminations inheritors (FrontPort, RearPort...) API #2897

Closed
opened 2025-12-29 18:23:13 +01:00 by adam · 4 comments
Owner

Originally created by @coloHsq on GitHub (Sep 23, 2019).

Environment

  • Python version: 3.6.5
  • NetBox version: 2.6.3

Proposed Functionality

At the moment the only way to know where a CableTermination is directly connected (cable peer) is to look up in the cable API.
It would be great to have this information directly in the CableTerminations inheritors API, like the 'connected_endpoint' for Interfaces, PowerPort, PowerOutlet... , but showing the cable peer

Use Case

Like said before, to compile a list like "term_a, cable, term_b", starting from a device, I have to do at least two API calls, one for get all the 'local terminations' (related to a single device) and one to get all the cables to check for the 'remote termination' like in get_cable_peer() method in the Cable model.
Plus the whole logic to initially compile the list only with 'local termination' and cable, and then add, where present, the 'remote termination'.

Having those data directly in the API related to terminations would make everything much simpler and more immediate.

Database Changes

I could be wrong but there should be no changes.

External Dependencies

None

Originally created by @coloHsq on GitHub (Sep 23, 2019). ### Environment * Python version: 3.6.5 * NetBox version: 2.6.3 ### Proposed Functionality At the moment the only way to know where a CableTermination is directly connected (cable peer) is to look up in the cable API. It would be great to have this information directly in the CableTerminations inheritors API, like the 'connected_endpoint' for Interfaces, PowerPort, PowerOutlet... , but showing the cable peer ### Use Case Like said before, to compile a list like "term_a, cable, term_b", starting from a device, I have to do at least two API calls, one for get all the 'local terminations' (related to a single device) and one to get all the cables to check for the 'remote termination' like in get_cable_peer() method in the Cable model. Plus the whole logic to initially compile the list only with 'local termination' and cable, and then add, where present, the 'remote termination'. Having those data directly in the API related to terminations would make everything much simpler and more immediate. ### Database Changes I could be wrong but there should be no changes. ### External Dependencies None
adam added the pending closure label 2025-12-29 18:23:13 +01:00
adam closed this issue 2025-12-29 18:23:13 +01:00
Author
Owner

@jeremystretch commented on GitHub (Oct 17, 2019):

Sorry, I'm not following. Could you please provide a concrete example of the data as it is currently provided and your proposed modifications?

@jeremystretch commented on GitHub (Oct 17, 2019): Sorry, I'm not following. Could you please provide a concrete example of the data as it is currently provided and your proposed modifications?
Author
Owner

@coloHsq commented on GitHub (Oct 22, 2019):

Hoping this is more clear :

Using this API call "https://netbox.foo.bar/api/dcim/front-ports/?device_id=314", that's the result (single front port from the array)

{
	"id": 5749,
	"device": {
		"id": 314,
		"url": "https://netbox.foo.bar/api/dcim/devices/314/",
		"name": "RX2A-W1.SM[1-24]#1",
		"display_name": "RX2A-W1.SM[1-24]#1"
	},
	"name": "01",
	"type": {
		"value": 2300,
		"label": "LC"
	},
	"rear_port": {
		"id": 705,
		"url": "https://netbox.foo.bar/api/dcim/rear-ports/705/",
		"name": "back"
	},
	"rear_port_position": 1,
	"description": "",
	"cable": {
		"id": 7047,
		"url": "https://netbox.foo.bar/api/dcim/cables/7047/",
		"label": ""
	},
	"tags": []
}

As you can see, there's no info about the direct connection of a front port, same for rear ports, interfaces, power ports...

It would be great to have the cable peer data in API response with the same format used for the connected endpont data:

That's the extrapolation of the connected_endpoint from an API call to "https://netbox.foo.bar/api/dcim/interfaces/?device_id=xxx"

"connected_endpoint_type": "dcim.interface",
"connected_endpoint": {
	"id": 25130,
	"url": "https://netbox.foo.bar/api/dcim/interfaces/25130/",
	"device": {
	  "id": 4292,
	  "url": "https://netbox.foo.bar/api/dcim/devices/4292/",
	  "name": "eudata-esx01",
	  "display_name": "eudata-esx01"
	},
	"name": "iLO",
	"cable": 3816,
	"connection_status": {
	  "value": true,
	  "label": "Connected"
	}
},

So, the hypothetical addition needed in the first API response shown above, could be something like:

"cable_peer_type": ' cable_peer_type ',
"cable_peer": {
	"id": xxx,
	"url": "https://netbox.foo.bar/api/dcim/'type'/xxx/",
	"device": {
	  "id": xxx,
	  "url": "https://netbox.foo.bar/api/dcim/devices/xxx/",
	  "name": "rnd_device",
	  "display_name": "rnd_device"
	},
	"name": "rnd_port",
	"cable": xxx,
	"connection_status": {
	  "value": true,
	  "label": "Connected"
	}
},

The final result of this whole request would be the possibility to have the cable peer data (where a port is directly linked) in every CableTermination() inheritor

@coloHsq commented on GitHub (Oct 22, 2019): Hoping this is more clear : Using this API call "https://netbox.foo.bar/api/dcim/front-ports/?device_id=314", that's the result (single front port from the array) { "id": 5749, "device": { "id": 314, "url": "https://netbox.foo.bar/api/dcim/devices/314/", "name": "RX2A-W1.SM[1-24]#1", "display_name": "RX2A-W1.SM[1-24]#1" }, "name": "01", "type": { "value": 2300, "label": "LC" }, "rear_port": { "id": 705, "url": "https://netbox.foo.bar/api/dcim/rear-ports/705/", "name": "back" }, "rear_port_position": 1, "description": "", "cable": { "id": 7047, "url": "https://netbox.foo.bar/api/dcim/cables/7047/", "label": "" }, "tags": [] } As you can see, there's no info about the direct connection of a front port, same for rear ports, interfaces, power ports... It would be great to have the cable peer data in API response with the same format used for the connected endpont data: That's the extrapolation of the connected_endpoint from an API call to "https://netbox.foo.bar/api/dcim/interfaces/?device_id=xxx" "connected_endpoint_type": "dcim.interface", "connected_endpoint": { "id": 25130, "url": "https://netbox.foo.bar/api/dcim/interfaces/25130/", "device": { "id": 4292, "url": "https://netbox.foo.bar/api/dcim/devices/4292/", "name": "eudata-esx01", "display_name": "eudata-esx01" }, "name": "iLO", "cable": 3816, "connection_status": { "value": true, "label": "Connected" } }, So, the hypothetical addition needed in the first API response shown above, could be something like: "cable_peer_type": ' cable_peer_type ', "cable_peer": { "id": xxx, "url": "https://netbox.foo.bar/api/dcim/'type'/xxx/", "device": { "id": xxx, "url": "https://netbox.foo.bar/api/dcim/devices/xxx/", "name": "rnd_device", "display_name": "rnd_device" }, "name": "rnd_port", "cable": xxx, "connection_status": { "value": true, "label": "Connected" } }, The final result of this whole request would be the possibility to have the cable peer data (where a port is directly linked) in every CableTermination() inheritor
Author
Owner

@stale[bot] commented on GitHub (Dec 6, 2019):

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. Please see our contributing guide.

@stale[bot] commented on GitHub (Dec 6, 2019): 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. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@stale[bot] commented on GitHub (Dec 13, 2019):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@stale[bot] commented on GitHub (Dec 13, 2019): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2897