Added Link REST and service for active links
diff --git a/src/main/java/net/floodlightcontroller/core/ISwitchStorage.java b/src/main/java/net/floodlightcontroller/core/ISwitchStorage.java
index 28e6a5d..5e81000 100644
--- a/src/main/java/net/floodlightcontroller/core/ISwitchStorage.java
+++ b/src/main/java/net/floodlightcontroller/core/ISwitchStorage.java
@@ -1,20 +1,15 @@
package net.floodlightcontroller.core;
import java.util.Collection;
-import java.util.List;
-
-import org.codehaus.jackson.annotate.JsonAutoDetect;
-import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.codehaus.jackson.map.ser.StdSerializers;
import org.openflow.protocol.OFPhysicalPort;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.frames.Adjacency;
import com.tinkerpop.frames.Incidence;
import com.tinkerpop.frames.Property;
+import com.tinkerpop.frames.VertexFrame;
public interface ISwitchStorage extends INetMapStorage {
@@ -23,7 +18,7 @@
ACTIVE
}
- public interface ISwitchObject {
+ public interface ISwitchObject extends VertexFrame{
@JsonProperty("dpid")
@Property("dpid")
@@ -42,7 +37,7 @@
public Iterable<IPortObject> getPorts();
}
- public interface IPortObject {
+ public interface IPortObject extends VertexFrame{
@JsonProperty("state")
@Property("state")
@@ -63,6 +58,10 @@
@JsonIgnore
@Incidence(label="on",direction = Direction.IN)
public ISwitchObject getSwitch();
+
+// @JsonIgnore
+// @Adjacency(label="link")
+// public Iterable<ILinkObject> getLinks();
}
/*
* Update the switch details
diff --git a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImpl.java b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImpl.java
index bf5aaf7..5ffd9bc 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/OFSwitchImpl.java
@@ -48,7 +48,7 @@
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.codehaus.jackson.map.ser.ToStringSerializer;
+import org.codehaus.jackson.map.ser.std.ToStringSerializer;
import org.jboss.netty.channel.Channel;
import org.openflow.protocol.OFFeaturesReply;
import org.openflow.protocol.OFFeaturesRequest;
diff --git a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
index dbb985e..1e14b05 100644
--- a/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
+++ b/src/main/java/net/floodlightcontroller/core/internal/SwitchStorageImpl.java
@@ -20,6 +20,8 @@
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.frames.FramedGraph;
+import com.tinkerpop.gremlin.java.GremlinPipeline;
+
import net.floodlightcontroller.core.ISwitchStorage;
public class SwitchStorageImpl implements ISwitchStorage {
@@ -53,11 +55,11 @@
if ((sw = graph.getVertices("dpid",dpid).iterator().next()) != null) {
sw.setProperty("state",state.toString());
graph.stopTransaction(Conclusion.SUCCESS);
- log.info("SwitchStorage:setSTatus dpid:{} state: {} done", dpid, state);
+ log.info("SwitchStorage:setStatus dpid:{} state: {} done", dpid, state);
}
} catch (TitanException e) {
// TODO: handle exceptions
- log.info("SwitchStorage:setSTatus dpid:{} state: {} failed", dpid, state);
+ log.info("SwitchStorage:setStatus dpid:{} state: {} failed", dpid, state);
}
@@ -204,14 +206,14 @@
FramedGraph<TitanGraph> fg = new FramedGraph<TitanGraph>(graph);
Iterable<ISwitchObject> switches = fg.getVertices("type","switch",ISwitchObject.class);
List<ISwitchObject> activeSwitches = new ArrayList<ISwitchObject>();
-
+
for (ISwitchObject sw: switches) {
if(sw.getState().equals(SwitchState.ACTIVE.toString())) {
activeSwitches.add(sw);
}
}
-
- return activeSwitches;
+
+ return activeSwitches;
}
@Override
@@ -250,14 +252,14 @@
FramedGraph<TitanGraph> fg = new FramedGraph<TitanGraph>(graph);
Iterable<ISwitchObject> switches = fg.getVertices("type","switch",ISwitchObject.class);
- List<ISwitchObject> inActiveSwitches = new ArrayList<ISwitchObject>();
+ List<ISwitchObject> inactiveSwitches = new ArrayList<ISwitchObject>();
for (ISwitchObject sw: switches) {
if(sw.getState().equals(SwitchState.INACTIVE.toString())) {
- inActiveSwitches.add(sw);
+ inactiveSwitches.add(sw);
}
}
- return inActiveSwitches;
+ return inactiveSwitches;
}
diff --git a/src/main/java/net/floodlightcontroller/core/web/CoreWebRoutable.java b/src/main/java/net/floodlightcontroller/core/web/CoreWebRoutable.java
index 0c41259..a3c5c01 100644
--- a/src/main/java/net/floodlightcontroller/core/web/CoreWebRoutable.java
+++ b/src/main/java/net/floodlightcontroller/core/web/CoreWebRoutable.java
@@ -18,6 +18,7 @@
package net.floodlightcontroller.core.web;
import net.floodlightcontroller.core.module.ModuleLoaderResource;
+import net.floodlightcontroller.linkdiscovery.web.TopoLinksResource;
import net.floodlightcontroller.restserver.RestletRoutable;
import org.restlet.Context;
@@ -61,6 +62,7 @@
router.attach("/health/json", HealthCheckResource.class);
router.attach("/system/uptime/json", SystemUptimeResource.class);
router.attach("/topology/switches/{filter}/json", TopoSwitchesResource.class);
+ router.attach("/topology/links/json", TopoLinksResource.class);
return router;
}
}