blob: ffb7c93f5bcca3093135904c4ca29e412010d67b [file] [log] [blame]
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -08001/*
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 */
16package org.onosproject.net.driver;
17
18import org.onosproject.net.DeviceId;
19
20import java.util.Set;
21
22/**
23 * Service for obtaining drivers and driver behaviour implementations.
24 */
25public 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 Vachuskaca88bb72015-04-08 19:38:02 -070041 * @throws org.onlab.util.ItemNotFoundException if driver with the given
42 * name is not found
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080043 */
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 Vachuskaca88bb72015-04-08 19:38:02 -070058 * 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 Vachuskaa8f4e7d2015-01-08 17:31:55 -080064 *
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070065 * @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 Vachuskaa8f4e7d2015-01-08 17:31:55 -080069 */
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070070 Driver getDriver(DeviceId deviceId);
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080071
72 /**
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070073 * 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 Vachuskaa8f4e7d2015-01-08 17:31:55 -080076 *
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080077 * @param deviceId device identifier
78 * @param credentials optional login credentials in string form
79 * @return driver handler
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070080 * @throws org.onlab.util.ItemNotFoundException if device or driver for it
81 * are not found
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080082 */
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070083 DriverHandler createHandler(DeviceId deviceId, String... credentials);
84
85 // TODO: Devise a mechanism for retaining DriverData for devices
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080086
87}