Following on from the previous post on Software-Defined Networks (SDN), we are going to have a quick look at Cisco's onePK.
onePK and the Software Defined Network
onePK stands for One Platform Kit, its what gets us started with programming for the Cisco Open Network Environment. It is basically a set of APIs for programming your network devices (IOS, IOS-XE, IOS-XR and NX-OS) in C (well C64 to be more exact), Java and Python.From Cisco's website (you'll need a CCO login for this) you can download the onePK all-in-one image for Ubuntu, which can run very nicely in VirtualBox. It is a 2.61Gb image that contains everything you'll need to get started, including 3 IOSv routers and the Eclipse IDE.
I downloaded the all-in-one VM and fired it up, but learned that before you do this you need to make sure that the second adapter is set to a host-only adapter. If you get an error that one cannot be found then go to preferences (of VirtualBox - not of the VM), select Network, click on Host-only Networks, and click add to create one:
Once it's installed into VirtualBox login in as "cisco" with a password of "cisco123" and change the password when prompted. Set the Network Simulator Credentials (I used 802101 for both), which is the username and password needed to communicate with the virtual routers.
Double click on Start 3node - if you get an error here then its probably due to lack of a host-only network - so make sure it's there and connected.
Once it's done you get a confirmation:
After you have clicked OK to the above message your routers start up:
At this point it should be pointed out that the onePK vm gets a little funny about switching back and forth in order to take screenshots. I stopped the VM, added a DVD drive and installed the Guest Additions. Once done I needed to use the Stop 3node icon and then use Start 3node to get my routers back again.
With the Guest Additions making life much easier we can have a quick look at the config of our router, nothing hugely out of the ordinary here, we have a bunch of interfaces:
The only real thing of note is the onep settings:
Enabling a supported device for onep is as simple as entering "onep" at the configuration prompt, then from the sub-prompt enabling the tls transport:
router(config)#onep router(config-onep)#transport tlsLet's try and actually do something now though.
From the desktop doubleclick on the CreateCA icon. This generates the certificate needed for communication between the nodes and the controller. At the moment I am following the instructions from the Cisco website, which follow the rule that any introduction to anything even vaguely programming orientated starts with a "Hello" example, so from the Terminal prompt on the desktop change directory (cd) to /home/cisco/onePK-sdk-1.2.0.173/c/sample-apps/HelloNetwork and run the "make" command. Once thats run through run the following:
cisco@onepk:~/onePK-sdk-1.2.0.173/c/sample-apps/HelloNetwork$ ./bin/HelloNetwork -a router1.3node.example.com -R ~/ca.pem Enter username: 802101 Enter password: Connecting with onep transport type TLS. Router1 says: Hello Network! cisco@onepk:~/onePK-sdk-1.2.0.173/c/sample-apps/HelloNetwork$I can tell you are impressed!
To prove that the application is actually doing something we can see the router's log for the connection:
We can change the routers name:
And we can run the command again and see the reflected change:
cisco@onepk:~/onePK-sdk-1.2.0.173/c/sample-apps/HelloNetwork$ ./bin/HelloNetwork -a router1.3node.example.com -R ~/ca.pem Enter username: 802101 Enter password: Connecting with onep transport type TLS. MyFirstRouter says: Hello Network! cisco@onepk:~/onePK-sdk-1.2.0.173/c/sample-apps/HelloNetwork$I havn't touched C programming since my university days, but onePK also supports Java and Python, so it should suit most developers in one language or another. Running a python script follows the same syntax, here is one that will get the contents of the RIB:
cisco@onepk:~/onePK-sdk-1.2.0.173/python/tutorials/routing$ ./RIBTutorial.py -a router1.3node.example.com -R ~/ca.pem INFO:onep:RIBTutorial:Reading arguments... Enter Username : 802101 Enter Password : INFO:onep:RIBTutorial:Connecting to Network Element... INFO:onep:BaseTutorial:We have a NetworkElement : NetworkElement [ router1.3node.example.com ] INFO:onep:BaseTutorial:Successful connection to NetworkElement - INFO:onep:RIBTutorial:Done INFO:onep:RIBTutorial:Getting a Routing Instance... INFO:onep:RIBTutorial:Getting a RIB... INFO:onep:RIBTutorial:adding RIB listener... INFO:onep:RIBTutorial:1001 INFO:onep:RIBTutorial:Routes are : INFO:onep:RIBTutorial:L3UnicastRoute[address:10.10.10.0/24,ownerType:CONNECTED,ownerTag:,adminDistance:0,metric:0,errorCode:0] INFO:onep:RIBTutorial:L3UnicastRoute[address:10.10.10.110/32,ownerType:LOCAL,ownerTag:,adminDistance:0,metric:0,errorCode:0] INFO:onep:RIBTutorial:L3UnicastRoute[address:10.10.20.0/24,ownerType:CONNECTED,ownerTag:,adminDistance:0,metric:0,errorCode:0] INFO:onep:RIBTutorial:L3UnicastRoute[address:10.10.20.110/32,ownerType:LOCAL,ownerTag:,adminDistance:0,metric:0,errorCode:0] INFO:onep:RIBTutorial:L3UnicastRoute[address:10.10.30.0/24,ownerType:CONNECTED,ownerTag:,adminDistance:0,metric:0,errorCode:0] INFO:onep:RIBTutorial:L3UnicastRoute[address:10.10.30.110/32,ownerType:LOCAL,ownerTag:,adminDistance:0,metric:0,errorCode:0] INFO:onep:RIBTutorial:L3UnicastRoute[address:192.168.56.0/24,ownerType:CONNECTED,ownerTag:,adminDistance:0,metric:0,errorCode:0] INFO:onep:RIBTutorial:L3UnicastRoute[address:192.168.56.111/32,ownerType:LOCAL,ownerTag:,adminDistance:0,metric:0,errorCode:0] cisco@onepk:~/onePK-sdk-1.2.0.173/python/tutorials/routing$Anything that can be done on the router can be done through a script, which is great when making changes to multiple routers. Yes I know you can use cut and paste, but somethings require a certain level of out-of-band management, and onePK is just the ticket.
This has only been a really simple walk through, hopefully when I get some time I'll put together something on how to create a script with the onePK API, for now I encourage you to have a look to get a feel for the possibilities that this opens up.
5 comments
commentsHow to use vmmastro instead launch images like this.
Replythey use one singe image and create 3 qemu kvm based router.
I don't think you can, its a very self contained environment. I did try getting the OVA file out and importing it into VirtualBox, but it bluescreened on me.
ReplyStill testing...
I just want ask something, how can i change the password for the network simulators, because when ever i try to run tutorials it always give this error(invalid credentials)
ReplyI just want ask something, how can i change the password for the network simulators, because when ever i try to run tutorials it always give this error(invalid credentials)
Reply