Proposal: Remove REST call to clear switch flow tables
Change-Id: I22f233cf554a59cb44851bde0f1aa96a7c67709a
diff --git a/src/main/java/net/floodlightcontroller/core/internal/Controller.java b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
index 42fb3c6..39bdf3c 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/Controller.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/Controller.java
@@ -61,7 +61,6 @@
import net.floodlightcontroller.restserver.IRestApiService;
import net.floodlightcontroller.threadpool.IThreadPoolService;
import net.onrc.onos.ofcontroller.core.IOFSwitchPortListener;
-import net.onrc.onos.ofcontroller.core.web.OnosInternalWebRoutable;
import net.onrc.onos.ofcontroller.linkdiscovery.ILinkDiscoveryService;
import net.onrc.onos.registry.controller.IControllerRegistryService;
import net.onrc.onos.registry.controller.IControllerRegistryService.ControlChangeCallback;
@@ -1832,7 +1831,6 @@
// Add our REST API
restApi.addRestletRoutable(new CoreWebRoutable());
- restApi.addRestletRoutable(new OnosInternalWebRoutable());
}
@Override
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/web/ClearFlowTableResource.java b/src/main/java/net/onrc/onos/ofcontroller/core/web/ClearFlowTableResource.java
deleted file mode 100644
index fe70877..0000000
--- a/src/main/java/net/onrc/onos/ofcontroller/core/web/ClearFlowTableResource.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package net.onrc.onos.ofcontroller.core.web;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import net.floodlightcontroller.core.IFloodlightProviderService;
-import net.floodlightcontroller.core.IOFSwitch;
-
-import org.codehaus.jackson.map.ObjectMapper;
-import org.openflow.util.HexString;
-import org.restlet.resource.Post;
-import org.restlet.resource.ServerResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class ClearFlowTableResource extends ServerResource {
- final static Logger log = LoggerFactory.getLogger(ClearFlowTableResource.class);
-
- @Post("json")
- public List<String> ClearFlowTable(String jsonData){
- IFloodlightProviderService floodlightProvider =
- (IFloodlightProviderService) getContext().getAttributes()
- .get(IFloodlightProviderService.class.getCanonicalName());
-
- Map<Long, IOFSwitch> switches = floodlightProvider.getSwitches();
-
- List<String> response = new ArrayList<String>();
- ObjectMapper mapper = new ObjectMapper();
- String[] dpids = null;
- try {
- dpids = mapper.readValue(jsonData, String[].class);
- } catch (IOException e) {
- log.debug("Error parsing switch dpid array: {}", e.getMessage());
- response.add("Error parsing input");
- return response;
- }
-
-
- for (String dpid : dpids){
- IOFSwitch sw = switches.get(HexString.toLong(dpid));
- if (sw != null){
- sw.clearAllFlowMods();
- response.add(dpid + " cleared");
- }
- else {
- response.add(dpid + " not found");
- }
- }
-
- return response;
- }
-
-}
diff --git a/src/main/java/net/onrc/onos/ofcontroller/core/web/OnosInternalWebRoutable.java b/src/main/java/net/onrc/onos/ofcontroller/core/web/OnosInternalWebRoutable.java
deleted file mode 100644
index 78bb02b..0000000
--- a/src/main/java/net/onrc/onos/ofcontroller/core/web/OnosInternalWebRoutable.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package net.onrc.onos.ofcontroller.core.web;
-
-import org.restlet.Context;
-import org.restlet.Restlet;
-import org.restlet.routing.Router;
-
-import net.floodlightcontroller.restserver.RestletRoutable;
-
-public class OnosInternalWebRoutable implements RestletRoutable {
- @Override
- public String basePath() {
- return "/wm/onos/internal";
- }
-
- @Override
- public Restlet getRestlet(Context context) {
- Router router = new Router(context);
- // Following added by ONOS
- router.attach("/clearflowtable/json", ClearFlowTableResource.class);
- return router;
- }
-}
diff --git a/web/clear_core.py b/web/clear_core.py
deleted file mode 100755
index 36eadd6..0000000
--- a/web/clear_core.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#! /usr/bin/env python
-
-import os
-import json
-
-CONFIG_FILE=os.getenv("HOME") + "/ONOS/web/config.json"
-
-def read_config():
- global LB, TESTBED, controllers, core_switches, ONOS_GUI3_HOST, ONOS_GUI3_CONTROL_HOST
- f = open(CONFIG_FILE)
- conf = json.load(f)
- LB = conf['LB']
- TESTBED = conf['TESTBED']
- controllers = conf['controllers']
- core_switches=conf['core_switches']
- ONOS_GUI3_HOST=conf['ONOS_GUI3_HOST']
- ONOS_GUI3_CONTROL_HOST=conf['ONOS_GUI3_CONTROL_HOST']
- f.close()
-
-if __name__ == "__main__":
- onos_rest_port = 8080
- read_config()
-
- try:
- sw_list = json.dumps(core_switches)
- command = "curl -s -H 'Content-Type: application/json' -d '%s' http://%s:%s/wm/onos/internal/clearflowtable/json" % (sw_list, controllers[0], onos_rest_port)
-
- print command
- result = os.popen(command).read()
- print result
- except:
- print "REST IF has issue"
- exit