Step 2: Install Virtual Box!
Step 3: Download a Linux Distribution.
I am a beginner in Linux so rather than shy away from it, my goal is to simply embrace running into issues and use the interweb to help overcome a problem or perceived problem in Linux. That’s the best to do to learn this stuff. I chose Lubuntu mainly because that’s what was used in the Open Networking Summit Engineering Tutorial just a few weeks ago. Its GUI is Lightweight and less processor/memory intensive, so it’s great for running on a personal machine.
Step 4: Install Lubuntu.
Your download should have been a disc image file (.iso). You’ll need to create a new VM in Virtual Box. Select new, enter a name for your VM, and select Linux as the OS Type and Ubuntu as the Version. I’d recommend using 2GB RAM. The rest of the settings can remain as default. Now we must mount the .iso to in order to boot from it. In Virtual Box, click your newly created VM, go to “Settings,” then “Storage.” Then click just under the CD icon in the center where it says “Empty.” You’ll see CD/DVD on the right side. Browse to your ISO, select it, and start your VM. Run through the install process accordingly. Once installed, don’t forget to unmount the ISO.
Step 5: Install “Guest Additions” in the Lubuntu VM.
This makes it so you can seamlessly copy and paste between your machine and Guest OS (Lubuntu). It also allows you to re-size the guest OS display window more appropriately to match that of your real machine. For those who are familiar with vSphere deployments, this is analogous to VMware Tools. While in the new Linux VM, go to the Devices drop down, then “Install Guest Additions.” You may need to force the mount here. In order to install on the machine, I did the following:
Open a terminal window. Browse to the media directory. It was
Jason is the user account that I created during the install. From here you can issue an “ls” command to browse the directory. You should see the VBOXADDITIONS directory. Browse to this directory. You can do:
“cd VBOX” and hit TAB.
It will auto-complete just like Cisco CLI. Issue “ls” to see available files. I ran the Linux additions since after all, I installed Linux. To run the script, you need to now enter:
and hit enter. Note that “./” signifies you’ll be executing a script. Once installed, you can enable Shared Clipboard and Drag ‘n Drop via the drop down “Devices” drop down menu. Poke around on the drop down menus on top of the VM in the Virtual Box menus. In the “View” menu, you can also re-size or just double click the Virtual Box bar on top to maximize the full window just like you do any normal windows application. You may need to reboot Lubuntu in order for the guest additions to fully take effect.
Step 6: Install required components needed to compile and download the OpenDaylight Controller.
Git, Java JDK/JRE, and Maven need to be installed. “apt-get” is used to install applications in Linux, so it’s a command you’ll see often. The controller requires maven to be compiled – not sure of the technical details and why, but it seems many of the controllers/APIs/apps coming out require maven to compile and build the application. Git is used to clone the code and download it from a repository to your local machine.
You can install the required components as shown below, but first let’s update the Linux distro.
and then install the components
“apt-get install git”
“apt-get install openjdk-7-jre”
“apt-get install openjdk-7-jdk”
“apt-get install maven”
I chose to install these individually because it made it easier to debug and troubleshoot. For me, git and java installed just fine, but maven kept failing. But you can however, install them all at once like “apt-get install git openjdk-7-jre openjdk-7-jdk maven” if you wish.
I kept getting errors that involved “libwagon” during the maven installation. After researching this, I found that the following command fixed the problem:
“sudo dpkg -i --force-all /var/cache/apt/archives/libwagon2-java_2.2-3+nmu1_all.deb”
This will force installation of libwagon2. Following this, you can re-try maven with:
“apt-get install maven”
By now, you may have realized you need “sudo” in front of commands that require “admin” or “root” privileges! Maybe I should have stated that earlier :).
Step 7: Download the OpenDaylight controller.
Using git, enter
“ http://git.opendaylight.org/gerrit/p/controller.git “
Step 8: Compile and build the controller code using Maven.
Browse to the following directory
Compile the controller using maven:
“mvn clean install”
This was another issue I had. The install kept failing and it seemed I was low on memory based on the error I was getting. I also read in other posts to boost the VM memory, so I did. I went from 1G to 2G to even 4G for my VM. The install still failed. After some digging and while still at 4GB RAM, I used this command:
“export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"
This was just what was needed. The install worked perfectly. I actually finished the complete install process of the controller then reduced the memory back to 2GB and haven’t had issues since.
Step 9: Set the JAVA_HOME variable.
This is required so that the OpenDaylight controller knows where to find the required JDK needed to run. This is done by entering:
This only sets it for the active session and we want it to persist during reboots so we also need to enter the same line somewhere else. In Linux, there are various scripts executed when starting up and as users log in. The trick is knowing which one to edit. Since I am the ultimate novice, I tried more than one as you’ll see on simple google searches, but it was “.bashrc” file that worked for me. This runs every time you login to the OS. In order to do this, we’ll need to edit a file in Linux. For anyone that has ever attempted editing a file in Linux, this means using VI, which could be dreadful to use. Of course, this is only my opinion. After a quick search, I was able to fine “gedit” --- an easy to use application to edit files in Linux. In order to edit .bashrc, first download “gedit” by entering
“sudo apt-get install gedit”
and following the install, navigate to your user directory. For me this is /home/Jason. At the prompt, enter
“sudo gedit .bashrc”
If you don’t enter “sudo” here, the file will still open and you can still edit the file, but it won’t save due to permissions, so remember to use sudo. .bashrc will automatically open --- once it is open, you can easily navigate the file and enter:
I entered this on the last line of .bashrc. After a reboot, you can ensure the JAVA_HOME variable is still set by entering
--- you should see the location of where the JDK is that you previously defined.
Step 10: Launch OpenDaylight Controller.
In order to run the controller, navigate to the directory as such
Once in this opendaylight directory, you can execute the run.sh script by entering
Remember “./” is required to run scripts. It’ll take about 30 seconds for the controller to get fully get up and running.
Step 11: Connect to the Controller.
Launch a web browser on the OpenDaylight server and browse to http://127.0.0.1:8080 or using a different machine on the network, browse to the controller using http://x.x.x.x:8080. You can login to the controller using admin/admin!
Step 12: Create Directory Alias
If you reboot quite a bit and login daily, it becomes nightmarish navigating to this directory to launch and run.sh. So, the nice thing is Linux allows you to create an alias for whatever you want. I simply created an alias to quickly navigate to proper opendaylight directory. I entered this at the command prompt:
“alias odp=cd opendaylight/controller/opendaylight/distribution/opendaylight/target/distribution.opendaylight-0.1.0-SNAPSHOT-osgipackage/opendaylight"
Note: I configured the alias from the /home/Jason directory since that is where I am at time of boot up.
Similarly, we also need the alias to persist on reboots, so we need to edit .bashrc again. Open .bashrc using gedit and add the full alias line as above in quotes. Enter it in the “alias” section.
Step 13: Create shell Alias
Rather than have to enter “./run.sh” each time I want to run the controller, I created another alias. This is:
Don’t forget to add this to bashrc as well!! Now, non-Linux users can quickly navigate and start the controller.
Step 14: Reboot and try it all!
After restarting your Linux, you can simply start up, launch a terminal window, and enter:
and you’ll be up and running!
This gets you access to the controller. There is a different process to hack the code in Eclipse/JAVA that isn’t the focus here. My goal was to try and break it down for people like me, new to Linux, the world of programming, and even virtualization. Soon I’ll post more on how to actually do something with the controller like attaching virtual switches.
I couldn’t have done this without the posts from the OpenDaylight Wiki, Brent (@networkstatic), and Jon (@Blinken_Lichten).
Until next time.