title: 'Hue API: Execute some builtin or shell commands' author: admin type: post date: 2015-02-08T01:02:56+00:00 url: /hue-api-execute-some-builtin-commands/ sf_thumbnail_type:
Last update: March 3rd 2016
Hue comes with a set of commands for simplifying the management of the service. Here is a quick guide about how to use them.
If using CM, export this variable in order to point to the correct Hue:
cd /opt/cloudera/parcels/CDH/lib/
HUE_CONF_DIR=/var/run/cloudera-scm-agent/process/-hue-HUE_SERVER-id
echo $HUE_CONF_DIR
export HUE_CONF_DIR
Where is the most recent ID in that process directory for hue-HUE_SERVER.
If not using CM, just append the root of Hue home, normally:
/usr/lib/hue
Note:
You might need to have access to a local directory for the logs of the command, e.g.:
cd /tmp
Starting in Cloudera Manager 5.5 passwords are not stored in configuration files in clear text anymore. As a result on Cloudera Manager 5.5 and higher you will need to know the password for Hue's DB connection to be able to run the Hue command line.
ls -1 /var/run/cloudera-scm-agent/process | grep HUE | sort -n | tail -1"
<li style="font-weight: 400;">
<span style="font-weight: 400;">HUE_DATABASE_PASSWORD=<dbpassword></span><span style="font-weight: 400;"> - This defines the password Hue should use to connect to the DB.</span>
</li>
<li style="font-weight: 400;">
<span style="font-weight: 400;">HUE_IGNORE_PASSWORD_SCRIPT_ERRORS=1</span><span style="font-weight: 400;"> - This configures the Hue command line to run even if there are other unknown passwords defined in the Cloudera Manager created </span><span style="font-weight: 400;">hue.ini</span><span style="font-weight: 400;">. Such as </span><span style="font-weight: 400;">bind_password</span><span style="font-weight: 400;"> or </span><span style="font-weight: 400;">ssl_password</span><span style="font-weight: 400;">.</span>
</li>
<li style="font-weight: 400;">
<span style="font-weight: 400;">HUE_IGNORE_PASSWORD_SCRIPT_ERRORS=1 HUE_DATABASE_PASSWORD=password /opt/cloudera/parcels/CDH/lib/hue/build/env/bin/hue <command></span>
</li>
<li style="font-weight: 400;">
<b>Note: </b><span style="font-weight: 400;">When you include environment variables on the command line without a ";" between them as the above command does, they will only apply to that command. You won't have </span><span style="font-weight: 400;">HUE_DATABASE_PASSWORD</span><span style="font-weight: 400;"> in the environment after the command finishes.</span>
</li>
Example running changepassword:
[root@nightly55-1 ~]# export HUE_CONF_DIR="/var/run/cloudera-scm-agent/process/\`ls -1 /var/run/cloudera-scm-agent/process | grep HUE | sort -n | tail -1 \`"
[root@nightly55-1 ~]# HUE_IGNORE_PASSWORD_SCRIPT_ERRORS=1 HUE_DATABASE_PASSWORD=password /opt/cloudera/parcels/CDH/lib/hue/build/env/bin/hue changepassword admin
Changing password for user 'admin'
Password:
Password (again):
Password changed successfully for user 'admin'
If you are performing command line actions that require other password, such as bind_password for syncing LDAP users and groups, you need to include environment variables to set those as well. Here is a list:
HUE_AUTH_PASSWORD = password used to authenticate to HS2/Impala.
HUE_LDAP_PASSWORD = password used to authenticate to HS2/Impala.
HUE_SSL_PASSWORD = password used for private key file.
HUE_SMTP_PASSWORD = password used for SMTP.
HUE_LDAP_BIND_PASSWORD = password used for Ldap Bind.
##
ls -1 /var/run/cloudera-scm-agent/process | grep HUE | sort -n | tail -1"
Example running changepassword.
[root@cdhnok54-1 tmp]# export HUE_CONF_DIR="/var/run/cloudera-scm-agent/process/\`ls -1 /var/run/cloudera-scm-agent/process | grep HUE | sort -n | tail -1 \`"
[root@cdhnok54-1 tmp]# /opt/cloudera/parcels/CDH/lib/hue/build/env/bin/hue changepassword admin
Changing password for user 'admin'
Password:
Password (again):
Password changed successfully for user 'admin'
Executing the hue command with no argument will list them all:
./build/env/bin/hue
...
[auth]
changepassword
createsuperuser
[beeswax]
beeswax_install_examples
close_queries
close_sessions
[desktop]
config_dump
config_help
config_upgrade
create_desktop_app
create_proxy_app
create_test_fs
kt_renewer
runcherrypyserver
runcpserver
runpylint
sync_documents
test
test_windmill
version
[django]
cleanup
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
reset
runfcgi
runserver
shell
sql
sqlall
sqlclear
sqlcustom
sqlflush
sqlindexes
sqlinitialdata
sqlreset
sqlsequencereset
startapp
startproject
validate
[django_extensions]
clean_pyc
compile_pyc
create_app
create_command
create_jobs
describe_form
dumpscript
export_emails
generate_secret_key
graph_models
mail_debug
passwd
print_user_for_session
reset_db
runjob
runjobs
runprofileserver
runscript
runserver_plus
set_fake_emails
set_fake_passwords
shell_plus
show_templatetags
show_urls
sqldiff
sync_media_s3
syncdata
unreferenced_files
[django_openid_auth]
openid_cleanup
[hbase]
hbase_setup
[indexer]
indexer_setup
[oozie]
oozie_setup
[pig]
pig_setup
[search]
search_setup
[south]
convert_to_south
datamigration
graphmigrations
migrate
migrationcheck
schemamigration
startmigration
syncdb
testserver
[spark]
livy_server
[useradmin]
import_ldap_group
import_ldap_user
sync_ldap_users_and_groups
useradmin_sync_with_unix
For stating the test server, defaulting to port 8000:
./build/env/bin/hue runserver
For stating the production server, defaulting to port 8888:
./build/env/bin/hue runcpserver
These commands are more detailed on the How to get started page.
All the commands finishing by '_setup' will install the example of the particular app.
./build/env/bin/hue search_setup
In the case of Hive, in order to install the sample_07 and sample_08 tables and SQL queries, type:
./build/env/bin/hue beeswax_install_examples
Note:
These commands are also accessible directly from the Web UI.
This command is explained in more detail in the How to change or reset a forgotten password post:
./build/env/bin/hue changepassword
This command is explained in more detail in the Hive and Impala queries life cycle post:
./build/env/bin/hue close_queries
./build/env/bin/hue close_sessions
This command is explained in more detail in the How to run the tests post:
./build/env/bin/hue test
This command is explained in more detail in the How to manage the database with the shell post:
./build/env/bin/hue dbshell
In order to type any Django to Python:
./build/env/bin/hue shell
./build/env/bin/hue shell < script.py
Have any questions? Feel free to contact us on hue-user or @gethue!