Added topology command-lines.
diff --git a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyService.java b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyService.java
index d8470e7..3469a55 100644
--- a/core/api/src/main/java/org/onlab/onos/net/topology/TopologyService.java
+++ b/core/api/src/main/java/org/onlab/onos/net/topology/TopologyService.java
@@ -2,6 +2,7 @@
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.net.Link;
import org.onlab.onos.net.Path;
import java.util.Set;
@@ -27,6 +28,14 @@
boolean isLatest(Topology topology);
/**
+ * Returns the graph view of the specified topology.
+ *
+ * @param topology topology descriptor
+ * @return topology graph view
+ */
+ TopologyGraph getGraph(Topology topology);
+
+ /**
* Returns the set of clusters in the specified topology.
*
* @param topology topology descriptor
@@ -35,12 +44,31 @@
Set<TopologyCluster> getClusters(Topology topology);
/**
- * Returns the graph view of the specified topology.
+ * Returns the cluster with the specified ID.
*
- * @param topology topology descriptor
- * @return topology graph view
+ * @param topology topology descriptor
+ * @param clusterId cluster identifier
+ * @return topology cluster
*/
- TopologyGraph getGraph(Topology topology);
+ TopologyCluster getCluster(Topology topology, ClusterId clusterId);
+
+ /**
+ * Returns the set of devices that belong to the specified cluster.
+ *
+ * @param topology topology descriptor
+ * @param cluster topology cluster
+ * @return set of cluster devices
+ */
+ Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster);
+
+ /**
+ * Returns the set of links that form the specified cluster.
+ *
+ * @param topology topology descriptor
+ * @param cluster topology cluster
+ * @return set of cluster links
+ */
+ Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster);
/**
* Returns the set of all shortest paths, precomputed in terms of hop-count,
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopology.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopology.java
index 86b88b3..ef87867 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopology.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/DefaultTopology.java
@@ -133,6 +133,17 @@
}
/**
+ * Returns the specified topology cluster.
+ *
+ * @param clusterId cluster identifier
+ * @return topology cluster
+ */
+ TopologyCluster getCluster(ClusterId clusterId) {
+ return clusters.get(clusterId);
+ }
+
+
+ /**
* Returns the set of cluster devices.
*
* @param cluster topology cluster
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/SimpleTopologyManager.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/SimpleTopologyManager.java
index 24bb256..6ad8f4b 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/SimpleTopologyManager.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/SimpleTopologyManager.java
@@ -11,9 +11,11 @@
import org.onlab.onos.event.EventDeliveryService;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.net.Link;
import org.onlab.onos.net.Path;
import org.onlab.onos.net.provider.AbstractProviderRegistry;
import org.onlab.onos.net.provider.AbstractProviderService;
+import org.onlab.onos.net.topology.ClusterId;
import org.onlab.onos.net.topology.GraphDescription;
import org.onlab.onos.net.topology.LinkWeight;
import org.onlab.onos.net.topology.Topology;
@@ -44,6 +46,8 @@
public static final String TOPOLOGY_NULL = "Topology cannot be null";
private static final String DEVICE_ID_NULL = "Device ID cannot be null";
+ private static final String CLUSTER_ID_NULL = "Cluster ID cannot be null";
+ private static final String CLUSTER_NULL = "Topology cluster cannot be null";
public static final String CONNECTION_POINT_NULL = "Connection point cannot be null";
private final Logger log = getLogger(getClass());
@@ -96,6 +100,27 @@
}
@Override
+ public TopologyCluster getCluster(Topology topology, ClusterId clusterId) {
+ checkNotNull(topology, TOPOLOGY_NULL);
+ checkNotNull(topology, CLUSTER_ID_NULL);
+ return store.getCluster(defaultTopology(topology), clusterId);
+ }
+
+ @Override
+ public Set<DeviceId> getClusterDevices(Topology topology, TopologyCluster cluster) {
+ checkNotNull(topology, TOPOLOGY_NULL);
+ checkNotNull(topology, CLUSTER_NULL);
+ return store.getClusterDevices(defaultTopology(topology), cluster);
+ }
+
+ @Override
+ public Set<Link> getClusterLinks(Topology topology, TopologyCluster cluster) {
+ checkNotNull(topology, TOPOLOGY_NULL);
+ checkNotNull(topology, CLUSTER_NULL);
+ return store.getClusterLinks(defaultTopology(topology), cluster);
+ }
+
+ @Override
public TopologyGraph getGraph(Topology topology) {
checkNotNull(topology, TOPOLOGY_NULL);
return store.getGraph(defaultTopology(topology));
diff --git a/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/SimpleTopologyStore.java b/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/SimpleTopologyStore.java
index b167dbc..f432ade 100644
--- a/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/SimpleTopologyStore.java
+++ b/core/trivial/src/main/java/org/onlab/onos/net/trivial/topology/impl/SimpleTopologyStore.java
@@ -3,8 +3,10 @@
import org.onlab.onos.event.Event;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.net.Link;
import org.onlab.onos.net.Path;
import org.onlab.onos.net.provider.ProviderId;
+import org.onlab.onos.net.topology.ClusterId;
import org.onlab.onos.net.topology.GraphDescription;
import org.onlab.onos.net.topology.LinkWeight;
import org.onlab.onos.net.topology.Topology;
@@ -44,6 +46,16 @@
}
/**
+ * Returns the immutable graph view of the current topology.
+ *
+ * @param topology topology descriptor
+ * @return graph view
+ */
+ TopologyGraph getGraph(DefaultTopology topology) {
+ return topology.getGraph();
+ }
+
+ /**
* Returns the set of topology SCC clusters.
*
* @param topology topology descriptor
@@ -54,13 +66,36 @@
}
/**
- * Returns the immutable graph view of the current topology.
+ * Returns the cluster of the specified topology.
*
- * @param topology topology descriptor
- * @return graph view
+ * @param topology topology descriptor
+ * @param clusterId cluster identity
+ * @return topology cluster
*/
- TopologyGraph getGraph(DefaultTopology topology) {
- return topology.getGraph();
+ TopologyCluster getCluster(DefaultTopology topology, ClusterId clusterId) {
+ return topology.getCluster(clusterId);
+ }
+
+ /**
+ * Returns the cluster of the specified topology.
+ *
+ * @param topology topology descriptor
+ * @param cluster topology cluster
+ * @return set of cluster links
+ */
+ Set<DeviceId> getClusterDevices(DefaultTopology topology, TopologyCluster cluster) {
+ return topology.getClusterDevices(cluster);
+ }
+
+ /**
+ * Returns the cluster of the specified topology.
+ *
+ * @param topology topology descriptor
+ * @param cluster topology cluster
+ * @return set of cluster links
+ */
+ Set<Link> getClusterLinks(DefaultTopology topology, TopologyCluster cluster) {
+ return topology.getClusterLinks(cluster);
}
/**