Skip to content

CloudStack

skovzhaw edited this page Jul 5, 2016 · 20 revisions

Installation

CloudStack collector is written in Java 8 and requires connection to RabbitMQ. To install these dependencies please consult the installation page.

Relational database

CloudStack collector also requires an access to rational database. Even though you can deploy and use any backend database, the default database is PostgreSQL, which you can install and set up with

cd install
bash install_postgresql.sh
bash create_database.sh

Do not forget that if you are deploying PostgreSQL on a remote server, you will need to open default port 5432 and enable remote connections via editing the following files

Adding host all all 0.0.0.0/0 md5 to /etc/postgresql/9.3/main/postgresql.conf

Adding listen_addresses = '*' to /etc/postgresql/9.3/main/postgresql.conf

Configuration

For CloudStack collector to function properly you will need to edit config/cloudstack.conf file and specify your CloudStack credentials, as well as RabbitMQ and Hibernate connection settings, both of which can be accessed remotely. You can also specify on which port server should be listening or what date will be used for the first import.

Even though the config/cloudstack.conf file is commented, it is still important to pay attention to:

  • CloudStackURL=https://url
  • CloudStackAPIKey=apikey
  • CloudStackSecretKey=secretkey

You can also specify what is the first day of import by providing YYYY-MM-DD date:

  • CloudStackFirstImport=2016-06-29

By default the server port is 4573, but you can change it easily:

  • ServerHTTPPort=4573

If you are running RabbitMQ and Hibernate (PostgreSQL) on the same machine as CloudStack collector, then you can left other configuration parameter untouched, as they already point to the localhost.

Bindings

Before starting CloudStack usage collection it is paramount to bind its exchanges to the RCB Cyclops queues. In order to do so simply run the following script and provide server's location and port RabbitMQ admin is listening on:

bash install/setup_bindings.sh localhost 15672

Logging

To have the logging system enabled you need to run the following:

bash install/setup_logging.sh

Then all CloudStack collector logs will be stored in /var/log/cyclops/cloudstack/ directory.

Deployment

Once all prerequisites are installed and collector is configured you can start using it.

Run the JAR file

In order to run CloudStack collector as embedded JAR:

java -jar bin/cloudstack.jar config/cloudstack.conf [port]

If you don't want to use the default port from configuration file, you can optionally specify one by adding it as parameter.

Compile from the source code

If you want to compile the code on your own and your environment already has Java 8 and Maven 3 present, simply execute the following commands:

cd scripts
bash compile.sh

You will find the compiled JAR embedded file in the bin subdirectory.

API guide

After the CloudStack collector has started it will start collecting usage records from your CloudStack deployment. If anything goes wrong, please refer to logs (they have logical structure).

The CloudStack collector operates based on internal scheduler, in order to periodically ask CloudStack for new usage records. These records are then processed, harmonised and broadcasted to RCB Cyclops (based on available bindings).

Even though everything happens automatically and you will receive new usage records every hour, you can still double check that internal scheduler is running, or even manually force a pull, all done by querying HTTP RESTful API interface:

Example scenario

If you want to know more about Rating-Charging-Billing for CloudStack, as well as see what is happening behind the scenes, refer to this guide.