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.
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
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:
In this section we'll look at installing the dependencies you'll need for Apache CloudStack development.
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.
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.
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
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
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
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
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.
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
To start CloudStack, run:
mvn -pl :cloud-client-ui jetty:run
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.