Construct GraphDescription with online/active Device/Link only
Change-Id: I9312c0c8ae190bf0200bd040823b6f7a3e7a15e1
diff --git a/core/api/src/main/java/org/onlab/onos/net/device/DeviceService.java b/core/api/src/main/java/org/onlab/onos/net/device/DeviceService.java
index d35b1af..7d2a0dd 100644
--- a/core/api/src/main/java/org/onlab/onos/net/device/DeviceService.java
+++ b/core/api/src/main/java/org/onlab/onos/net/device/DeviceService.java
@@ -44,6 +44,14 @@
Iterable<Device> getDevices();
/**
+ * Returns an iterable collection of all devices
+ * currently available to the system.
+ *
+ * @return device collection
+ */
+ Iterable<Device> getAvailableDevices();
+
+ /**
* Returns the device with the specified identifier.
*
* @param deviceId device identifier
diff --git a/core/api/src/main/java/org/onlab/onos/net/device/DeviceStore.java b/core/api/src/main/java/org/onlab/onos/net/device/DeviceStore.java
index bc0b5c1..ed86881 100644
--- a/core/api/src/main/java/org/onlab/onos/net/device/DeviceStore.java
+++ b/core/api/src/main/java/org/onlab/onos/net/device/DeviceStore.java
@@ -44,6 +44,15 @@
Iterable<Device> getDevices();
/**
+ * Returns an iterable collection of all devices currently available to the system.
+ *
+ * @return device collection
+ */
+ Iterable<Device> getAvailableDevices();
+
+
+
+ /**
* Returns the device with the specified identifier.
*
* @param deviceId device identifier
diff --git a/core/api/src/main/java/org/onlab/onos/net/link/LinkService.java b/core/api/src/main/java/org/onlab/onos/net/link/LinkService.java
index 2039aa5..58b01bf 100644
--- a/core/api/src/main/java/org/onlab/onos/net/link/LinkService.java
+++ b/core/api/src/main/java/org/onlab/onos/net/link/LinkService.java
@@ -41,6 +41,13 @@
Iterable<Link> getLinks();
/**
+ * Returns a collection of all active infrastructure links.
+ *
+ * @return all infrastructure links
+ */
+ Iterable<Link> getActiveLinks();
+
+ /**
* Returns set of all infrastructure links leading to and from the
* specified device.
*
diff --git a/core/api/src/test/java/org/onlab/onos/net/device/DeviceServiceAdapter.java b/core/api/src/test/java/org/onlab/onos/net/device/DeviceServiceAdapter.java
index 6b4ed3b..3d2d74f 100644
--- a/core/api/src/test/java/org/onlab/onos/net/device/DeviceServiceAdapter.java
+++ b/core/api/src/test/java/org/onlab/onos/net/device/DeviceServiceAdapter.java
@@ -21,6 +21,9 @@
import org.onlab.onos.net.Port;
import org.onlab.onos.net.PortNumber;
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
+
import java.util.List;
/**
@@ -38,6 +41,18 @@
}
@Override
+ public Iterable<Device> getAvailableDevices() {
+ return FluentIterable.from(getDevices())
+ .filter(new Predicate<Device>() {
+
+ @Override
+ public boolean apply(Device input) {
+ return isAvailable(input.id());
+ }
+ });
+ }
+
+ @Override
public Device getDevice(DeviceId deviceId) {
return null;
}
diff --git a/core/api/src/test/java/org/onlab/onos/net/link/LinkServiceAdapter.java b/core/api/src/test/java/org/onlab/onos/net/link/LinkServiceAdapter.java
index 0e25e2a..b22f0a5 100644
--- a/core/api/src/test/java/org/onlab/onos/net/link/LinkServiceAdapter.java
+++ b/core/api/src/test/java/org/onlab/onos/net/link/LinkServiceAdapter.java
@@ -20,6 +20,10 @@
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.Link;
+import org.onlab.onos.net.Link.State;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.FluentIterable;
/**
* Test adapter for link service.
@@ -36,6 +40,18 @@
}
@Override
+ public Iterable<Link> getActiveLinks() {
+ return FluentIterable.from(getLinks())
+ .filter(new Predicate<Link>() {
+
+ @Override
+ public boolean apply(Link input) {
+ return input.state() == State.ACTIVE;
+ }
+ });
+ }
+
+ @Override
public Set<Link> getDeviceLinks(DeviceId deviceId) {
return null;
}