floodlight控制器用PHP重新写webUI
floodlight控制器用PHP重新写webUI
大家都知道floodlight本身的webUI是localhost/ui/index.html
1.我试着用我的Linux环境架另一个服务器来提供php的环境。可以参考我的另一篇文章。关于怎么架构lamp。
2.Proxy 我们在宿主机上又搭建了一台服务器,后端即Command Proxy负责转发前端Web Interface的操作请求给Floodlight。
由于ajax不能跨域请求,所以建立了一个服务器端代理。Command Proxy是我们用PHP编写的一个后端脚本,它用来转发Web Interface的请求或者执行Web Interface发送的命令。
3.接着把整个PHP写的webUI放在var/www/html里面。就是floodlight那个resource里面那个web;
4.然后解决floodlight与webUI之间的通信问题
在floodlight里面改路径:
/**
* Copyright 2013, Big Switch Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "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/";
}
}
在web UI里面加入一个manifest.mf (可自行Google)
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
然后在浏览器里面就可以看到PHP写的网页了
查看网络拓扑图
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。