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!

Leave a Reply

Your email address will not be published. Required fields are marked *