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