Skip to content
Snippets Groups Projects
README.md 8.32 KiB

Introduction

This is a flask application that leverages RabbitMQ and Celery to asynchronously create a Cheaha user account. Currently the project is being developed on an Openstack cluster.

Project Setup

To clone this repo use the command:

$ git clone https://gitlab.rc.uab.edu/mmoo97/flask_user_reg.git
$ cd flask_user_reg

Prerequisites

Setup a Virtual Environment

  • Ensure you have created a virtual environment called venv setup running python3.
    • Note, this project requires a virtual environment running python3 (3.6.8 in this case).
      • Create this by navigating to you home directory via typing $ cd and entering the following commands:
      $ python3 -m venv ~/venv
      $ source ~/venv
      • Upon Activation, you should see the prompt update accordingly:
      [centos@ood ~]$              <------Old Prompt
      (venv) [centos@ood ~]$       <------New Prompt
      In this case, the env name is displayed as venv but would change to reflect whatever name you initialized it with in the previous step. Additionally, this example is running on the ood node provisioned via OpenStack.
  • Ensure pip is installed.
    • Mac/Linux

      • Check if installed by typing $ pip
      • Install pip using $ python -m pip install --user --upgrade pip.
    • Windows

      • Check if installed using $ py
      • Install pip using $ py -m pip install --upgrade pip

  • Ensure Flask and other dependencies are installed to you virtual environment using the following commands:
$ cd ~/your/repo/path/flask_user_reg
$ pip install -r requirements.txt
  • Note, to install flask in your own $HOME use pip install --user Flask.

Install RabbitMQ

(Reference: here)

  • Install RabbitMQ server on the host machine. (Installation Guide)
    • Mac/Linux

      • $ brew update
      • $ brew install rabbitmq
      • it is recommended that you add the following line to your .bash_profile:
        export PATH=$PATH:/usr/local/opt/rabbitmq/sbin.
      • Start server using the command $ rabbitmq-server. (Note, this implementation assumes RabbitMQ is running on localhost on standard port 5672)
    • Windows

      • Download the installer from here and run.
      • Post install, the server should be running. To check, run $ rabbitmqctl.bat status.
    • CentOS 7

      • First, import signing key using $ rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc
      • Next, install Erlang using $ yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
      • Finally, install RabbitMq using $ yum install rabbitmq-server-3.8.2-1.el8.noarch.rpm
      • The server is not started as a daemon by default when the RabbitMQ server package is installed. To start the daemon by default when the system boots, as an administrator run: $ chkconfig rabbitmq-server on.
      • As an administrator, start and stop the server as usual:
        /sbin/service rabbitmq-server start
        /sbin/service rabbitmq-server stop
  • Add the user "reggie" using the command $ rabbitmqctl add_user reggie reggie.
    • The current configuration assumes the following username password combination. To change the password, type $ rabbitmqctl change_password reggie <new_password>.
    • Note that rabbitmqctl may require sudo permissions and that changing the password will require a password change in the credentials within test_producer.py and base_consumer.py as well.

Run Project

1. Connect to OHPC/OOD

  1. Network Setup:
    Assuming proper steps have been run to provision your openstack cluster, your network topology should look like the following:
    Openstack Network Topology

  2. Locate Floating Ip for each instance:
    Research Computing Network
    According to this diagram of the network infrastructure, the IP Addresses that you will need to connect to in order to ssh into each machine will be 164.111.161.xxx where .xxx is the last octet of your assigned Floating IP Addresses shown below.
    Floating IP Addresses
    Note that these numbers will typically vary depending on factors in the provisioning process.

  3. SSH into each machine:
    Now that you have the IP Addresses of the OHPC and OOD nodes, you can connect to them via the following command in two separate shell windows/tabs:

    $ ssh centos@164.111.161.xxx
  4. Drop Firewall:
    Currently, the firewall prevents us from connecting to our soon to be running flask app. To check if the firewall is active, type:
    $ sudo systemctl status firewalld
    In the case the firewall is still active, type:
    $ sudo systemctl stop firewalld
    In the case you need to turn the firewall back on, type:
    sudo systemctl start firewalld

  5. Edit Security Rules:
    Lastly, we want to make sure that our network it open to run on our flask application which runs on localhost:5000 by default. Modify your Default security group to reflect the following rules:
    Security Rules
    The main takeaway/modification in these rules is that traffic is allowed in and out of port 5000.

2. Initialize RabbitMQ

Make sure that you are running rabbitmq via the command sudo rabbitmq server.

3. Test RabbitMQ

For a simple example on the functionality of RabbitMQ, do the following: