blob: bc0b5c1869d02f44104610f1ccd9c4b7df29da94 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
tom41a2c5f2014-09-19 09:20:35 -070016package org.onlab.onos.net.device;
17
18import org.onlab.onos.net.Device;
19import org.onlab.onos.net.DeviceId;
tom41a2c5f2014-09-19 09:20:35 -070020import org.onlab.onos.net.Port;
21import org.onlab.onos.net.PortNumber;
22import org.onlab.onos.net.provider.ProviderId;
tomf80c9722014-09-24 14:49:18 -070023import org.onlab.onos.store.Store;
tom41a2c5f2014-09-19 09:20:35 -070024
25import java.util.List;
26
27/**
tome4729872014-09-23 00:37:37 -070028 * Manages inventory of infrastructure devices; not intended for direct use.
tom41a2c5f2014-09-19 09:20:35 -070029 */
tomf80c9722014-09-24 14:49:18 -070030public interface DeviceStore extends Store<DeviceEvent, DeviceStoreDelegate> {
tom41a2c5f2014-09-19 09:20:35 -070031
32 /**
33 * Returns the number of devices known to the system.
34 *
35 * @return number of devices
36 */
37 int getDeviceCount();
38
39 /**
40 * Returns an iterable collection of all devices known to the system.
41 *
42 * @return device collection
43 */
44 Iterable<Device> getDevices();
45
46 /**
47 * Returns the device with the specified identifier.
48 *
49 * @param deviceId device identifier
50 * @return device
51 */
52 Device getDevice(DeviceId deviceId);
53
54 /**
55 * Creates a new infrastructure device, or updates an existing one using
56 * the supplied device description.
57 *
58 * @param providerId provider identifier
59 * @param deviceId device identifier
60 * @param deviceDescription device description
61 * @return ready to send event describing what occurred; null if no change
62 */
63 DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId,
64 DeviceDescription deviceDescription);
65
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -070066 // TODO: We may need to enforce that ancillary cannot interfere this state
tom41a2c5f2014-09-19 09:20:35 -070067 /**
68 * Removes the specified infrastructure device.
69 *
70 * @param deviceId device identifier
71 * @return ready to send event describing what occurred; null if no change
72 */
73 DeviceEvent markOffline(DeviceId deviceId);
74
75 /**
76 * Updates the ports of the specified infrastructure device using the given
77 * list of port descriptions. The list is assumed to be comprehensive.
78 *
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -070079 * @param providerId provider identifier
tom41a2c5f2014-09-19 09:20:35 -070080 * @param deviceId device identifier
81 * @param portDescriptions list of port descriptions
82 * @return ready to send events describing what occurred; empty list if no change
83 */
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -070084 List<DeviceEvent> updatePorts(ProviderId providerId, DeviceId deviceId,
tom41a2c5f2014-09-19 09:20:35 -070085 List<PortDescription> portDescriptions);
86
87 /**
88 * Updates the port status of the specified infrastructure device using the
89 * given port description.
90 *
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -070091 * @param providerId provider identifier
tom41a2c5f2014-09-19 09:20:35 -070092 * @param deviceId device identifier
93 * @param portDescription port description
94 * @return ready to send event describing what occurred; null if no change
95 */
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -070096 DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId,
tom41a2c5f2014-09-19 09:20:35 -070097 PortDescription portDescription);
98
99 /**
100 * Returns the list of ports that belong to the specified device.
101 *
102 * @param deviceId device identifier
103 * @return list of device ports
104 */
105 List<Port> getPorts(DeviceId deviceId);
106
107 /**
108 * Returns the specified device port.
109 *
110 * @param deviceId device identifier
111 * @param portNumber port number
112 * @return device port
113 */
114 Port getPort(DeviceId deviceId, PortNumber portNumber);
115
116 /**
117 * Indicates whether the specified device is available/online.
118 *
119 * @param deviceId device identifier
120 * @return true if device is available
121 */
122 boolean isAvailable(DeviceId deviceId);
123
124 /**
tom41a2c5f2014-09-19 09:20:35 -0700125 * Administratively removes the specified device from the store.
126 *
127 * @param deviceId device to be removed
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800128 * @return null if no such device, or was forwarded to remove master
tom41a2c5f2014-09-19 09:20:35 -0700129 */
130 DeviceEvent removeDevice(DeviceId deviceId);
131}