Tutorials/CloudSim/1.0/development

CloudSim ==

CloudSim is a web app that runs in a virtual machine on the AWS (Amazon Web Services) cloud. This guide will show you how to run a local copy of CloudSim on your development machine. It also covers tools and tricks to get insights on its internals.

The code can be found here:

https://bitbucket.org/osrf/cloudsim

Prerequisites ==

Here are the packages that need to be installed in order to run and develop CloudSim

sudo apt-get install -y python openssh-client unzip zip mercurial cloud-utils apache2 redis-server python-pip sudo pip install unittest-xml-reporting sudo pip install redis sudo apt-get install python-software-properties sudo apt-add-repository -y ppa:rye/ppa sudo apt-get update sudo apt-get install -y libapache2-mod-auth-openid sudo ln -s /etc/apache2/mods-available/authopenid.load /etc/apache2/mods-enabled

System overview ==

CloudSim is a distributed system that runs on a server machine inside multiple processes (the web server and the CloudSim daemons). These processes interact with each other via the file system and the Redis key-value store. The CloudSim server controls the life cycle of multiple virtual machines on the Cloud. The user interacts with it via their web browser. Here is a description of the various processes, their roles and the source code.



Redis is a key-value store program that is used as an IPC mechanism between the daemons and the web app. http://redis.io/ It needs to be installed on the CloudSim server, and the Redis-server daemon must be running (it runs by default on Ubuntu once installed).
 * 1) Redis server


 * 1) cloudsimd
 * This is a python program that launches simulators and other machines in the cloud. It is installed as an upstart daemon (http://upstart.ubuntu.com/).

Cloudsimd uses the common library code (in cloudsim/inside/cgi-bin/common), so PYTHONPATH must be set accordingly. It contains a launchers module. Each file in this module corresponds to a configuration that can be launched with CloudSim.
 * It listens for commands using redis publish/subscribe channels. The web app listen to these messages.
 * The source code is found in cloudsim/cloudsimd.
 * The entry point is cloudsimd.py.


 * 1) cloudsim_monitord
 * This is a python upstart daemon.
 * It periodically checks the status of machines running on the cloud, and publishes their state via redis channels. The web app listen to these messages.
 * The source code is found in cloudsim/cloudsimd.
 * The entry point is cloudsim_monitord.py


 * 1) Web server
 * The apache web server runs python cgi scripts that implement the REST api and serve the web application to the users. It uses redis to communicate with Cloudsimd and cloudsim_monitord.
 * The web server loads an apache2 module that performs OpenID authentication. The login.html page is the entry point to the application.
 * The source code is in cloudsim/inside/cg-bin directory. The common subdirectory contains the source code for the common library.


 * 1) Web browser (running the web app)
 * The source code to the web app is mostly contained in the 'cloudsim/js' directory. The `cloudsim/inside/cgi-bin/console.py` serves a minimal page that includes all the javascript files (and dependencies like jquery / jqueryui and flotcharts). The on_load page event subscribes to server events that are propagated to the widgets.

CloudSim uses the file system to store files and state information (mostly key files, scripts) for each machine. The information stored on disk may eventually migrate to the Redis key-store.
 * 1) Disk (file system)

Deployment ==

CloudSim uses the www-data user to access the disk. It creates `/var/www-cloudsim-auth` and `/var/www` directories.

Getting the code. Use Mercurial to get the code (i.e, from your bitbucket account).

hg clone https://xxx@bitbucket.org/cloudsim cd cloudsim

The first time you deploy, you will need to give your admin user to the application. Edit the content of the `cloudsim/distfile/users` to set your email address. You can also edit the `/var/www-cloudsim-auth/users` after deployment.

{"hugo@osrfoundation.org":"admin"}

Deploy the application locally by running the deploy.sh script. This overrides your apache2 configuration so you may want to save your `/etc/apache2/apache2.conf` file before running it.

. deploy.sh

Login via your browser at `http://localhost`. The first time you login, you will need to set your AWS credentials in order to launch machines.

Tools ==

Cloudsim contains a few unit tests to help isolate problems. Tests are run automatically after new code is checked in. The `cloudsimd-spy.py` is a scripts that prints redis messages to the console. It is useful for tracing and debugging purposes.