tom

Implementing port methods in trivial core.

1 package org.onlab.onos.net.trivial.impl; 1 package org.onlab.onos.net.trivial.impl;
2 2
3 +import com.google.common.collect.ImmutableList;
3 import org.onlab.onos.net.DefaultDevice; 4 import org.onlab.onos.net.DefaultDevice;
4 import org.onlab.onos.net.DefaultPort; 5 import org.onlab.onos.net.DefaultPort;
5 import org.onlab.onos.net.Device; 6 import org.onlab.onos.net.Device;
...@@ -227,7 +228,13 @@ class SimpleDeviceStore { ...@@ -227,7 +228,13 @@ class SimpleDeviceStore {
227 */ 228 */
228 DeviceEvent updatePortStatus(DeviceId deviceId, 229 DeviceEvent updatePortStatus(DeviceId deviceId,
229 PortDescription portDescription) { 230 PortDescription portDescription) {
230 - return null; 231 + synchronized (this) {
232 + Device device = devices.get(deviceId);
233 + checkArgument(device != null, DEVICE_NOT_FOUND, deviceId);
234 + Map<PortNumber, Port> ports = getPortMap(deviceId);
235 + Port port = ports.get(portDescription.portNumber());
236 + return updatePort(device, port, portDescription, ports);
237 + }
231 } 238 }
232 239
233 /** 240 /**
...@@ -237,7 +244,8 @@ class SimpleDeviceStore { ...@@ -237,7 +244,8 @@ class SimpleDeviceStore {
237 * @return list of device ports 244 * @return list of device ports
238 */ 245 */
239 List<Port> getPorts(DeviceId deviceId) { 246 List<Port> getPorts(DeviceId deviceId) {
240 - return null; 247 + Map<PortNumber, Port> ports = devicePorts.get(deviceId);
248 + return ports == null ? new ArrayList<Port>() : ImmutableList.copyOf(ports.values());
241 } 249 }
242 250
243 /** 251 /**
...@@ -248,7 +256,8 @@ class SimpleDeviceStore { ...@@ -248,7 +256,8 @@ class SimpleDeviceStore {
248 * @return device port 256 * @return device port
249 */ 257 */
250 Port getPort(DeviceId deviceId, PortNumber portNumber) { 258 Port getPort(DeviceId deviceId, PortNumber portNumber) {
251 - return null; 259 + Map<PortNumber, Port> ports = devicePorts.get(deviceId);
260 + return ports == null ? null : ports.get(portNumber);
252 } 261 }
253 262
254 /** 263 /**
......