Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 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 | */ |
| 16 | package org.onosproject.net.driver; |
| 17 | |
| 18 | import org.onosproject.net.DeviceId; |
| 19 | |
| 20 | import java.util.Set; |
| 21 | |
| 22 | /** |
| 23 | * Service for obtaining drivers and driver behaviour implementations. |
| 24 | */ |
| 25 | public interface DriverService { |
| 26 | |
| 27 | /** |
| 28 | * Returns the overall set of drivers being provided, optionally |
| 29 | * filtered to only those that support all specified behaviours. |
| 30 | * |
| 31 | * @param withBehaviours optional behaviour classes to query by |
| 32 | * @return provided drivers |
| 33 | */ |
| 34 | Set<Driver> getDrivers(Class<? extends Behaviour>... withBehaviours); |
| 35 | |
| 36 | /** |
| 37 | * Returns the specified driver. |
| 38 | * |
| 39 | * @param driverName driver name |
| 40 | * @return driver |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 41 | * @throws org.onlab.util.ItemNotFoundException if driver with the given |
| 42 | * name is not found |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 43 | */ |
| 44 | Driver getDriver(String driverName); |
| 45 | |
| 46 | /** |
| 47 | * Returns the driver that matches the specified primordial device |
| 48 | * discovery information. |
| 49 | * |
| 50 | * @param mfr device manufacturer |
| 51 | * @param hw device hardware name/version |
| 52 | * @param sw device software version |
| 53 | * @return driver or null of no matching one is found |
| 54 | */ |
| 55 | Driver getDriver(String mfr, String hw, String sw); |
| 56 | |
| 57 | /** |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 58 | * Returns the driver for the specified device. If the device carries |
| 59 | * {@code driver} annotation, its value is used to look-up the driver. |
| 60 | * Otherwise, the device manufacturer, hardware and software version |
| 61 | * attributes are used to look-up the driver. First using their literal |
| 62 | * values and if no driver is found, using ERE matching against the |
| 63 | * driver manufacturer, hardware and software version fields. |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 64 | * |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 65 | * @param deviceId device identifier |
| 66 | * @return driver or null of no matching one is found |
| 67 | * @throws org.onlab.util.ItemNotFoundException if device or driver for it |
| 68 | * are not found |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 69 | */ |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 70 | Driver getDriver(DeviceId deviceId); |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 71 | |
| 72 | /** |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 73 | * Creates a new driver handler for interacting with the specified device. |
| 74 | * The driver is looked-up using the same semantics as |
| 75 | * {@link #getDriver(DeviceId)} method. |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 76 | * |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 77 | * @param deviceId device identifier |
| 78 | * @param credentials optional login credentials in string form |
| 79 | * @return driver handler |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 80 | * @throws org.onlab.util.ItemNotFoundException if device or driver for it |
| 81 | * are not found |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 82 | */ |
Thomas Vachuska | ca88bb7 | 2015-04-08 19:38:02 -0700 | [diff] [blame] | 83 | DriverHandler createHandler(DeviceId deviceId, String... credentials); |
| 84 | |
| 85 | // TODO: Devise a mechanism for retaining DriverData for devices |
Thomas Vachuska | a8f4e7d | 2015-01-08 17:31:55 -0800 | [diff] [blame] | 86 | |
| 87 | } |