Refactor #2109
closedLoad Django DB settings from server.conf
100%
Description
This was a checklist item for #2086, but doesn't need to block the completion of that issue.
The django settings for postgres should be loaded from pulp's server.conf, if possible, similar to how we're loading mongo settings now.
Related issues
Updated by semyers over 8 years ago
- Blocked by Task #2086: add django DB boilerplate added
Updated by amacdona@redhat.com over 8 years ago
- Tracker changed from Issue to Refactor
Updated by mhrivnak over 8 years ago
- Groomed changed from No to Yes
- Sprint Candidate changed from No to Yes
Updated by jcline@redhat.com over 8 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to jcline@redhat.com
Updated by jcline@redhat.com over 8 years ago
I've been familiarizing myself with Django's various settings and I'm on the fence about whether we should stick with the INI-style configuration or whether we should switch to YAML. The reason is some configuration options for Django are nested dictionaries or lists of lists. For example, a multi-database Django configuration looks like
DATABASES = {
'default': {},
'auth_db': {
'NAME': 'auth_db',
'ENGINE': 'django.db.backends.mysql',
'USER': 'mysql_user',
'PASSWORD': 'swordfish',
},
'primary': {
'NAME': 'primary',
'ENGINE': 'django.db.backends.mysql',
'USER': 'mysql_user',
'PASSWORD': 'spam',
},
'replica1': {
'NAME': 'replica1',
'ENGINE': 'django.db.backends.mysql',
'USER': 'mysql_user',
'PASSWORD': 'eggs',
},
'replica2': {
'NAME': 'replica2',
'ENGINE': 'django.db.backends.mysql',
'USER': 'mysql_user',
'PASSWORD': 'bacon',
},
}
and a logging configuration looks like
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'simple': {'format': 'pulp: %(name)s:%(levelname)s: %(message)s'},
},
'handlers': {
'syslog': {
'address': '/dev/log',
'facility': 'pulp.server.logs.CompliantSysLogHandler.LOG_DAEMON',
'class': 'pulp.server.logs.CompliantSysLogHandler',
'formatter': 'simple',
},
},
'loggers': {
'pulp.platform': {
'handlers': ['syslog'],
'level': 'INFO',
},
}
},
If you want to configure email notifications for certain events, the emails are in the format
ADMINS = [
(<name>, <email>),
]
All of these could be translated to INI-style configurations, but I'm wondering if they'll be more complex than using YAML (from both a user and a developer perspective).
I am imagining having the databases be defined in several sections that start with the prefix 'database_<name>', for example
[database_auth_db]
name: 'auth_db'
user: 'pulp'
password: 'hunter2'
[database_primary]
name: 'primary'
user: 'postgres'
password: 'test'
host: 10.10.10.10
...
versus
databases:
auth_db:
name: auth_db
user: pulp
password: hunter2
primary:
name: primary
user: postgres
password: test
host: 10.10.10.10
The downside is we'd depend on PyYAML (although we might have to already), and we don't get the automagic merging of configparser, but maybe it's still worth it. Does anyone have opinions one way or the other?
Updated by jcline@redhat.com over 8 years ago
- Status changed from ASSIGNED to POST
https://github.com/pulp/pulp/pull/2710 is one way we could do things
Updated by semyers about 8 years ago
- Related to Task #2226: Rename pulp.platform to pulp.app added
Added by Jeremy Cline about 8 years ago
Added by Jeremy Cline about 8 years ago
Revision f4c369b6 | View on GitHub
Add a new settings file for Django
In order to allow for easy configuration, this patch loads settings from
/etc/pulp/server.yaml
, merges them with default settings for Pulp, and
then applies them to settings.py (which is in turn merged with the
global default settings).
fixes #2109
Updated by Anonymous about 8 years ago
- Status changed from POST to MODIFIED
- % Done changed from 0 to 100
Applied in changeset pulp|f4c369b6c9f2d087b182f0f22ade48ae880cb8e5.
Updated by bmbouter almost 5 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Add a new settings file for Django
In order to allow for easy configuration, this patch loads settings from
/etc/pulp/server.yaml
, merges them with default settings for Pulp, and then applies them to settings.py (which is in turn merged with the global default settings).fixes #2109