floodlight Controller re-write WebUI in PHP
We all know that the webui of floodlight itself is localhost/ui/index.html
1. I tried to use my Linux environment to rack another server to provide PHP environment. You can refer to one of my other articles. about how to structure lamp.
2.Proxy we set up a server on the host, and the backend command proxy is responsible for forwarding the front-end Web interface operation request to floodlight.
Because Ajax cannot cross-domain requests, a server-side proxy is established. Command Proxy is a back-end script that we write in PHP that is used to forward requests for web interface or to execute commands sent by web interface.
3. Then put the entire PHP write WebUI in var/www/html. is floodlight that resource inside that web;
4. Then solve the communication problem between Floodlight and WebUI
Change the path inside the floodlight:
/**
* Copyright, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); May
* Not use this file except in compliance with the License. Obtain
* A copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable or agreed to writing, software
* Distributed under the License is distributed on a "as is" BASIS, without
* Warranties or CONDITIONS of any KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* Under the License.
**/
Package net.floodlightcontroller.ui.web;
Import java.util.ArrayList;
Import java.util.Collection;
Import Java.util.Map;
Import org.restlet.Client;
Import Org.restlet.Context;
Import Org.restlet.Restlet;
Import Org.restlet.data.Protocol;
Import Org.restlet.resource.Directory;
Import Org.restlet.routing.Router;
Import Net.floodlightcontroller.core.module.FloodlightModuleContext;
Import net.floodlightcontroller.core.module.FloodlightModuleException;
Import Net.floodlightcontroller.core.module.IFloodlightModule;
Import Net.floodlightcontroller.core.module.IFloodlightService;
Import Net.floodlightcontroller.restserver.IRestApiService;
Import net.floodlightcontroller.restserver.RestletRoutable;
public class Staticwebroutable implements Restletroutable, Ifloodlightmodule {
Private Irestapiservice Restapi;
@Override
Public collection<class<? Extends Ifloodlightservice>> getmoduledependencies () {
collection<class<? Extends ifloodlightservice>> L =
New Arraylist<class<? Extends Ifloodlightservice>> ();
L.add (Irestapiservice.class);
return l;
}
@Override
Public collection<class<? Extends Ifloodlightservice>> getmoduleservices () {
return null;
}
@Override
Public map<class<? Extends Ifloodlightservice>, ifloodlightservice>
Getserviceimpls () {
return null;
}
@Override
public void init (Floodlightmodulecontext context)
Throws Floodlightmoduleexception {
Restapi = Context.getserviceimpl (Irestapiservice.class);
}
@Override
public void StartUp (Floodlightmodulecontext context) {
Add our REST API
Restapi.addrestletroutable (this);
}
@Override
Public Restlet Getrestlet (context context) {
Router Router = new Router (context);
Router.attach ("", New Directory (context, "clap://var/www/html/floodlightui/index.html"));
Context.setclientdispatcher (New Client (context, protocol.clap));
return router;
}
@Override
Public String BasePath () {
return "/floodlightui/";
}
}
Add a MANIFEST.MF to your Web UI (Google yourself)
manifest-version:1.0
Main-class:/home/ubuntu/floodlight/src/main/java/net/floodlightcontroller/core/main.java
Class-path:/home/ubuntu/floodlight/lib/oro/jakarta-oro-2.0.8.jar
/home/ubuntu/floodlight/lib/args4j-2.0.16.jar
/home/ubuntu/floodlight/lib/asm-3.0.jar
/home/ubuntu/floodlight/lib/asm-tree-3.0.jar
/home/ubuntu/floodlight/lib/cglib-nodep-2.2.2.jar
/home/ubuntu/floodlight/lib/cobertura-1.9.4.1.jar
/home/ubuntu/floodlight/lib/concurrentlinkedhashmap-lru-1.2.jar
/home/ubuntu/floodlight/lib/derby-10.9.1.0.jar
/home/ubuntu/floodlight/lib/findbugs-annotations-2.0.1.jar
/home/ubuntu/floodlight/lib/findbugs-jsr305-2.0.1.jar
/home/ubuntu/floodlight/lib/guava-13.0.1.jar
/home/ubuntu/floodlight/lib/jackson-annotations-2.1.4.jar
/home/ubuntu/floodlight/lib/jackson-core-2.1.4.jar
/home/ubuntu/floodlight/lib/jackson-databind-2.1.4.jar
/home/ubuntu/floodlight/lib/jackson-dataformat-csv-2.1.4.jar
/home/ubuntu/floodlight/lib/jackson-dataformat-smile-2.1.4.jar
/home/ubuntu/floodlight/lib/jackson-dataformat-xml-2.1.4.jar
/home/ubuntu/floodlight/lib/jackson-dataformat-yaml-2.1.4.jar
/home/ubuntu/floodlight/lib/jdeb-1.0.1.jar
/home/ubuntu/floodlight/lib/junit-4.8.2.jar
/home/ubuntu/floodlight/lib/jython-2.5.2.jar
/home/ubuntu/floodlight/lib/libthrift-0.9.0.jar
/home/ubuntu/floodlight/lib/log4j-1.2.9.jar
/home/ubuntu/floodlight/lib/logback-classic-1.0.0.jar
/home/ubuntu/floodlight/lib/logback-core-1.0.0.jar
/home/ubuntu/floodlight/lib/netty-3.2.6.final.jar
/home/ubuntu/floodlight/lib/objenesis-1.2.jar
/home/ubuntu/floodlight/lib/org.easymock-3.1.jar
/home/ubuntu/floodlight/lib/org.restlet-2.2m3.jar
/home/ubuntu/floodlight/lib/org.restlet.ext.jackson-2.2m3.jar
/home/ubuntu/floodlight/lib/org.restlet.ext.simple-2.2m3.jar
/home/ubuntu/floodlight/lib/org.restlet.ext.slf4j-2.2m3.jar
/home/ubuntu/floodlight/lib/packetstreamer-thrift.jar
/home/ubuntu/floodlight/lib/simple-5.1.1.jar
/home/ubuntu/floodlight/lib/slf4j-api-1.6.4.jar
Then you can see the PHP page in the browser.
View network topology diagram
Floodlight controller re-write WebUI in PHP