Setting Up an Ideal CloudStack Development Environment

05-02-2013 / Marc-André Jutras

In this, my first article, I answer a question that I often get asked: How do I set up and prepare my development environment for CloudStack? True, there are many articles and wiki pages available on this subject, but here is my method.

Keep in mind that this article assumes a good knowledge of Linux. It is intended for developers who want to try out the latest development environment on their workstation.

Preferences

I prefer to use the Oracle JVM/JDK for development and OpenJDK in production. I also prefer to set a general symbolic link to every external package, like Maven and OracleJVM, rather than placing the package in the default path. It makes it easier to upgrade a specific package version (by updating only the symbolic link that refers to the particular package).

Requirements

Hypervisor: Oracle VirtualBox
OS: Linux CentOS 6.3 x86_64 for this setup
Java 6 JDK
Maven 3

Procedure

1. Install VirtualBox on your workstation.
2. Install Linux CentOS 6.3 in VirtualBox with the following minimum resources: 1 network interface card (NIC); 2 GB RAM; 20 GB disk space.
3. Update your CentOs. yum update
4. Disable selinux. vi /etc/selinux/config - set: SELINUX=disabled
5. Disable the firewall. chkconfig iptables off
6. Install any package dependencies. yum install genisoimage git
7. Download all the requirements to your VM and place them under /opt/java.

Java:
1. Uncompress your Java package and place it under /opt/java.
2. Create a symbolic link to your JDK.


ln –s jdk1.6.0_38 java

3. Enable Java in your CentOS distribution.


update-alternatives --install "/usr/bin/java" "java" "/opt/java/java/bin/java" 1
update-alternatives --install "/usr/bin/jar" "jar" "/opt/java/java/bin/jar" 1
update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/java/bin/javac" 1
update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/opt/java/java/jre/lib/i386/libnpjp2.so" 1
update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/java/java/bin/javaws" 1
alternatives --config java  (set it to 2)

Maven:
1. Uncompress your Maven package and place it under /opt/java.
2. Create a symbolic link to your Maven release.


ln –s apache-maven-3.0.4 maven

3. Set Maven in your path. Edit /etc/profile (or your ~/.bashrc) and add your Maven value.


M2_HOME=/opt/java/maven
M2_BIN=$M2_HOME/bin
MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=500m -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n"
PATH=${PATH}:$M2_HOME:$M2_BIN
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL M2_HOME M2_BIN MAVEN_OPTS

At this point, reboot Linux to activate all the latest changes. To test everything, log in as root and test your Maven installation:


mvn –version : should return the exact version that matches what you installed in your /opt/java folder.
[root@cs4-1 ~]# mvn -version
Apache Maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500)
Maven home: /opt/java/maven
Java version: 1.6.0_38, vendor: Sun Microsystems Inc.
Java home: /opt/java/jdk1.6.0_38/jre
Default locale: en_CA, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-279.19.1.el6.x86_64", arch: "amd64", family: "unix"

Now we’re ready to get the latest source version of CloudStack! In your /opt folder, create a folder named CloudStack. Inside the CloudStack folder, run git to get the latest source files:


mkdir /opt/CloudStack
cd /opt/CloudStack
git clone https://git-wip-us.apache.org/repos/asf/incubator-cloudstack.git

Because of license issues, vhd-util was removed. So, you must download it and copy it to this location in the source tree:
/opt/CloudStack/incubator-cloudstack/scripts/vm/hypervisor/xenserver/vhd-util
Without this file, you won’t be able to add any Xen servers to your CloudStack setup.

We’re now ready to compile everything! Here are my notes for building CloudStack correctly:

1. Always work in your git folder. (/opt/CloudStack/incubator-cloudstack)
2. Get the latest source. git pull
3. Validate all dependencies. mvn –P deps
4. Deploy the database. mvn -P developer -pl developer –D deploydb
5. Build up everything. mvn -P systemvm clean install
6. Start CloudStack. mvn -pl :cloud-client-ui jetty:run

And that’s it! At this point, you’re ready to test your new CloudStack server!

For information about CloudStack support for non-Open Source features, such as Netscaler, F5, and Netapp, visit these pages:

https://cwiki.apache.org/confluence/display/CLOUDSTACK/How+to+build+on+master+branch https://cwiki.apache.org/confluence/display/CLOUDSTACK/Working+with+CloudStack+Code

New call-to-action