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 ability to store configuration settings in the database #370
Comments
Hmm, I like this idea. It seems to me there are a lot of settings that could be stored in a database configuration that don't affect the operation of the service, that could be moved here. I'm thinking of settings like Could you please elaborate on your use-case so that we can consider how this might be implemented and how we can justify the means to the end? |
I'm thinking from the description that one of the models used in a plugin that I worked on would be able to benefit from it. Basically that there could only be one representation for each of the particular apps. I can explain what was done in some more detail as well |
Related to #541 in that we should provide a clear delineation between database storage of non-sensitive configuration data versus more secure ways of storing and managing sensitive data such as credentials and tokens. |
Being how closely related to #580 this is, we should probably consolidate around this issue, but make it such that the plugin API can leverage patterns defined here (which is also stated in the description provided by @itdependsnetworks ). @itdependsnetworks @jvanderaa we reviewed this last week and would like some feedback to drive the initial implementation. Initially, it would not include storing any credentials in the "settings." That would stay as-is, e.g. in the config. This will change as we progress on #541 We also discussed limiting it to (a) basic key-value pairs more akin to environment variables (b) storing JSON vs. (c) modeling just what's possible in the custom field framework (so as that expands, this would as well). Could you provide further thoughts and feedback based on your use cases? |
As I look at the future of plugins if every plugin has its settings in the UI there would be menu items for each of them. The thought is to have a consolidated settings page provided by Nautobot to house all of the settings for any plugin that would have settings. This way the UI is kept clean and there is a consistent method for providing the settings from plugin to plugin. Having 5 plugins, and 5 different settings pages will likely clutter the UI some. |
Makes sense. We're really looking for the next level of feedback. It's what I was getting at here:
Add a (d) future could even be a JSON Schema definition that generates JSON forms. Can you comment on these options as viable options for plugins you've developed? |
I would be leaning towards (B) to have all of the settings available in the UI. The Onboarding Plugin stands out that would benefit being able to have a key-value mapping available for a sub setting, specifically in the platform map setting. (B) also covers (a) for the basic key value pairs. |
I had more advance use case then just a key/value store, such as linking to the a Git Repository. The following code will describe all of the actual use cases I have already had where I went with the singleton pattern: Additionally, I could have pursued doing the following in the configuration settings as well: https://github.com/nautobot/nautobot-plugin-golden-config/blob/d928ce9da926976f4ad96d99daabb0941ba66a20/nautobot_golden_config/__init__.py#L21-L29 |
It looks like both of these libraries are oriented around managing settings via the Django admin views, for what it's worth. |
Based on what we recently added within #768 with the plans to add JSON to CFs, modeling what we have for CFs for this seems to make sense. It give us text, integer, boolean, date, URL, selection, multiple selection with validation rules for settings. |
Just in the interest of clarity, when I state Git Repository, I am referring to the Django ORM object type |
Brainstorming - global configuration (BANNER_TOP, BANNER_BOTTOM, etc.) probably would make sense to manage under django-admin (possibly with django-solo or django-constance), whereas plugin configs (#580) probably makes sense as a (single) menu item under the Plugins menu as we may want non-admin users to be able to manage plugin configuration. |
based on my experience, It's been useful to have BANNER_TOP, BANNER_BOTTOM defined in the configuration because we can assign it different value based on the environment Prod , Test, Dev etc ... and still easily import the database from prod to dev etc .. |
Fair point @dgarros! That's a general problem with this approach any storage of configuration in the DB - we'll be intermingling application configuration with application data, and there are any number of cases where that might not be desirable. Thinking about this some more, a number of plugins (circuit-maintenance, chatops for examples) have configuration patterns that are better served by a dedicated database table, because they have a need for N configuration entries (access grants for chatops, notification sources for circuit-maintenance, etc) - these plugins would not benefit from a singleton design because it simply doesn't match how they need to be configured. Similarly, settings like the onboarding plugin platform mappings, if desirable to store in the database, would IMHO be better implemented as a small dedicated table rather than as a JSON field in a singleton object. For cases like the golden-config plugin, where there are a number of unique configuration keys, each with exactly one value, a singleton pattern for that specific plugin makes sense, but this would still typically be a different model/table for this plugin than for any other plugin. In conclusion I find myself questioning what generic functionality in Nautobot core would make sense to add/include that wouldn't be better solved by a plugin-specific implementation that addresses the particular configuration needs of that plugin directly. |
@dgarros do you have any opinion on what core parameters should be stored in the database? |
@jedelman8 it's a hard question, I can see only a few core parameters that could be useful to have in the database
|
Thanks! Storing |
Two prominent solutions:
I would say if we want a rigid data model for the configuration we go with |
+1 for django-constance We use it at work and we are happy with it. |
See #1079. |
Environment
Proposed Functionality
Provide some amount of settings via a singleton pattern.
Use Case
In developing the golden config plugin, I have settings that requires only a single instance in a database. Provide a pattern for singletons with configuration. This should include core, but a pattern for plugins too.
Database Changes
Not directly
External Dependencies
It could make sense to leverage a library, such as django-solo or django-constance.
The text was updated successfully, but these errors were encountered: