==========================
Installing the AEN gateway
==========================

.. contents::
   :local:
   :depth: 1


The gateway is a reverse proxy that authenticates users and automatically
directs them to the proper AEN compute node for their project. Users will not
notice this node as it automatically routes them.

Gateway is installed in the ``/opt/wakari/wakari-gateway`` directory.

Setting variables and changing permissions
==========================================

.. AEN_GW_INST_VARS_PERMS_START

Run:

.. code-block:: bash

        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: Change <FQDN HOSTNAME OR IP ADDRESS> to the actual fully qualified domain
hostname or IP address.

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.

.. AEN_GW_INST_VARS_PERMS_END

Running the AEN gateway installer
=================================

.. AEN_GW_INST_RUN_START

Run:

.. code-block:: bash

        sudo -E ./aen-gateway-4.2.1-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
        ...

.. AEN_GW_INST_RUN_END

Registering your gateway
========================

The gateway needs to register with the AEN server.

This needs to be authenticated, so the NFI user's credentials created during
the AEN server install must be used.

To write the configuration file
``/opt/wakari/wakari-gateway/etc/wakari/wk-gateway-config.json``,
run the following as sudo or root:

.. code-block:: bash

    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 :doc:`server installation
<install-server-node>`.

Setting permissions
-------------------

Run:

.. code-block:: bash

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

Starting the gateway
--------------------

Run:

.. code-block:: bash

   sudo service wakari-gateway start


Verifying your gateway registration
-----------------------------------

#. Log into the AEN server using the Chrome or Firefox browser
   and the AEN_SRVC_ACCT user.

#. In the AEN navigation bar, click Admin to open the Admin
   Settings page.

#. In the **Site Admin** menu, select Data Centers:

   .. figure:: /img/aen-admin-admin_datacenter1.png
      :width: 50%

      ..

   |

#. Click your data center:

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

#. Verify that your data center is registered and the status is ``{"status": "ok", "messages": []}``:

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

      ..

   |


What's next
===========

:doc:`Install the AEN compute node(s) <install-compute-node>`.
