Robot Core

The function of the “core” is to identify Resources that need to be processed and dispatching the Resource to the queue with a message that will dircet the worker to the relevant function in a Driver.

How does it Work?

  1. celery_app.py

  • Instantiates the Celery library, the application is thread-safe so that multiple Celery applications with different configurations, components, and tasks can co-exist in the same process space.

  • Finds all the task modules from the Drivers and imports them.

  • Every task module has a unique name, and this name is referenced in the task messages so the worker can find the right function to execute.

  1. mainloop.py

  • It performs a perpetual loop that queries the CloudCIX IaaS API run_robot service to fetch user requested Resource data to process. The data in the response is the Resource IDs that require processing.

  • The run_robot response returns the Resource ID if its state is in a Timeout state and the run_robot flag of the Resources Project is True.

  • If there are no IDs in the response, mainloop will sleep for 15 seconds before resuming.

  • If there are IDs in the response, mainloop sends the Resource ID to the dispatcher.

  1. dispatcher.py

  • The dispatcher calls the respective Driver of the Resurces dispatch function to create the task and place them in the RabbitMQ celery-worker queue.