Sahara UI Dev Environment Setup

This page describes how to setup Horizon for developing Sahara by either installing it as part of DevStack with Sahara or installing it in an isolated environment and running from the command line.

Install as a part of DevStack

See the DevStack guide for more information on installing and configuring DevStack with Sahara.

After Horizon installation, it will contain a Data Processing tab under Projects tab. Sahara UI source code will be located at $DEST/horizon/openstack_dashboard/contrib/sahara/content/data_processing where $DEST/ is usually /opt/stack/.

Isolated Dashboard for Sahara

These installation steps serve two purposes:
  1. Setup a dev environment
  2. Setup an isolated Dashboard for Sahara

Note The host where you are going to perform installation has to be able to connect to all OpenStack endpoints. You can list all available endpoints using the following command:

$ keystone endpoint-list

You can list the registered services with this command:

$ keystone service-list
  1. Install prerequisites
$ sudo apt-get update
$ sudo apt-get install git-core python-dev gcc python-setuptools python-virtualenv node-less libssl-dev libffi-dev libxslt-dev

On Ubuntu 12.10 and higher you have to install the following lib as well:

$ sudo apt-get install nodejs-legacy
  1. Checkout Horizon from git and switch to your version of OpenStack

Here is an example:

$ git clone https://github.com/openstack/horizon

Then install the virtual environment:

$ python tools/install_venv.py
  1. Create a local_settings.py file
$ cp openstack_dashboard/local/local_settings.py.example openstack_dashboard/local/local_settings.py
  1. Modify openstack_dashboard/local/local_settings.py

Set the proper values for host and url variables:

OPENSTACK_HOST = "ip of your controller"

If you are using Nova-Network with auto_assign_floating_ip=True add the following parameter:

SAHARA_AUTO_IP_ALLOCATION_ENABLED = True
  1. If Sahara is not registered with the keystone service catalog, it may be added with the following commands. To use Sahara from Horizon without keystone registration, see Using the Data Processing Dashboard without Keystone Registration.

    $ keystone service-create --name sahara --type data-processing
    $ keystone endpoint-create --region RegionOne --service sahara --publicurl 'http://localhost:8386/v1.1/%(tenant_id)s'
    

    Note you should replace the ip and port in with the appropriate values.

  2. Start Horizon

$ tools/with_venv.sh python manage.py runserver 0.0.0.0:8080

This will start Horizon in debug mode. That means the logs will be written to console and if any exceptions happen, you will see the stack-trace rendered as a web-page.

Debug mode can be disabled by changing DEBUG=True to False in local_settings.py. In that case Horizon should be started slightly differently, otherwise it will not serve static files:

$ tools/with_venv.sh  python manage.py runserver --insecure 0.0.0.0:8080

Note It is not recommended to use Horizon in this mode for production.

  1. Applying changes
If you have changed any *.py files in horizon/openstack_dashboard/contrib/sahara/content/data_processing directory, Horizon will notice that and reload automatically. However changes made to non-python files may not be noticed, so you have to restart Horizon again manually, as described in step 6.

Using the Data Processing Dashboard without Keystone Registration

Note These modifications are strictly for a development environment

If Sahara is not registered as a service with keystone, Horizon must be modified so that the Sahara URL can be known and so service-based permissions do not prevent the Data Processing dashboard from displaying.

  1. Modify openstack_dashboard/contrib/sahara/api/sahara.py:

    Add the following lines before def client(request):

    Note you should replace the ip and port in SAHARA_URL with the appropriate values.

    SAHARA_URL = "http://localhost:8386/v1.1"
    
    def get_sahara_url(request):
    
        if SAHARA_URL:
            url = SAHARA_URL.rstrip('/')
            if url.split('/')[-1] in ['v1.0', 'v1.1']:
                url = SAHARA_URL + '/' + request.user.tenant_id
            return url
    
        return base.url_for(request, SAHARA_SERVICE)
    

    After that modify sahara_url provided in def client(request):

    sahara_url=get_sahara_url(request)
    
  2. Modify openstack_dashboard/dashboards/project/dashboard.py:

    Overload the register method in class Project to programmatically remove data-processing permissions from all panels.

    @classmethod
    def register(cls, panel):
        if hasattr(panel, 'permissions'):
           panel.permissions = tuple(
               [perm for perm in panel.permissions if not perm.startswith(
                   'openstack.services.data-processing')])
        super(Project, cls).register(panel)
    

    Alternatively the data-processing permissions can be removed manually from each panel under openstack_dashboard/contrib/sahara/content/data_processing