Merge branch 'clearhw'
diff --git a/src/main/java/net/floodlightcontroller/core/web/ClearFlowTableResource.java b/src/main/java/net/floodlightcontroller/core/web/ClearFlowTableResource.java
new file mode 100644
index 0000000..c2d2eb4
--- /dev/null
+++ b/src/main/java/net/floodlightcontroller/core/web/ClearFlowTableResource.java
@@ -0,0 +1,55 @@
+package net.floodlightcontroller.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 {
+	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/floodlightcontroller/core/web/CoreWebRoutable.java b/src/main/java/net/floodlightcontroller/core/web/CoreWebRoutable.java
index c110651..2bb39ef 100644
--- a/src/main/java/net/floodlightcontroller/core/web/CoreWebRoutable.java
+++ b/src/main/java/net/floodlightcontroller/core/web/CoreWebRoutable.java
@@ -65,6 +65,7 @@
         router.attach("/topology/switches/{filter}/json", TopoSwitchesResource.class);
         router.attach("/topology/links/json", TopoLinksResource.class);
         router.attach("/topology/devices/json", TopoDevicesResource.class);
+        router.attach("/clearflowtable/json", ClearFlowTableResource.class);
         return router;
     }
 }
diff --git a/web/clear_core.py b/web/clear_core.py
new file mode 100755
index 0000000..ea3e964
--- /dev/null
+++ b/web/clear_core.py
@@ -0,0 +1,33 @@
+#! /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/core/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