read more

Objective: “i want to be able to take a router that is enabled w/ Onep, then read its interfaces and put into a drop down menu…then have a list of Qos policies to select..then a button to deploy on the selected interface.”

Steps for setting up GUI for onePK

#We assume Python use, but the steps should follow similarly for using C or Java. 

1. Determine a server that is able to host a website and also has access to the hardware that will be controlled by onePK. 

2. Install the Python SDK on this server and point Python to your installation directory. Instructions are in the GettingStartedWithOnePK PDF. You can install the onePK SDK in a directory that Python already searches when “import” is used. I didn’t want to mess with existing packages just in case, so I installed into a far away directory. In order to get everything working (this took me a while), I put my application files (the files that I’ll actually be executing) in the “site-packages” (this is not advised: figure out another way) so that they rest beside the onep folder. Also in order to get the tutorial scripts running I had to include and its corresponding (this one may not be necessary though). 

2a. Modify/create a file called “” that is an adaptation of the “” file that’s in the tutorials. 

2b. Make sure that the router’s software is up to requirements for the given device. 

3. Get a certificate created by the router you are trying to connect to. (currently working on)

4. Run “./ -a -t tcp” to test that it works. 

Error is on line 106 in BaseTutorial, during the creation of a session handle. Seems as though the session config is the problem, and this problem resides in element/, in _get_vm_credentials. Believe this is due to router not running up to date onePK and so TCP ports were closed. 

5. Install Apache (using 2.4.9). Just use “apt-get install apache2”. 
	For the following, unpack using tar, run ./configure, then make, then make install. 
	5a) prereq: install apr and apr-util. 
	5b) prereq: install pcre 
		5ba) this may require c++ compiler, so install g++ “apt-get install g++”
6. Change the root directory for serving files for Apache from its default (/var/www) to where you have your onePK files. So go to /etc/apache2/sites-available/ and then sudo nano default and change /var/www to be /home/cisco/onePK/… 

6a (optional). You can go into your apache2.conf file whchi is in etc/apache2 and change the ServerRoot to be your onePK directory, that way you can just have an index.html file in there and it’ll automatically get loaded instead of having to manually append it in the URL.

7. Restart Apache to make sure it worked. Do a “sudo service apache2 restart”. 

8. Go to localhost/ to make sure that worked. 

9. In tutorials, create a file “test.cgi” that has “#!/usr/bin/python    \n    print “Content-type: text/html\n\n”    \n    print “hey”. Then go to it in terminal and make it executable (chmod +x test.cgi). 

10. Now we’re going to tell Apache to execute .cgi scripts in a given directory, so go to /etc/apache2/sites-available and then change/make sure the  ….  has  and Options ExecCGI \n AddHandler cgi-script .cgi \n  

11. Restart Apache, then go to localhost/test.cgi 

12. Write a cgi script that executes one of the python scripts (such as base tutorial) when the cgi script is executed. Navigate to this script using your browser to ensure it works. 

13. For debugging/general use, you’ll need the browser to display the output of the script that you’re executing, this can be done using “subprocess.Popen”, and the source code will be included with this doc. 

14. Now, you need to make it so that user input isn’t required for the script to execute. You should be able to eliminate all user input by creating defaults in, such as changing the connect line to have the string username and password of your router rather than prompting in the shell for it, and also for accepting all connections. The modified basetutorial file will be included as well. 

15. Now modify the NetworkInterfaceTutorial so that it only prints interface names, so where it says “printing all interfaces…” change inside the for loop to It’ll return a bunch of other stuff too, but we’ll parse through that later. 

16. Now you can make a general index.cgi which can at first be a copy of test.cgi, and you’ll need to modify that so that it filters out everything except the interface names and puts them inside a select for a drop down. 

17. Note about what we’re dealing with: a class-map groups traffic into groups, so you could have a class-map called VoIP traffic and put something under it. Not sure what you’re putting in yet. Then you can make a policy map which matches the classes that you created to how much bandwidth and/or priority you’r giving the traffic. Then you apply the policy-map to a given interface.