Enhanced DeviceDescription and added default implementation for it.
diff --git a/net/api/src/main/java/org/onlab/onos/net/Element.java b/net/api/src/main/java/org/onlab/onos/net/Element.java
index c11d103..5d3969e 100644
--- a/net/api/src/main/java/org/onlab/onos/net/Element.java
+++ b/net/api/src/main/java/org/onlab/onos/net/Element.java
@@ -1,7 +1,5 @@
package org.onlab.onos.net;
-import org.onlab.onos.net.provider.Provided;
-
/**
* Base abstraction of a network element, i.e. an infrastructure device or an end-station host.
*/
diff --git a/net/api/src/main/java/org/onlab/onos/net/Link.java b/net/api/src/main/java/org/onlab/onos/net/Link.java
index 75e026d..38b6f69 100644
--- a/net/api/src/main/java/org/onlab/onos/net/Link.java
+++ b/net/api/src/main/java/org/onlab/onos/net/Link.java
@@ -1,7 +1,5 @@
package org.onlab.onos.net;
-import org.onlab.onos.net.provider.Provided;
-
/**
* Abstraction of a network infrastructure link.
*/
diff --git a/net/api/src/main/java/org/onlab/onos/net/provider/Provided.java b/net/api/src/main/java/org/onlab/onos/net/Provided.java
similarity index 77%
rename from net/api/src/main/java/org/onlab/onos/net/provider/Provided.java
rename to net/api/src/main/java/org/onlab/onos/net/Provided.java
index 89364c2..92bfe95 100644
--- a/net/api/src/main/java/org/onlab/onos/net/provider/Provided.java
+++ b/net/api/src/main/java/org/onlab/onos/net/Provided.java
@@ -1,4 +1,6 @@
-package org.onlab.onos.net.provider;
+package org.onlab.onos.net;
+
+import org.onlab.onos.net.provider.ProviderId;
/**
* Abstraction of an entity supplied by a provider.
diff --git a/net/api/src/main/java/org/onlab/onos/net/Topology.java b/net/api/src/main/java/org/onlab/onos/net/Topology.java
index c8a01e9..ed1bfb5 100644
--- a/net/api/src/main/java/org/onlab/onos/net/Topology.java
+++ b/net/api/src/main/java/org/onlab/onos/net/Topology.java
@@ -3,7 +3,7 @@
/**
* Represents a network topology computation snapshot.
*/
-public interface Topology {
+public interface Topology extends Provided {
/**
* Returns the time, specified in milliseconds since start of epoch,
diff --git a/net/api/src/main/java/org/onlab/onos/net/device/DefaultDeviceDescription.java b/net/api/src/main/java/org/onlab/onos/net/device/DefaultDeviceDescription.java
new file mode 100644
index 0000000..3d340b2
--- /dev/null
+++ b/net/api/src/main/java/org/onlab/onos/net/device/DefaultDeviceDescription.java
@@ -0,0 +1,80 @@
+package org.onlab.onos.net.device;
+
+import java.net.URI;
+
+import static com.google.common.base.Objects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onlab.onos.net.Device.Type;
+
+/**
+ * Default implementation of immutable device description entity.
+ */
+public class DefaultDeviceDescription implements DeviceDescription {
+ private final URI uri;
+ private final Type type;
+ private final String manufacturer;
+ private final String hwVersion;
+ private final String swVersion;
+ private final String serialNumber;
+
+ /**
+ * Creates a device description using the supplied information.
+ *
+ * @param uri device URI
+ * @param type device type
+ * @param manufacturer device manufacturer
+ * @param hwVersion device HW version
+ * @param swVersion device SW version
+ * @param serialNumber device serial number
+ */
+ public DefaultDeviceDescription(URI uri, Type type, String manufacturer,
+ String hwVersion, String swVersion,
+ String serialNumber) {
+ this.uri = checkNotNull(uri, "Device URI cannot be null");
+ this.type = checkNotNull(type, "Device type cannot be null");
+ this.manufacturer = manufacturer;
+ this.hwVersion = hwVersion;
+ this.swVersion = swVersion;
+ this.serialNumber = serialNumber;
+ }
+
+ @Override
+ public URI deviceURI() {
+ return uri;
+ }
+
+ @Override
+ public Type type() {
+ return type;
+ }
+
+ @Override
+ public String manufacturer() {
+ return manufacturer;
+ }
+
+ @Override
+ public String hwVersion() {
+ return hwVersion;
+ }
+
+ @Override
+ public String swVersion() {
+ return swVersion;
+ }
+
+ @Override
+ public String serialNumber() {
+ return serialNumber;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("uri", uri).add("type", type).add("mfr", manufacturer)
+ .add("hw", hwVersion).add("sw", swVersion)
+ .add("serial", serialNumber)
+ .toString();
+ }
+
+}
diff --git a/net/api/src/main/java/org/onlab/onos/net/device/DefaultPortDescription.java b/net/api/src/main/java/org/onlab/onos/net/device/DefaultPortDescription.java
new file mode 100644
index 0000000..c171098
--- /dev/null
+++ b/net/api/src/main/java/org/onlab/onos/net/device/DefaultPortDescription.java
@@ -0,0 +1,7 @@
+package org.onlab.onos.net.device;
+
+/**
+ * Default implementation of immutable port description.
+ */
+public class DefaultPortDescription implements PortDescription {
+}
diff --git a/net/api/src/main/java/org/onlab/onos/net/device/DeviceDescription.java b/net/api/src/main/java/org/onlab/onos/net/device/DeviceDescription.java
index 2b83890..e32c19d 100644
--- a/net/api/src/main/java/org/onlab/onos/net/device/DeviceDescription.java
+++ b/net/api/src/main/java/org/onlab/onos/net/device/DeviceDescription.java
@@ -1,6 +1,7 @@
package org.onlab.onos.net.device;
import org.onlab.onos.net.Description;
+import org.onlab.onos.net.Device;
import java.net.URI;
@@ -18,4 +19,39 @@
*/
URI deviceURI();
+ /**
+ * Returns the type of the infrastructure device.
+ *
+ * @return type of the device
+ */
+ Device.Type type();
+
+ /**
+ * Returns the device manufacturer name.
+ *
+ * @return manufacturer name
+ */
+ String manufacturer();
+
+ /**
+ * Returns the device hardware version.
+ *
+ * @return hardware version
+ */
+ String hwVersion();
+
+ /**
+ * Returns the device software version.
+ *
+ * @return software version
+ */
+ String swVersion();
+
+ /**
+ * Returns the device serial number.
+ *
+ * @return serial number
+ */
+ String serialNumber();
+
}
diff --git a/providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
index f7e3c95..16a4305 100644
--- a/providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/of/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -1,10 +1,5 @@
package org.onlab.onos.provider.of.device.impl;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -13,6 +8,7 @@
import org.onlab.onos.net.Device;
import org.onlab.onos.net.DeviceId;
import org.onlab.onos.net.MastershipRole;
+import org.onlab.onos.net.device.DefaultDeviceDescription;
import org.onlab.onos.net.device.DeviceDescription;
import org.onlab.onos.net.device.DeviceProvider;
import org.onlab.onos.net.device.DeviceProviderRegistry;
@@ -25,6 +21,11 @@
import org.onlab.onos.of.controller.RoleState;
import org.slf4j.Logger;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
/**
* Provider which uses an OpenFlow controller to detect network
* infrastructure devices.
@@ -90,17 +91,14 @@
}
private class InternalDeviceProvider implements OpenFlowSwitchListener {
-
@Override
- public void switchAdded(final Dpid dpid) {
+ public void switchAdded(Dpid dpid) {
URI uri = buildURI(dpid);
- providerService.deviceConnected(new DeviceId(uri), new DeviceDescription() {
-
- @Override
- public URI deviceURI() {
- return buildURI(dpid);
- }
- });
+ // TODO: fetch and provide switch desc information
+ DeviceDescription description =
+ new DefaultDeviceDescription(buildURI(dpid), Device.Type.SWITCH,
+ null, null, null, null);
+ providerService.deviceConnected(new DeviceId(uri), description);
}
@Override