/central-automation-studio

A graphical user interface web application to run API based automation workflows in Aruba Central

Primary LanguageJavaScriptMIT LicenseMIT

Central Automation Studio (CAS)

Central Automation Studio uses a Docker container to provide a portable, customizable platform for users to explore Central APIs.

Central Automation Studio is a Dockerization of Aaron Scott's Central Automation platform (https://central.wifidownunder.com).
Source code by Aaron Scott at https://central.wifidownunder.com/source
See https://central.wifidownunder.com/documentation.html

Table of Contents

Instructions for Use (MacOS/ Linux)
Instructions for Use (Windows)
Dependencies
Image Versions
Useful Commands for Development
Architecture
Container Structure
Important Files
Notes/ Issues

Note: Using WSL has not been tested.

  1. Install Docker: https://docs.docker.com/get-docker/

  2. Pull the image:
    sudo docker pull joshruiz1985/central-automation-studio

  3. Start a container using the image you just built.

    • With HTTP
      sudo docker run -it --rm --name containerName -p <port-number>:80 -e API_URL="http://<ip-address>:<port-number>/backend" -e SECURE="False" arubahpe/central-automation-studio

      For example:
      sudo docker run -it --rm --name myContainer -p 5001:80 -e API_URL="http://192.168.1.200:5001/backend" -e SECURE="False" arubahpe/central-automation-studio

      View your container at the specified IP address, ex: http://192.168.1.200:5001/

    • With HTTPS/ SSL enabled. Note that and need to be provided by the user, and are the file paths of the key and certificate, respectively.
      sudo docker run -it --rm --name containerName -p 443:443 -e API_URL="https://<ip-address-or-fqdn>/backend" -e SECURE="True" -v <path-to-ssl-key>:/usr/local/apache2/conf/apache-private.key -v <path-to-ssl-certificate>:/usr/local/apache2/conf/apache-cert.crt arubahpe/central-automation-studio

      For example:
      sudo docker run -it --rm --name myContainer -p 443:443 -e API_URL="https://192.168.1.200/backend" -e SECURE="True" -v /etc/ssl/private/apache-selfsigned.key:/usr/local/apache2/conf/apache-private.key -v /etc/ssl/certs/apache-selfsigned.crt:/usr/local/apache2/conf/apache-cert.crt arubahpe/central-automation-studio

      View your container at the specified IP address or FQDN (Fully Qualified Domain Name), ex: https://192.168.1.200/
      For an example of how to quickly set up a self-signed certificate, see Step 1 of this article: https://www.digitalocean.com/community/tutorials/how-to-create-a-self-signed-ssl-certificate-for-apache-in-ubuntu-16-04. The Common Name should match the IP address in API_URL. Note that if you use a self-signed certificate, you may see an error message; click "Advanced" and proceed anyway.

    • Environment variables
      The "-e" flag sets an environment variable. There are two environment variables that need to be set:
      API_URL: Set this to the URL of your backend server.
      SECURE: Set this to "True" if you want to enable SSL and use HTTPS, otherwise set it to "False".

  4. If you want to stop your container:
    sudo docker stop containerName

    The --rm flag means that your container will be removed when it is stopped; if you would like continue running the same exact container, remove the --rm flag.

Note: Using WSL has not been tested.

  1. Install Docker: https://docs.docker.com/get-docker/.

  2. Pull the image:
    docker pull arubahpe/central-automation-studio

  3. Start a container using the image you just pulled.

    • With HTTP
      docker run -it --rm --name containerName -p <port-number>:80 -e API_URL="http://<ip-address>:<port-number>/backend" -e SECURE="False" arubahpe/central-automation-studio

      For example:
      docker run -it --rm --name myContainer -p 5001:80 -e API_URL="http://192.168.1.200:5001/backend" -e SECURE="False" arubahpe/central-automation-studio

      View your container at the specified IP address, ex: http://192.168.1.200:5001/. The --rm flag means that your container will be removed when it is stopped; if you would like continue running the same exact container, remove the --rm flag.

    • Environment variables
      The "-e" flag sets an environment variable. There are two environment variables that need to be set:
      API_URL: Set this to the URL of your backend server.
      SECURE: Set this to "True" if you want to enable SSL and use HTTPS, otherwise set it to "False".

  4. If you want to stop your container:
    sudo docker stop containerName


API: Python, Flask, Flask-CORS, Gunicorn

Clone the repo here: git clone https://github.com/aruba/central-automation-studio.git

To build an image from scratch:
sudo docker build --no-cache -t imageRepo .
NOTE: On Windows, you will need to change the line endings before you build the image. Find the file central-automation-studio/start.sh and change the line endings from CRLF (Windows) to LF (Unix). You can do this with a text editor.
Sublime: View -> Line Endings -> Unix
Notepad++: Edit -> EOL Conversion -> Unix (LF)
Visual Studio Code: See the bottom right corner -> CRLF -> LF

To run a new interactive container (accessible through bash) that is automatically removed when stopped:
sudo docker run --name containerName -it --rm --entrypoint "" imageRepo tail -f /dev/null

To access a container's terminal:
sudo docker exec -it containerName /bin/bash

UI (Apache) <----> API Proxy (Gunicorn) <----> Aruba Central
See https://central.wifidownunder.com/documentation.html#architecture-row

/central
     |----/API
         |----set_env.py: sets environment variables
         |----start.sh: bash script that starts frontend and backend servers
         |----timed_test.log: rotating error log
         |----api.py
         |----wsgi.py
         |----/api
         |----/static
         |----/templates
     |----/UI
     |----/apacheconfig
         |----apache_main.conf: main Apache configuration
         |----apache_main_ssl.conf: main Apache configuration with SSL enabled
         |----apache_ssl.conf: specific SSL configuration for Apache
/usr/local/apache2/
     |----/htdocs/ UI code is located here
     |----/conf/ If SSL is enabled, the certificate and key are placed here.

  • UI/assets/js/main.js:32 is where the api_url/ location of backend server is defined.
  • set_env.py sets the environment variables API_URL and SECURE
  • API/api.py is where the error log is created
  • apache_main.conf contains the Apache reverse proxy config
  • apache_main_ssl.conf and apache_ssl.conf contain the Apache reverse proxy config + SSL enablement.
  • start.sh starts the Gunicorn server in the background, and the Apache server in the foreground
  • UI/assets/js/main.js: Copyright symbol was removed due to encoding issues when trying to read the file in set_env.py
  • Some issues on Windows PC, so for now just use http instead of https: RUN sed -i 's/https/http/' /etc/apk/repositories (put this before apk update)
  • To run on Windows, change the line endings in start.sh from CRLF to LF before building the image
  • Setting up HTTPS for Windows? "Invalid mode" when volume mounting SSL certificate and key, using OpenSSL on Windows