Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.net.driver; |
| 17 | |
| 18 | import org.onosproject.net.DeviceId; |
| 19 | |
Seyeon Jeong | 80a6246 | 2020-03-10 17:41:14 -0700 | [diff] [blame] | 20 | import java.util.Map; |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 21 | import java.util.Set; |
| 22 | |
| 23 | /** |
| 24 | * Service for obtaining drivers and driver behaviour implementations. |
| 25 | */ |
Thomas Vachuska | 11b99fc | 2017-04-27 12:51:04 -0700 | [diff] [blame] | 26 | public interface DriverService extends DriverRegistry { |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 27 | |
| 28 | /** |
Thomas Vachuska | 5c2f813 | 2015-04-08 23:09:08 -0700 | [diff] [blame] | 29 | * Returns the overall set of drivers being provided. |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 30 | * |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 31 | * @return provided drivers |
| 32 | */ |
Thomas Vachuska | 5c2f813 | 2015-04-08 23:09:08 -0700 | [diff] [blame] | 33 | Set<Driver> getDrivers(); |
| 34 | |
| 35 | /** |
| 36 | * Returns the set of drivers which support the specified behaviour. |
| 37 | * |
| 38 | * @param withBehaviour behaviour class to query by |
| 39 | * @return provided drivers |
| 40 | */ |
| 41 | Set<Driver> getDrivers(Class<? extends Behaviour> withBehaviour); |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 42 | |
| 43 | /** |
Thomas Vachuska | 164ecf6 | 2018-05-08 17:29:55 -0700 | [diff] [blame] | 44 | * Returns the driver for the specified device. If the network configuration |
| 45 | * for the specified device carries the {@code driver} property or if the |
| 46 | * device carries the {@code driver} annotation, they will be used to look-up |
| 47 | * the driver, in respective order. |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 48 | * Otherwise, the device manufacturer, hardware and software version |
| 49 | * attributes are used to look-up the driver. First using their literal |
| 50 | * values and if no driver is found, using ERE matching against the |
| 51 | * driver manufacturer, hardware and software version fields. |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 52 | * |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 53 | * @param deviceId device identifier |
| 54 | * @return driver or null of no matching one is found |
| 55 | * @throws org.onlab.util.ItemNotFoundException if device or driver for it |
| 56 | * are not found |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 57 | */ |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 58 | Driver getDriver(DeviceId deviceId); |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 59 | |
| 60 | /** |
Seyeon Jeong | 80a6246 | 2020-03-10 17:41:14 -0700 | [diff] [blame] | 61 | * Returns a map between all devices and their driver names. |
| 62 | * |
| 63 | * @return map of (device id, driver name) |
| 64 | */ |
| 65 | Map<DeviceId, String> getDeviceDrivers(); |
| 66 | |
| 67 | /** |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 68 | * Creates a new driver handler for interacting with the specified device. |
| 69 | * The driver is looked-up using the same semantics as |
| 70 | * {@link #getDriver(DeviceId)} method. |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 71 | * |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 72 | * @param deviceId device identifier |
| 73 | * @param credentials optional login credentials in string form |
| 74 | * @return driver handler |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 75 | * @throws org.onlab.util.ItemNotFoundException if device or driver for it |
| 76 | * are not found |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 77 | */ |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 78 | DriverHandler createHandler(DeviceId deviceId, String... credentials); |
| 79 | |
| 80 | // TODO: Devise a mechanism for retaining DriverData for devices |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 81 | |
| 82 | } |