Browse Source

HUE-400. Beeswax sample installation assumes a `hue' user

* If the `hue' user doesn't exist, use the current user.
bc Wong 15 years ago
parent
commit
f432acaceb

+ 1 - 0
apps/beeswax/beeswax_server.sh

@@ -61,5 +61,6 @@ echo \$HADOOP_CONF_DIR=$HADOOP_CONF_DIR
 
 
 # Note: I've had trouble running this with just "java -jar" with the classpath
 # Note: I've had trouble running this with just "java -jar" with the classpath
 # determined with a seemingly appropriate find command.
 # determined with a seemingly appropriate find command.
+echo CWD=$(pwd)
 echo Executing $HADOOP_HOME/bin/hadoop jar $BEESWAX_JAR "$@"
 echo Executing $HADOOP_HOME/bin/hadoop jar $BEESWAX_JAR "$@"
 exec $HADOOP_HOME/bin/hadoop jar $BEESWAX_JAR "$@"
 exec $HADOOP_HOME/bin/hadoop jar $BEESWAX_JAR "$@"

+ 15 - 2
apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py

@@ -34,6 +34,7 @@ Expects 2 files in the beeswax.conf.LOCAL_EXAMPLES_DATA_DIR:
 
 
 import logging
 import logging
 import os
 import os
+import pwd
 import simplejson
 import simplejson
 
 
 from django.core.management.base import NoArgsCommand
 from django.core.management.base import NoArgsCommand
@@ -48,7 +49,19 @@ from beeswaxd.ttypes import BeeswaxException
 import hive_metastore.ttypes
 import hive_metastore.ttypes
 
 
 LOG = logging.getLogger(__name__)
 LOG = logging.getLogger(__name__)
-HADOOP_USER = 'hue'
+DEFAULT_INSTALL_USER = 'hue'
+
+def get_install_user():
+  """Use the DEFAULT_INSTALL_USER if it exists, else try the current user"""
+  try:
+    pwd.getpwnam(DEFAULT_INSTALL_USER)
+    return DEFAULT_INSTALL_USER
+  except KeyError:
+    pw_struct = pwd.getpwuid(os.geteuid())
+    LOG.info("Default sample installation user '%s' does not exist. Using '%s'"
+             % (DEFAULT_INSTALL_USER, pw_struct.pw_name))
+    return pw_struct.pw_name
+
 
 
 class InstallException(Exception):
 class InstallException(Exception):
   pass
   pass
@@ -137,7 +150,7 @@ def _make_query_msg(hql):
   Need to run query as a valid hadoop user. Use hue:supergroup
   Need to run query as a valid hadoop user. Use hue:supergroup
   """
   """
   query_msg = BeeswaxService.Query(query=hql, configuration=[])
   query_msg = BeeswaxService.Query(query=hql, configuration=[])
-  query_msg.hadoop_user = HADOOP_USER
+  query_msg.hadoop_user = get_install_user()
   return query_msg
   return query_msg