Rename DeviceRole to Role #1814

Closed
opened 2025-12-29 17:19:21 +01:00 by adam · 1 comment
Owner

Originally created by @jeremystretch on GitHub (Jun 26, 2018).

Issue type

[x] Feature request
[ ] Bug report
[ ] Documentation

Environment

  • Python version: 3.5.2
  • NetBox version: 2.3.4

Description

The dcim.DeviceRole model was originally used only for devices (hence its name), however since the introduction of virtualization modeling it is used for virtual machines as well. The name of the model should be changed to dcim.Role to reflect this. Additionally, the device_role field on the Device model should be renamed to role to be consistent with the new name and the VirtualMachine model.

It is worth noting that we will now have two models named Role: one in the DCIM app and one in IPAM. This shouldn't be problematic as the two are never used in conjunction (that I can recall). In any instance where both models are needed, we should be able to import them with local names. For example:

from dcim.models import Role as DCIMRole
from ipam.models import Role as IPAMRole
Originally created by @jeremystretch on GitHub (Jun 26, 2018). ### Issue type [x] Feature request <!-- An enhancement of existing functionality --> [ ] Bug report <!-- Unexpected or erroneous behavior --> [ ] Documentation <!-- A modification to the documentation --> ### Environment * Python version: 3.5.2 * NetBox version: 2.3.4 ### Description The `dcim.DeviceRole` model was originally used only for devices (hence its name), however since the introduction of virtualization modeling it is used for virtual machines as well. The name of the model should be changed to `dcim.Role` to reflect this. Additionally, the `device_role` field on the Device model should be renamed to `role` to be consistent with the new name and the VirtualMachine model. It is worth noting that we will now have two models named Role: one in the DCIM app and one in IPAM. This _shouldn't_ be problematic as the two are never used in conjunction (that I can recall). In any instance where both models are needed, we should be able to import them with local names. For example: ``` from dcim.models import Role as DCIMRole from ipam.models import Role as IPAMRole ```
adam added the type: housekeeping label 2025-12-29 17:19:21 +01:00
adam closed this issue 2025-12-29 17:19:21 +01:00
Author
Owner

@jeremystretch commented on GitHub (Dec 12, 2019):

After further thought, if anything it makes more sense to rename ipam.Role to e.g. PrefixRole, to match the other models (RackRole, ClusterRole, etc.). At this point it's not worth the hassle though, so I'll just close this out.

@jeremystretch commented on GitHub (Dec 12, 2019): After further thought, if anything it makes more sense to rename `ipam.Role` to e.g. `PrefixRole`, to match the other models (`RackRole`, `ClusterRole`, etc.). At this point it's not worth the hassle though, so I'll just close this out.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1814