Git Product home page Git Product logo

ros-backend's Introduction

ROS-backend

Backend for Resource Optimization Service

Getting Started

This project uses pipenv to manage the development and production environments.

Once you have pipenv installed, do the following:

pipenv install

Afterwards you can activate the virtual environment by running:

pipenv shell

A list of configurable environment variables is present inside .env.example file.

Dependencies

The application depends on several parts of the insights platform. These dependencies are provided by the docker-compose.yml file in the scripts directory.

To run the dependencies, just run following command:

cd scripts && docker-compose up insights-inventory-web db-ros insights-engine

Running the ROS application

Within docker

To run the full application ( With ros components within docker)

docker-compose up ros-processor ros-api

On host machine

In order to properly run the application from the host machine, you need to have modified your /etc/hosts file. Check the README.md file in scripts directory.

Initialize the database

Run the following commands to excute the db migration scripts.

python manage.py db upgrade
python manage.py seed 

Running the processor locally

The processor component connects to kafka, and listens on topics for system archive uploads/ system deletion messages.

python -m ros.processor.main

Running the web api locally

The web api component provides a REST api view of the app database.

python -m ros.api.main

Running the Tests

It is possible to run the tests using pytest:

pipenv install --dev
pytest --cov=ros tests

Available v0 API endpoints

Request

GET /api/ros/v0/systems Shows list of all systems from Host Inventory having a Performance Profile

curl -v -H "Content-Type: application/json" https://cloud.redhat.com/api/ros/v0/systems -u rhn-username:redhat

Response

HTTP/1.1 200 OK
Date: Thu, 24 Feb 2011 12:36:30 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 2

[{
  "fqdn": "string",
  "display_name": "string",
  "inventory_id": "string",
  "account": "string",
  "number_of_suggestions": 0,
  "state": "string",
  "performance_utilization": {
    "memory": 0,
    "cpu": 0,
    "io": 0
  },
  "cloud_provider": "string",
  "instance_type": "string",
  "idling_time": 0,
  "io_wait": 0
}]

Request

GET /api/ros/v0/systems/<host_id> To get the individual system details using their <host_id>

curl -v -H "Content-Type: application/json" https://cloud.redhat.com/api/ros/v0/systems/<host_id>

Response

HTTP/1.1 200 OK
Date: Thu, 24 Feb 2011 12:36:30 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 2

{"host_id": "12345-57575757", "performance_record": "{'avg_memory': '3998008.000', 'avg_memory_used': '2487908.973'}", "performance_utilization": "{'memory': 62}"}

Request

GET /api/ros/v0/status Shows the status of the server

curl -v -H "Content-Type: application/json" https://cloud.redhat.com/api/ros/v0/status

Response

HTTP/1.1 200 OK
Date: Thu, 24 Feb 2011 12:36:30 GMT
Status: 200 OK
Connection: close
Content-Type: application/json
Content-Length: 2

{"status": "Application is running!"}

For local dev setup, please remember to use the x-rh-identity header encoded from your account number, the one used while running make insights-upload-data and make ros-upload-data commands.

ros-backend's People

Contributors

apuntamb avatar gnurag avatar jpramos123 avatar kgaikwad avatar patilsuraj767 avatar preetiw avatar r14chandra avatar saltgen avatar victoremepunto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.