Renamed SDN-IP packages and classes.
The code use to use the name 'BgpRoute' in a number of places, which is not
descriptive and doesn't map to how we talk about SDN-IP (we always call it
SDN-IP in all other documents/presentations).
Details of changes are as follows:
net.onrc.onos.apps.bgproute -> net.onrc.onos.apps.sdnip
BgpRoute.java -> SdnIp.java
IBgpRouteService.java -> ISdnIpService.java
created new package for web classes: net.onrc.onos.apps.sdnip.web
BgpRouteResource.java -> IncomingRequestResource.java
BgpRouteResourceSynch.java -> OutgoingRequestResource.java
BgpRouteWebRoutable.java -> SdnIpWebRoutable.java
Change-Id: Ie6b1cbe4e95736d4cbd53b9f4def7cc3e0b46132
diff --git a/src/main/java/net/onrc/onos/apps/sdnip/web/OutgoingRequestResource.java b/src/main/java/net/onrc/onos/apps/sdnip/web/OutgoingRequestResource.java
new file mode 100644
index 0000000..772bf7d
--- /dev/null
+++ b/src/main/java/net/onrc/onos/apps/sdnip/web/OutgoingRequestResource.java
@@ -0,0 +1,88 @@
+package net.onrc.onos.apps.sdnip.web;
+
+import net.onrc.onos.apps.sdnip.ISdnIpService;
+import net.onrc.onos.apps.sdnip.RestClient;
+
+import org.restlet.resource.Delete;
+import org.restlet.resource.Post;
+import org.restlet.resource.ServerResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * REST handler for sending commands to SDN-IP. This interface is intended for
+ * operators or developers to change the route table of BGPd. There are
+ * interfaces for both sending new routes and deleting routes. This is
+ * not intended to be used during general operation. It is to have a way to
+ * influence BGPd's behavior for debugging.
+ */
+public class OutgoingRequestResource extends ServerResource {
+ private static final Logger log = LoggerFactory.getLogger(OutgoingRequestResource.class);
+
+ /**
+ * Handles a REST call to SDN-IP which gives a command to send a new route
+ * to BGPd.
+ *
+ * @return a String describing the result of the operation
+ */
+ @Post
+ public String handlePostMethod() {
+
+ ISdnIpService sdnIp = (ISdnIpService) getContext().getAttributes().
+ get(ISdnIpService.class.getCanonicalName());
+
+ String routerId = (String) getRequestAttributes().get("routerid");
+ String prefix = (String) getRequestAttributes().get("prefix");
+ String mask = (String) getRequestAttributes().get("mask");
+ String nexthop = (String) getRequestAttributes().get("nexthop");
+
+ String bgpdRestIp = sdnIp.getBgpdRestIp();
+
+ // bgpdRestIp includes port number, e.g. 1.1.1.1:8080
+ RestClient.post("http://" + bgpdRestIp + "/wm/bgp/" + routerId + "/" + prefix + "/"
+ + mask + "/" + nexthop);
+
+ String reply = "";
+ reply = "[POST: " + prefix + "/" + mask + ":" + nexthop + "/synch]";
+ log.info(reply);
+
+ return reply + "\n";
+
+ }
+
+ /**
+ * Handles a REST call to SDN-IP which gives a command to BGPd to delete a
+ * route from its route table.
+ *
+ * @return a String description of the result of the operation
+ */
+ @Delete
+ public String handleDeleteMethod() {
+ ISdnIpService sdnIp = (ISdnIpService) getContext().getAttributes().
+ get(ISdnIpService.class.getCanonicalName());
+
+ String routerId = (String) getRequestAttributes().get("routerid");
+ String prefix = (String) getRequestAttributes().get("prefix");
+ String mask = (String) getRequestAttributes().get("mask");
+ String nextHop = (String) getRequestAttributes().get("nexthop");
+
+ StringBuilder reply = new StringBuilder();
+
+ String bgpdRestIp = sdnIp.getBgpdRestIp();
+
+ RestClient.delete("http://" + bgpdRestIp + "/wm/bgp/" + routerId + "/" + prefix + "/"
+ + mask + "/" + nextHop);
+
+ reply.append("[DELE: ")
+ .append(prefix)
+ .append('/')
+ .append(mask)
+ .append(':')
+ .append(nextHop)
+ .append("/synch]");
+
+ log.info(reply.toString());
+
+ return reply.append("\n").toString();
+ }
+}