===================
Install AEN Gateway
===================

The *Gateway* is a reverse proxy server that authenticates users and
automatically directs them to the proper AEN Compute Node for
their project. Users will not notice the Gateway as it 
automatically routes them.

These procedures assume that you have already performed the :doc:`install-prep`
and :doc:`install-server` procedures.

Set variables and change permissions
====================================

In the script below, change ``<FQDN HOSTNAME OR IP ADDRESS>`` to the actual
fully qualified domain hostname or IP address. 

::

        export AEN_SERVER=<FQDN HOSTNAME OR IP ADDRESS> # Use the real FQDN
        export AEN_GATEWAY_PORT=8089
        export AEN_GATEWAY=<FQDN HOSTNAME OR IP ADDRESS> # will be needed shortly
        chmod a+x aen-*.sh                # Set installer to be executable
        
NOTE: You must perform the entire procedure before closing the terminal 
to ensure the variable export persists. If the terminal is closed before
successful installation, export the variables to continue with the installation.

Run Gateway installer
======================

::

        sudo -E ./aen-gateway-4.1.2-Linux-x86_64.sh -w $AEN_SERVER
        <license text>
        ...
        ...

        PREFIX=/opt/wakari/wakari-gateway
        Logging to /tmp/wakari_gateway.log
        ...
        ...
        Checking server name
        Please restart the Gateway after running the following command
        to connect this Gateway to the AEN Server
        ...


Register the AEN Gateway
========================

The AEN Gateway needs to register with the AEN Server. This needs
to be authenticated, so the ``AEN_SRVC_ACCT`` user's credentials created during the
AEN Server install need to be used. **This needs to be run as sudo or root**
to write the configuration file:
``/opt/wakari/wakari-gateway/etc/wakari/wk-gateway-config.json``

::

    sudo /opt/wakari/wakari-gateway/bin/wk-gateway-configure \
    --server http://$AEN_SERVER --host $AEN_GATEWAY \
    --port $AEN_GATEWAY_PORT --name Gateway --protocol http \
    --summary Gateway --username $AEN_SRVC_ACCT \
    --password '<NFI USER PASSWORD>'

Note: replace ``<NFI USER PASSWORD>`` with the password of the NFI user that was generated during server installation above.

Ensure proper permissions
-------------------------

::

    sudo chown $AEN_SRVC_ACCT /opt/wakari/wakari-gateway/etc/wakari/wk-gateway-config.json

Start the Gateway
-----------------

::

    sudo service wakari-gateway start


Verify the AEN Gateway registration
------------------------------------

1. Login to the AEN Server using Chrome or Firefox browser using the
   ``AEN_SRVC_ACCT`` user.
   
2. Click the Admin link in the toolbar

   .. image:: /img/aen-install-admin-menu.png
      :scale: 40 %
      
   |
      
3. Click the Data Centers subsection, then click your Data Center:

   .. image:: /img/aen-install-datacenter-leftnav.png
      :scale: 40 %
      
   |
      
4. Verify that your Data Center is registered and status is
   ``{"status": "ok", "messages": []}``

   .. image:: /img/aen-install-datacenter.png
      :scale: 40 %

   |
     
Next steps
==========

See the next step needed for full AEN install below:

* :doc:`install-compute`
   
The following optional install procedures may need to be performed, 
depending on how you set up your data center:
   
* :doc:`option-config`
* :doc:`customization`
* :doc:`ldap`
* :doc:`ssl`
* :doc:`sso`
   
Additional post-install information:
   
* :doc:`installation_update`
* :doc:`uninstall`
* :doc:`release`
