Browse Source

HUE-2271 [core] Make hue and hdfs usernames configurable in hue.ini

Suhas Satish 11 years ago
parent
commit
95e24ac0a5

+ 3 - 2
apps/beeswax/src/beeswax/server/hive_server2_lib.py

@@ -22,6 +22,7 @@ from operator import itemgetter
 
 
 from desktop.lib import thrift_util
 from desktop.lib import thrift_util
 from desktop.conf import LDAP_PASSWORD, LDAP_USERNAME
 from desktop.conf import LDAP_PASSWORD, LDAP_USERNAME
+from desktop.conf import DEFAULT_USER
 from hadoop import cluster
 from hadoop import cluster
 
 
 from TCLIService import TCLIService
 from TCLIService import TCLIService
@@ -43,7 +44,7 @@ from impala import conf as impala_conf
 LOG = logging.getLogger(__name__)
 LOG = logging.getLogger(__name__)
 
 
 IMPALA_RESULTSET_CACHE_SIZE = 'impala.resultset.cache.size'
 IMPALA_RESULTSET_CACHE_SIZE = 'impala.resultset.cache.size'
-
+DEFAULT_USER = DEFAULT_USER.get()
 
 
 class HiveServerTable(Table):
 class HiveServerTable(Table):
   """
   """
@@ -375,7 +376,7 @@ class HiveServerClient:
     }
     }
 
 
     if self.impersonation_enabled:
     if self.impersonation_enabled:
-      kwargs.update({'username': 'hue'})
+      kwargs.update({'username': DEFAULT_USER})
 
 
       if self.query_server['server_name'] == 'impala': # Only when Impala accepts it
       if self.query_server['server_name'] == 'impala': # Only when Impala accepts it
         kwargs['configuration'].update({'impala.doas.user': user.username})
         kwargs['configuration'].update({'impala.doas.user': user.username})

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

@@ -46,6 +46,12 @@
   ## server_user=hue
   ## server_user=hue
   ## server_group=hue
   ## server_group=hue
 
 
+  # This should be the Hue admin and proxy user
+  ## default_user=hue
+
+  # This should be the hadoop cluster admin
+  ## default_hdfs_superuser=hdfs
+
   # If set to false, runcpserver will not actually start the web server.
   # If set to false, runcpserver will not actually start the web server.
   # Used if Apache is being used as a WSGI container.
   # Used if Apache is being used as a WSGI container.
   ## enable_server=yes
   ## enable_server=yes

+ 6 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -55,6 +55,12 @@
   ## server_user=hue
   ## server_user=hue
   ## server_group=hue
   ## server_group=hue
 
 
+  # This should be the Hue admin and proxy user
+  ## default_user=hue
+
+  # This should be the hadoop cluster admin
+  ## default_hdfs_superuser=hdfs
+
   # If set to false, runcpserver will not actually start the web server.
   # If set to false, runcpserver will not actually start the web server.
   # Used if Apache is being used as a WSGI container.
   # Used if Apache is being used as a WSGI container.
   ## enable_server=yes
   ## enable_server=yes

+ 12 - 0
desktop/core/src/desktop/conf.py

@@ -392,6 +392,18 @@ SERVER_GROUP = Config(
   type=str,
   type=str,
   default="hue")
   default="hue")
 
 
+DEFAULT_USER = Config(
+  key="default_user",
+  help=_("This should be the user running hue webserver"),
+  type=str,
+  default="hue")
+
+DEFAULT_HDFS_SUPERUSER = Config(
+  key="default_hdfs_superuser",
+  help=_("This should be the hdfs super user"),
+  type=str,
+  default="hdfs")
+
 CUSTOM = ConfigSection(
 CUSTOM = ConfigSection(
   key="custom",
   key="custom",
   help=_("Customizations to the UI."),
   help=_("Customizations to the UI."),

+ 3 - 3
desktop/libs/hadoop/src/hadoop/fs/webhdfs.py

@@ -36,9 +36,9 @@ from hadoop.fs.webhdfs_types import WebHdfsStat, WebHdfsContentSummary
 from hadoop.conf import UPLOAD_CHUNK_SIZE
 from hadoop.conf import UPLOAD_CHUNK_SIZE
 
 
 import hadoop.conf
 import hadoop.conf
+import desktop.conf
 
 
-
-DEFAULT_HDFS_SUPERUSER = 'hdfs'
+DEFAULT_HDFS_SUPERUSER = desktop.conf.DEFAULT_HDFS_SUPERUSER.get()
 
 
 # The number of bytes to read if not specified
 # The number of bytes to read if not specified
 DEFAULT_READ_SIZE = 1024*1024 # 1MB
 DEFAULT_READ_SIZE = 1024*1024 # 1MB
@@ -50,7 +50,7 @@ class WebHdfs(Hdfs):
   """
   """
   WebHdfs implements the filesystem interface via the WebHDFS rest protocol.
   WebHdfs implements the filesystem interface via the WebHDFS rest protocol.
   """
   """
-  DEFAULT_USER = 'hue'        # This should be the user running Hue
+  DEFAULT_USER = desktop.conf.DEFAULT_USER.get()        # This should be the user running Hue
   TRASH_CURRENT = 'Current'
   TRASH_CURRENT = 'Current'
 
 
   def __init__(self, url,
   def __init__(self, url,

+ 2 - 1
desktop/libs/liboozie/src/liboozie/oozie_api.py

@@ -20,6 +20,7 @@ import threading
 
 
 
 
 from desktop.conf import TIME_ZONE
 from desktop.conf import TIME_ZONE
+from desktop.conf import DEFAULT_USER
 from desktop.lib.rest.http_client import HttpClient
 from desktop.lib.rest.http_client import HttpClient
 from desktop.lib.rest.resource import Resource
 from desktop.lib.rest.resource import Resource
 
 
@@ -31,7 +32,7 @@ from liboozie.utils import config_gen
 
 
 
 
 LOG = logging.getLogger(__name__)
 LOG = logging.getLogger(__name__)
-DEFAULT_USER = 'hue'
+DEFAULT_USER = DEFAULT_USER.get()
 API_VERSION = 'v1' # Overridden to v2 for SLA
 API_VERSION = 'v1' # Overridden to v2 for SLA
 
 
 _XML_CONTENT_TYPE = 'application/xml;charset=UTF-8'
 _XML_CONTENT_TYPE = 'application/xml;charset=UTF-8'