API programming with python for HP VAN SDN Controller

Part Two: Navigating the HP VAN SDN API
DISCLAIMER: You can only trust a mad scientist so much!

OK, we have our API programming lab up and running. You can log into the HP VAN SDN controller from your DevOps station. It is time to start exploring the API’s and what they have to offer.
api
For the most part API’s will be used in a couple of ways. It is the language of the web. API’s are simple to use. There is the HTTP GET, which collects information from the web server, POST, which creates and PUT, you guessed it, it updates. With these few basic commands we could create just about any C.R.U.D. application we want. Let’s not get ahead of ourselves, we want to find out what API’s are available. To do that will navigate to the RSDOC page of the controller. Thanks for thinking of us! The API’s are documented and interactive! Point the browser on the DevOps station to the address in the graphic below.
findapi
In order to get to all the goodies (API’s) we need to tell the controller that we are a “friendly” by entering the username and password. So this part is a bit tricky and you will need to enter some JSON in the “auth” api and get a token. By default the HP VAN SDN Controller uses keystone as an authentication mechanism. It will give you a token (good for 24 hours) to use in your communications. Click on the “auth” api and then on the green “Post” button. A box will appear asking for the JSON login string. {“login”:{”user”:”sdn”,”password”:”skyline”}}. Then the “Try it out” button. Look for the token in the server response. Copy the token to the clipboard (Double-click on it and copy)
gettoken
Now look at the top of your screen for an explore button. Right to the left of it is a box where you will paste the token. It is a long hex number that I usually just memorize. Once it is pasted in the box, click on the Explore button and you should get a response of OK200 at the top center of the screen.
pastetoken
Before we start looking around you might want to know that switches, managed by the HP VAN SDN controller are called dpids, Datapath Identifiers. They look like they impart no knowledge but they do…just look at this.
dpids
So some of the API’s will ask for a specific dpid. Just use the datapaths API without any options to see what the controller knows about dpids.
Now we are ready to click on the other API’s and test drive them.
exploreapi
Now for a little bad news…Currently the HP VAN SDN controller is not aware of any network devices (dpids) so your exploration is a bit boring. We need to fire up a test network with a tool called mininet. To do this look on the desktop of the DevOps station. You will see a notepad file with start mininet. Double click the file and it will open in the default editor. Look for the IP address (should be xx.xx.xx.xx) Change the IP address to match the IP address of the HP VAN SDN controller. Open up a mate terminal and paste the command and hit enter.
startmn
You will see mininet start up and load the hosts and switches. It will finish at a mininet prompt. At the prompt enter the command pingall to generate some interesting traffic.
pingall
Now go back and start looking around for nodes, datapaths and links. You will start seeing some interesting and familiar things like IP addresses and MAC addresses and switch port numbers. Get familiar with these API’s and what they are capable of. We will be writing python applications to take advantage of them in the next post.
Happy Exploring!

API programming with python for HP VAN SDN Controller

Part One: Getting your API lab up and running
DISCLAIMER: You can only trust a mad scientist so much!

If you’re an occasional visitor to this blog then you will know that I have a “thing” for API’s, or Application Program Interfaces. Seems everybody has one these days so why not learn how to take advantage of them. Before we get started we will need a test lab where we can test our creations without bringing down the production network, a career limiting move (CLM).
api_dc
So without spending any money, you can build a virtualized lab to run a couple Virtual Machines right on your laptop (recommend you have minimum 8 gig of RAM). You will need to run two VM’s. One will be the HP VAN SDN controller and the other will be a L.A.M.P. (Linux, Apache, MySQL and Php) server.
lamp_plat
Luckily, I have these to VM’s prebuilt and sitting on my ftp server in a huge zip file with lots of other goodies. The following picture shows the ftp location and credentials. Once you get this downloaded (sorry if you’re still using 56k dial up) we can take the next step to getting the lab up and running.
demo_lab
OK, got the zip file, check….It has been extracted to some folder on your computer, check….you have identified the two “OVA” files we will import into Oracle Virtual Box (“HP VAN SDN Controller 2.3.5.ova” and “My New DevOps Box.ova”), check…..You have Virtualization Technology enabled you your PC…….do it now!!!!…..check…..You have the latest copy Oracle Virtual Box downloaded and installed……OK, I’ll wait…….you think you would have done this by now…OK…check. We are ready to import the OVA’s into Oracle Virtual Box (OVB).
Open OVB and from the main menu select File>>Import……check!
ovb_1
Once you have selected to VM to import click on NEXT and IMPORT…Just a few secs to wait here.
ovb_2
Now we have just a few changes to make to the VM settings to get this VM to be a part of our network. We will set the NIC (Network Interface Card) to be bridged mode. This is handy if you are running DHCP on the host network. You will do this for both virtual machines. The following picture will guide you through this process.
ovb_3
Now that we have the NIC configured properly we can start up the virtual machines and log in and take a look around. You will repeat the process depicted with both VM’s.
ovb_4
Now for a little bad news…the VM’s that you just started are Linux distros of Ubuntu. One with a GUI and the other without. The HP VAN SDN Controller will have a user of sdn and a password of skyline and the LAMP server will have a user of rick with a password of siesta3.
You will need a bare minimum of linux chops to complete this tutorial so here they are.
sudo
I will leave you here at this spot so you can practice your linux commands. On the desktop of the LAMP server is an icon for a MATE terminal. Double-click it and a terminal window will appear. Enter the command ifconfig and look at the IP address your LAMP server is assigned ….write it down. On the SDN controller there is no GUI so from the initial prompt enter ifconfig to see what IP address it was assigned and write it down.
Finally, to check to see if your SDN controller is operational lets go to the LAMP server and from the application menu, slide down to Internet then over to Chromium Web Browser. Once the browser launches enter https://ip_address_of_sdn_controller:8443/sdn/ui. It should look like the picture below.
sdn
Enter the credentials from above and navigate some of the menus. You are now ready to take the next step..stay tuned.