Implementing port methods in trivial core.

This commit is contained in:
tom 2014-09-05 08:25:56 -07:00
parent 29df6f4ce2
commit 46a220d6a0

View File

@ -1,5 +1,6 @@
package org.onlab.onos.net.trivial.impl; package org.onlab.onos.net.trivial.impl;
import com.google.common.collect.ImmutableList;
import org.onlab.onos.net.DefaultDevice; import org.onlab.onos.net.DefaultDevice;
import org.onlab.onos.net.DefaultPort; import org.onlab.onos.net.DefaultPort;
import org.onlab.onos.net.Device; import org.onlab.onos.net.Device;
@ -227,7 +228,13 @@ class SimpleDeviceStore {
*/ */
DeviceEvent updatePortStatus(DeviceId deviceId, DeviceEvent updatePortStatus(DeviceId deviceId,
PortDescription portDescription) { PortDescription portDescription) {
return null; synchronized (this) {
Device device = devices.get(deviceId);
checkArgument(device != null, DEVICE_NOT_FOUND, deviceId);
Map<PortNumber, Port> ports = getPortMap(deviceId);
Port port = ports.get(portDescription.portNumber());
return updatePort(device, port, portDescription, ports);
}
} }
/** /**
@ -237,7 +244,8 @@ class SimpleDeviceStore {
* @return list of device ports * @return list of device ports
*/ */
List<Port> getPorts(DeviceId deviceId) { List<Port> getPorts(DeviceId deviceId) {
return null; Map<PortNumber, Port> ports = devicePorts.get(deviceId);
return ports == null ? new ArrayList<Port>() : ImmutableList.copyOf(ports.values());
} }
/** /**
@ -248,7 +256,8 @@ class SimpleDeviceStore {
* @return device port * @return device port
*/ */
Port getPort(DeviceId deviceId, PortNumber portNumber) { Port getPort(DeviceId deviceId, PortNumber portNumber) {
return null; Map<PortNumber, Port> ports = devicePorts.get(deviceId);
return ports == null ? null : ports.get(portNumber);
} }
/** /**