From 0b04001b15f31679476fecef925ee0d150ba9ec7 Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Thu, 23 Feb 2017 14:31:24 -0500 Subject: [PATCH 1/3] host may be None, account for that --- awx/main/utils/handlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/main/utils/handlers.py b/awx/main/utils/handlers.py index 874a5e6046..fe2fb87228 100644 --- a/awx/main/utils/handlers.py +++ b/awx/main/utils/handlers.py @@ -88,7 +88,7 @@ class BaseHTTPSHandler(logging.Handler): self.session.headers.update(headers) def get_http_host(self): - host = self.host + host = self.host or '' if not host.startswith('http'): host = 'http://%s' % self.host if self.port != 80 and self.port is not None: From 2953479dc8baddd76352586dbfe24f3baa729a92 Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Thu, 23 Feb 2017 14:31:47 -0500 Subject: [PATCH 2/3] 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 '' --- awx/main/conf.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/awx/main/conf.py b/awx/main/conf.py index bbdf159ae6..aaf0bc9694 100644 --- a/awx/main/conf.py +++ b/awx/main/conf.py @@ -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, ) From 50a8083984749714c21cd0dec755e9f7f280160b Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Thu, 23 Feb 2017 15:41:41 -0500 Subject: [PATCH 3/3] flake8 --- awx/main/conf.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/awx/main/conf.py b/awx/main/conf.py index aaf0bc9694..96c589e632 100644 --- a/awx/main/conf.py +++ b/awx/main/conf.py @@ -317,11 +317,13 @@ register( 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,