Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a generic Role model #1063

Closed
dgarros opened this issue Nov 8, 2021 · 7 comments · Fixed by #2822, #2884, #2885, #2911 or #2990
Closed

Add a generic Role model #1063

dgarros opened this issue Nov 8, 2021 · 7 comments · Fixed by #2822, #2884, #2885, #2911 or #2990
Assignees
Labels
type: feature Introduction of new or enhanced functionality to the application
Milestone

Comments

@dgarros
Copy link
Contributor

dgarros commented Nov 8, 2021

Environment

  • Python version: 3.77
  • Nautobot version: 1.1.4

Proposed Functionality

Add a generic Role model, similar to Status to avoid creating multiple models that are describing pretty much the same things.
Currently in Core, we are leveraging roles in multiple places :

  • Dynamic based on database model : ipam:Role, dcim:DeviceRole, dcim: RackRole
  • Static : ipam ? IPAddressRoleChoices

I wouldn't be surprised if we are using roles in more places

Use Case

  • Improve the user experience by allowing users to manage roles in a single place.
  • Reduce the effort to add role to more models, as part of core or as part of a plugin
  • Allow static role to become dynamic.

Database Changes

Yes
At a minimum we need to add a new role model, most likely as part of Extras that will be very similar to Status.
At some point, it would be good to migrate all existing roles to this new model but it would most likely be a breaking change

External Dependencies

No

@jathanism
Copy link
Contributor

Yeah we talked about this back pre-1.0 for things like "profiles" e.g. "interface profiles" but just using roles generically. I'm a fan.

@jathanism jathanism added type: feature Introduction of new or enhanced functionality to the application workflow: under review labels Nov 9, 2021
@glennmatthews
Copy link
Contributor

This would probably be difficult to implement in a non-breaking / backwards compatible way. Need to consider impact to the REST API, plugins potentially consuming these data models, etc.

Setting that aside, it would be worth looking at whether we even need separate data models for "status" and "role" or whether these are just two different groupings/uses of the same generic model type behind the scenes? (In theory even "tag" could be subsumed into this as well...)

Currently we're leaning towards targeting this as a 2.x feature - not to rule out implementing it before then if these sorts of concerns can be addressed in a backwards-compatible way.

@dgarros
Copy link
Contributor Author

dgarros commented Nov 30, 2021

Understood, retrofitting the existing models wouldn't be backward compatible

It might be possible to introduce the new Role model first, to allow plugins to leverage it and retrofit the existing models later as part of a major release.

@jvanderaa
Copy link
Contributor

This is probably something that could be implemented across the boards, including supplanting Location Type. @bryanculver

@bryanculver bryanculver mentioned this issue Nov 1, 2022
6 tasks
@bryanculver bryanculver added this to the v2.0.0 milestone Nov 3, 2022
@Kircheneer
Copy link
Contributor

I can also see use in this as a feature for plugin developers, if all I need is an extendable list of possible types otherwise I would have to define a custom model with lots of extra overhead, if we had this and it was extendable to plugin models that could save me as a plugin developer some time. One example from a currently open-sourced plugin would be nautobot_bgp_models.models.PeeringRole, this is a very simple model without custom logic that just provides an extendable role field.

@glennmatthews
Copy link
Contributor

Another candidate model for rolling into a generic Role would be the CircuitType model.

@glennmatthews
Copy link
Contributor

Implemented for 2.0 by #2822.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.