Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pynetbox/models/dcim.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@
from pynetbox.core.endpoint import DetailEndpoint, RODetailEndpoint
from pynetbox.core.query import Request
from pynetbox.core.response import JsonField, Record
from pynetbox.models.circuits import Circuits
from pynetbox.models.circuits import Circuits, CircuitTerminations
from pynetbox.models.ipam import IpAddresses


class TraceableRecord(Record):
def _get_obj_class(self, url):
uri_to_obj_class_map = {
"circuits/circuit-terminations": CircuitTerminations,
"dcim/cables": Cables,
"dcim/console-ports": ConsolePorts,
"dcim/console-server-ports": ConsoleServerPorts,
"dcim/front-ports": FrontPorts,
"dcim/interfaces": Interfaces,
"dcim/power-feeds": PowerFeeds,
"dcim/power-outlets": PowerOutlets,
"dcim/power-ports": PowerPorts,
"dcim/rear-ports": RearPorts,
}

Expand Down Expand Up @@ -154,6 +160,10 @@ class Interfaces(TraceableRecord):
interface_connection = InterfaceConnection


class PowerFeeds(TraceableRecord):
Copy link
Member

@jnovinger jnovinger May 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably my lack of pynetbox knowledge showing through, but why do we need a separate sub-class of TraceAbleRecord for PowerFeeds? Is there some reason that the addition to uri_to_obj_class_map is not sufficient?

If it is required, i Is there a reason it's body is just pass versus some other configuration declaration?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there are any sub-objects needs to be set to the correct type, it is like Cables or InterfaceConnection. Those have to set __str but PowerFeed has name field which is the default str.

pass


class PowerOutlets(TraceableRecord):
device = Devices

Expand Down
3 changes: 2 additions & 1 deletion pynetbox/models/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
DeviceTypes,
FrontPorts,
Interfaces,
PowerFeeds,
PowerOutlets,
PowerPorts,
RackReservations,
Expand Down Expand Up @@ -48,7 +49,7 @@
"dcim.modulebaytemplate": None,
"dcim.moduletype": None,
"dcim.platform": None,
"dcim.powerfeed": None,
"dcim.powerfeed": PowerFeeds,
"dcim.poweroutlet": PowerOutlets,
"dcim.poweroutlettemplate": None,
"dcim.powerpanel": None,
Expand Down