correct behavior of tower_uuid logging setting

* Register a default=function() with LOG_AGGREGATOR_TOWER_UUID. We know
this function will ONLY be called when there is no database backed
settings. Therefore, we set a one-time uuid at this time.
* The user is free to change LOG_AGGREGATOR_TOWER_UUID.
* The user may not set this field to null
* The user may not set this field to ''
This commit is contained in:
Chris Meyers 2017-02-23 14:31:47 -05:00
parent 0b04001b15
commit 2953479dc8

View File

@ -2,9 +2,11 @@
import json
import logging
import os
import uuid
# Django
from django.utils.translation import ugettext_lazy as _
from django.conf import settings
# Tower
from awx.conf import fields, register
@ -314,13 +316,18 @@ register(
category=_('Logging'),
category_slug='logging',
)
def init_LOG_AGGREGATOR_TOWER_UUID():
unique_id = uuid.uuid4()
settings.LOG_AGGREGATOR_TOWER_UUID = unique_id
return unique_id
register(
'LOG_AGGREGATOR_TOWER_UUID',
field_class=fields.CharField,
allow_blank=True,
label=_('Cluster-wide Tower unique identifier.'),
help_text=_('Useful to uniquely identify Tower instances.'),
category=_('Logging'),
category_slug='logging',
default=None,
default=init_LOG_AGGREGATOR_TOWER_UUID,
)