Hue API: Execute some builtin or shell commands

Published on 08 February 2015 in Development - 4 minutes read - Last modified on 19 April 2021

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.

 

Get started

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.

Running Hue command line on Cloudera Manager 5.5 and above

  • Set HUE_CONF_DIR to the current Hue configuration created by Cloudera Manager.
  • export HUE_CONF_DIR="/var/run/cloudera-scm-agent/process/`ls -1 /var/run/cloudera-scm-agent/process | grep HUE | sort -n | tail -1 `"
  • Run the Hue Command line by including the following environment variables:
    • HUE_DATABASE_PASSWORD= - This defines the password Hue should use to connect to the DB.
    • HUE_IGNORE_PASSWORD_SCRIPT_ERRORS=1 - This configures the Hue command line to run even if there are other unknown passwords defined in the Cloudera Manager created hue.ini.  Such as bind_password or ssl_password.
    • HUE_IGNORE_PASSWORD_SCRIPT_ERRORS=1 HUE_DATABASE_PASSWORD=password /opt/cloudera/parcels/CDH/lib/hue/build/env/bin/hue
    • Note: 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 HUE_DATABASE_PASSWORD in the environment after the command finishes.
  • 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.

    Running Hue command line on Cloudera Manager 5.4 and below

  • Set HUE_CONF_DIR to the current Hue configuration created by Cloudera Manager.
  • export HUE_CONF_DIR="/var/run/cloudera-scm-agent/process/`ls -1 /var/run/cloudera-scm-agent/process | grep HUE | sort -n | tail -1 `"
  • Run the Hue command line.
  • /opt/cloudera/parcels/CDH/lib/hue/build/env/bin/hue
  • 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'

     

    Commands

    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
    
    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
    
    

    Starting the server

    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.

    Installing the examples

    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.

    Screenshot from 2014-04-09 08:06:15

    Changing a password

    This command is explained in more detail in the How to change or reset a forgotten password post:

    ./build/env/bin/hue changepassword

    Closing Hive queries

    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

    Running the tests

    This command is explained in more detail in the How to run the tests post:

    ./build/env/bin/hue test

    Connect to the Database

    This command is explained in more detail in the How to manage the database with the shell post:

    ./build/env/bin/hue dbshell

    Connect to the Python shell

    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!


    comments powered by Disqus

    More recent stories

    26 June 2024
    Integrating Trino Editor in Hue: Supporting Data Mesh and SQL Federation
    Read More
    03 May 2023
    Discover the power of Apache Ozone using the Hue File Browser
    Read More