Setting Up an Apache CloudStack Development Environment

Want to set up an Apache CloudStack development environment? We'll show you how to set up a development environment under Linux with Eclipse as the IDE. Be sure to check the new Maven instructions for major releases after CloudStack 4.0.0-incubating.

Getting Source

CloudStack uses git for source version control, if you know little about git, http://book.git-scm.com/ is a good start. Once you have git setup on your machine, pull source with:

git clone https://git-wip-us.apache.org/repos/asf/cloudstack.git

Importing Source into Eclipse

Most Apache CloudStack developers use Eclipse as their primary IDE. CloudStack source code already includes Eclipse .project file in each project folder, you can import them to your Eclipse workspace by:

  • Creating a new Eclipse workspace, right clicking package explorer and selecting Import.
  • Selecting "Existing Projects into Workspace".
  • Browsing to the folder with CloudStack source code.
  • Click Open, where you will see all Apache CloudStack projects listed in the dialog box. Click the Finish button. Now you have CloudStack registered with Eclipse.

Installing Dependencies

In this section we'll look at installing the dependencies you'll need for Apache CloudStack development.

Installing OpenJDK

Install openjdk. As we're using Linux, OpenJDK is our first choice. You can install it using Yum or APT, depending on which Linux distribution you use one of these commands:

yum install package_name_of_openjdk

apt-get install package_name_of_openjdk

If you're unsure of the name for the OpenJDK package, use yum search or apt-cache search, or use your distribution's GUI-based tools for installing and managing packages.

Note that you are free to install another JVM if you have special needs.

Installing Apache Tomcat 6

Install tomcat6. Apache CloudStack developers use the tarball from the Tomcat 6 download page, as it's the easiest and fastest way.

Here we'll download Apache Tomcat 6 and uncompress the tarball:

wget http://archive.apache.org/dist/tomcat/tomcat-6/v6.0.33/bin/apache-tomcat-6.0.33.tar.gz

tar xzf apache-tomcat-6.0.33.tar.gz

Note we specifically recommend Apache Tomcat version 6.0.33 at this time. The 6.0.35 release has some issues with Apache CloudStack at this time, thus we recommend avoiding it for CloudStack development.

Now we set the environment variables:

export CATALINA_HOME=/your_path/apache-tomcat-6.0.33/

export CATALINA_BASE=/your_path/apache-tomcat-6.0.33/

Note: we usually set them in ~/.bashrc for convenience.

Install Ant

If ant is not already installed, you can install it using Yum or APT. Depending on which Linux distribution you use one of these commands:

yum install ant

apt-get install ant

Install MySQL

Next, we'll install MySQL if it's not already present on the system. Again, use Yum or APT depending on the type of system you're doing development on.

yum install mysql-server

apt-get install mysql-server

Compile and Deploy

Ant procedure to be used > Cloudstack 4.0 release

To pull in dependencies, go to the cloudstack source folder and run:

mvn -P deps

To compile Apache CloudStack, go to the cloudstack source folder and run:

ant clean-all build-all

To deploy Apache CloudStack, run:

ant deploy-server

Deploy the database next:

ant deploydb

Run Apache CloudStack

To start CloudStack, run:

ant debug

Apache CloudStack should now be running. Its log file is called vmops.log, and it should be under the root source directory. You can monitor it with:

tail -f vmops.log

Run with Suspend

If you're going to set a break point in Eclipse before CloudStack launches, you may want to suspend CloudStack until Eclipse debugger is connected. Do this with:

ant debug-suspend

Now CloudStack is running and listening on port 8787. You can use the remote debug feature of Eclipse to connect to this port and CloudStack will go on running.

Maven procedure developed for Cloudstack 4.1.0 and later

To compile Apache CloudStack, go to the cloudstack source folder and run:

mvn -P developer clean install

To deploy Apache CloudStack, run:

mvn -P developer -pl developer,tools/devcloud -Ddeploydb

Deploy the database next:

mvn -P developer -pl tools/devcloud -Ddeploysvr

Run Apache CloudStack

To start CloudStack, run:

mvn -pl :cloud-client-ui jetty:run

Log Into Apache CloudStack

Open your Web browser and use this URL to connect to CloudStack:

http://localhost:8080/client/

or

http://ip_address_where_cloudstack_is_running:8080/client

Note: If you have iptables enabled, you may have to open the ports used by CloudStack. Specifically, ports 8080, 8250, and 9090.

If you've run into any problems with this, please ask on the cloudstack-dev mailing list.