tom

Enhanced DeviceDescription and added default implementation for it.

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.
*/
......
package org.onlab.onos.net;
import org.onlab.onos.net.provider.Provided;
/**
* Abstraction of a network infrastructure link.
*/
......
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.
......
......@@ -3,7 +3,7 @@ package org.onlab.onos.net;
/**
* Represents a network topology computation snapshot.
*/
public interface Topology {
public interface Topology extends Provided {
/**
* Returns the time, specified in milliseconds since start of epoch,
......
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();
}
}
package org.onlab.onos.net.device;
/**
* Default implementation of immutable port description.
*/
public class DefaultPortDescription implements PortDescription {
}
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 @@ public interface DeviceDescription extends Description {
*/
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();
}
......
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.apache.felix.scr.annotations.ReferenceCardinality;
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.OpenFlowSwitchListener;
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 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
}
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
......