Эх сурвалжийг харах

HUE-4937 [core] Set audit_event_log_dir and audit_max_log_file_size config values from Navigator conf if found

Jenny Kim 9 жил өмнө
parent
commit
5c7f7caa4d

+ 3 - 0
desktop/conf.dist/hue.ini

@@ -1532,3 +1532,6 @@
     # e.g. Used for LDAP/PAM pass-through authentication.
     # e.g. Used for LDAP/PAM pass-through authentication.
     ## auth_username=hue
     ## auth_username=hue
     ## auth_password=
     ## auth_password=
+
+    # Execute this script to produce the auth password. This will be used when `auth_password` is not set.
+    ## auth_password_script=

+ 4 - 1
desktop/conf/pseudo-distributed.ini.tmpl

@@ -1528,7 +1528,7 @@
 
 
   [[navigator]]
   [[navigator]]
     # For tagging tables, files and getting lineage of data.
     # For tagging tables, files and getting lineage of data.
-    # Navigator API URL with version (without version suffix)
+    # Navigator API URL (without version suffix)
     ## api_url=http://localhost:7187/api
     ## api_url=http://localhost:7187/api
 
 
     # Navigator API HTTP authentication username and password
     # Navigator API HTTP authentication username and password
@@ -1536,3 +1536,6 @@
     # e.g. Used for LDAP/PAM pass-through authentication.
     # e.g. Used for LDAP/PAM pass-through authentication.
     ## auth_username=hue
     ## auth_username=hue
     ## auth_password=
     ## auth_password=
+
+    # Execute this script to produce the auth password. This will be used when `auth_password` is not set.
+    ## auth_password_script=

+ 8 - 3
desktop/core/src/desktop/conf.py

@@ -30,6 +30,11 @@ from desktop.lib.conf import Config, ConfigSection, UnspecifiedConfigSection,\
                              coerce_password_from_script
                              coerce_password_from_script
 from desktop.lib.i18n import force_unicode
 from desktop.lib.i18n import force_unicode
 from desktop.lib.paths import get_desktop_root
 from desktop.lib.paths import get_desktop_root
+from metadata.metadata_sites import get_navigator_server_url, get_navigator_audit_log_dir, \
+                                    get_navigator_audit_max_file_size
+
+
+LOG = logging.getLogger(__name__)
 
 
 
 
 def coerce_database(database):
 def coerce_database(database):
@@ -1144,18 +1149,19 @@ MEMORY_PROFILER = Config(
   type=coerce_bool,
   type=coerce_bool,
   default=False)
   default=False)
 
 
+
 AUDIT_EVENT_LOG_DIR = Config(
 AUDIT_EVENT_LOG_DIR = Config(
   key="audit_event_log_dir",
   key="audit_event_log_dir",
   help=_("The directory where to store the auditing logs. Auditing is disable if the value is empty."),
   help=_("The directory where to store the auditing logs. Auditing is disable if the value is empty."),
   type=str,
   type=str,
-  default=""
+  dynamic_default=get_navigator_audit_log_dir
 )
 )
 
 
 AUDIT_LOG_MAX_FILE_SIZE = Config(
 AUDIT_LOG_MAX_FILE_SIZE = Config(
   key="audit_log_max_file_size",
   key="audit_log_max_file_size",
   help=_("Size in KB/MB/GB for audit log to rollover."),
   help=_("Size in KB/MB/GB for audit log to rollover."),
   type=str,
   type=str,
-  default="100MB"
+  dynamic_default=get_navigator_audit_max_file_size
 )
 )
 
 
 DJANGO_SERVER_EMAIL = Config(
 DJANGO_SERVER_EMAIL = Config(
@@ -1247,7 +1253,6 @@ def validate_database():
 
 
   from django.db import connection
   from django.db import connection
 
 
-  LOG = logging.getLogger(__name__)
   res = []
   res = []
 
 
   if connection.vendor == 'mysql':
   if connection.vendor == 'mysql':

+ 4 - 0
desktop/libs/metadata/src/metadata/conf.py

@@ -35,6 +35,7 @@ def get_auth_password():
     return password
     return password
   return DEFAULT_AUTH_PASSWORD.get()
   return DEFAULT_AUTH_PASSWORD.get()
 
 
+
 def default_navigator_config_dir():
 def default_navigator_config_dir():
   """Get from usual main Hue config directory"""
   """Get from usual main Hue config directory"""
   return get_config_root()
   return get_config_root()
@@ -49,12 +50,15 @@ def default_navigator_url():
 def get_optimizer_url():
 def get_optimizer_url():
   return OPTIMIZER.API_URL.get() and OPTIMIZER.API_URL.get().strip('/')
   return OPTIMIZER.API_URL.get() and OPTIMIZER.API_URL.get().strip('/')
 
 
+
 def has_optimizer():
 def has_optimizer():
   return bool(get_optimizer_url())
   return bool(get_optimizer_url())
 
 
+
 def get_navigator_url():
 def get_navigator_url():
   return NAVIGATOR.API_URL.get() and NAVIGATOR.API_URL.get().strip('/')[:-3]
   return NAVIGATOR.API_URL.get() and NAVIGATOR.API_URL.get().strip('/')[:-3]
 
 
+
 def has_navigator():
 def has_navigator():
   return bool(get_navigator_url() and NAVIGATOR.AUTH_PASSWORD.get())
   return bool(get_navigator_url() and NAVIGATOR.AUTH_PASSWORD.get())
 
 

+ 10 - 6
desktop/libs/metadata/src/metadata/metadata_sites.py

@@ -19,8 +19,6 @@ import errno
 import logging
 import logging
 import os
 import os
 
 
-from metadata.conf import NAVIGATOR
-
 
 
 LOG = logging.getLogger(__name__)
 LOG = logging.getLogger(__name__)
 
 
@@ -32,7 +30,6 @@ _CONF_NAVIGATOR_AUDIT_LOG_DIR = 'audit_event_log_dir'
 _CONF_NAVIGATOR_AUDIT_MAX_FILE_SIZE = 'navigator.audit_log_max_file_size'
 _CONF_NAVIGATOR_AUDIT_MAX_FILE_SIZE = 'navigator.audit_log_max_file_size'
 
 
 
 
-
 def reset():
 def reset():
   global _SITE_DICT
   global _SITE_DICT
   _SITE_DICT = None
   _SITE_DICT = None
@@ -44,18 +41,25 @@ def get_conf(name='navigator'):
   return _SITE_DICT[name]
   return _SITE_DICT[name]
 
 
 
 
-
 def get_navigator_server_url():
 def get_navigator_server_url():
+  """Returns the navigator.server.url"""
   return get_conf().get(_CONF_NAVIGATOR_SERVER_URL, 'http://localhost:7187')
   return get_conf().get(_CONF_NAVIGATOR_SERVER_URL, 'http://localhost:7187')
 
 
+
 def get_navigator_audit_log_dir():
 def get_navigator_audit_log_dir():
-  return get_conf().get(_CONF_NAVIGATOR_AUDIT_LOG_DIR)
+  """Returns audit_event_log_dir"""
+  return get_conf().get(_CONF_NAVIGATOR_AUDIT_LOG_DIR, '')
+
 
 
 def get_navigator_audit_max_file_size():
 def get_navigator_audit_max_file_size():
-  return get_conf().get(_CONF_NAVIGATOR_AUDIT_MAX_FILE_SIZE, '100')
+  """Returns navigator.audit_log_max_file_size in MB"""
+  size = get_conf().get(_CONF_NAVIGATOR_AUDIT_MAX_FILE_SIZE, '100')
+  return '%sMB' % size.strip() if size else "100MB"
 
 
 
 
 def _parse_sites():
 def _parse_sites():
+  from metadata.conf import NAVIGATOR
+
   global _SITE_DICT
   global _SITE_DICT
   _SITE_DICT ={}
   _SITE_DICT ={}