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

Support the use of NetBox features by plugin models #8392

Closed
Tracked by #8333
jeremystretch opened this issue Jan 19, 2022 · 2 comments
Closed
Tracked by #8333

Support the use of NetBox features by plugin models #8392

jeremystretch opened this issue Jan 19, 2022 · 2 comments
Assignees
Labels
status: accepted This issue has been accepted for implementation topic: plugins Relates to the plugins framework type: feature Introduction of new functionality to the application
Milestone

Comments

@jeremystretch
Copy link
Member

jeremystretch commented Jan 19, 2022

NetBox version

v3.1.6

Feature type

New functionality

Proposed functionality

Officially support the use of various NetBox features by plugin models. These include:

  • Custom fields
  • Custom links
  • Custom validation
  • Export Templates
  • Journaling
  • Tags
  • Webhooks

For each feature above, we should introduce (or repurpose) a class which a model can inherit to enable the feature. For example, a TagsMixin class would enable the assignment of tags, and a CustomLinksMixin would enable custom links.

In the interest of cleanliness, we probably also want to introduce a base model class (e.g. BaseModel) that inherits all such feature mixins. A plugin model can then simply inherit from BaseModel to enable all features (while reserving the option to inherit only specific mixin classes if only a subset of features is desired).

I'd like to do away with the extras_features() decorator that's currently used to register features for specific models, as it's redundant for features which require additional fields or attributes on the model (see #8373). We may be able to leverage Django's class_prepared signal to automate this process.

Use case

This initiative will enable plugin authors to make use of many valuable features built into NetBox in a convenient and supported way.

Database changes

No response

External dependencies

No response

@jeremystretch jeremystretch added type: feature Introduction of new functionality to the application status: under review Further discussion is needed to determine this issue's scope and/or implementation topic: plugins Relates to the plugins framework labels Jan 19, 2022
@jeremystretch jeremystretch changed the title Support the user of NetBox features by plugin models Support the use of NetBox features by plugin models Jan 19, 2022
@jeremystretch jeremystretch added status: accepted This issue has been accepted for implementation and removed status: under review Further discussion is needed to determine this issue's scope and/or implementation labels Jan 19, 2022
@jeremystretch jeremystretch added this to the v3.2 milestone Jan 19, 2022
@jeremystretch jeremystretch self-assigned this Jan 19, 2022
@jeremystretch
Copy link
Member Author

I've made good progress with this already. Ditched the extras_features() decorator entirely, and refactored the base model classes. Still have some work to do, but I'm very encouraged by the results so far.

As this is the first major extension of the plugins framework since its introduction, I'm also going to be working on rebuilding the documentation. I've enlisted mkdocstrings for code introspection, which will help immensely. A rough working example is below.

Screenshot 2022-01-19 at 16-10-18 Model Features - NetBox Documentation

@jeremystretch
Copy link
Member Author

jeremystretch commented Jan 20, 2022

Extended the list above to include custom validation, and remove job results as a default feature.

jeremystretch added a commit that referenced this issue Jan 20, 2022
Closes #8392: Enable NetBox features for plugin models
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: accepted This issue has been accepted for implementation topic: plugins Relates to the plugins framework type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

1 participant