blob: ed86881a6e51ffb203712731e6fe9a19f08a304a [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 /**
Yuta HIGUCHIf1f2ac02014-11-26 14:02:22 -080047 * Returns an iterable collection of all devices currently available to the system.
48 *
49 * @return device collection
50 */
51 Iterable<Device> getAvailableDevices();
52
53
54
55 /**
tom41a2c5f2014-09-19 09:20:35 -070056 * Returns the device with the specified identifier.
57 *
58 * @param deviceId device identifier
59 * @return device
60 */
61 Device getDevice(DeviceId deviceId);
62
63 /**
64 * Creates a new infrastructure device, or updates an existing one using
65 * the supplied device description.
66 *
67 * @param providerId provider identifier
68 * @param deviceId device identifier
69 * @param deviceDescription device description
70 * @return ready to send event describing what occurred; null if no change
71 */
72 DeviceEvent createOrUpdateDevice(ProviderId providerId, DeviceId deviceId,
73 DeviceDescription deviceDescription);
74
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -070075 // TODO: We may need to enforce that ancillary cannot interfere this state
tom41a2c5f2014-09-19 09:20:35 -070076 /**
77 * Removes the specified infrastructure device.
78 *
79 * @param deviceId device identifier
80 * @return ready to send event describing what occurred; null if no change
81 */
82 DeviceEvent markOffline(DeviceId deviceId);
83
84 /**
85 * Updates the ports of the specified infrastructure device using the given
86 * list of port descriptions. The list is assumed to be comprehensive.
87 *
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -070088 * @param providerId provider identifier
tom41a2c5f2014-09-19 09:20:35 -070089 * @param deviceId device identifier
90 * @param portDescriptions list of port descriptions
91 * @return ready to send events describing what occurred; empty list if no change
92 */
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -070093 List<DeviceEvent> updatePorts(ProviderId providerId, DeviceId deviceId,
tom41a2c5f2014-09-19 09:20:35 -070094 List<PortDescription> portDescriptions);
95
96 /**
97 * Updates the port status of the specified infrastructure device using the
98 * given port description.
99 *
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -0700100 * @param providerId provider identifier
tom41a2c5f2014-09-19 09:20:35 -0700101 * @param deviceId device identifier
102 * @param portDescription port description
103 * @return ready to send event describing what occurred; null if no change
104 */
Yuta HIGUCHI5f6739c2014-10-01 14:04:01 -0700105 DeviceEvent updatePortStatus(ProviderId providerId, DeviceId deviceId,
tom41a2c5f2014-09-19 09:20:35 -0700106 PortDescription portDescription);
107
108 /**
109 * Returns the list of ports that belong to the specified device.
110 *
111 * @param deviceId device identifier
112 * @return list of device ports
113 */
114 List<Port> getPorts(DeviceId deviceId);
115
116 /**
117 * Returns the specified device port.
118 *
119 * @param deviceId device identifier
120 * @param portNumber port number
121 * @return device port
122 */
123 Port getPort(DeviceId deviceId, PortNumber portNumber);
124
125 /**
126 * Indicates whether the specified device is available/online.
127 *
128 * @param deviceId device identifier
129 * @return true if device is available
130 */
131 boolean isAvailable(DeviceId deviceId);
132
133 /**
tom41a2c5f2014-09-19 09:20:35 -0700134 * Administratively removes the specified device from the store.
135 *
136 * @param deviceId device to be removed
Yuta HIGUCHI5c947272014-11-03 21:39:21 -0800137 * @return null if no such device, or was forwarded to remove master
tom41a2c5f2014-09-19 09:20:35 -0700138 */
139 DeviceEvent removeDevice(DeviceId deviceId);
140}