blob: fa37f1b06de03d1a4f18aa27ae67aa14a54d11eb [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 /**
Thomas Vachuska5c2f8132015-04-08 23:09:08 -070028 * Returns the overall set of drivers being provided.
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080029 *
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080030 * @return provided drivers
31 */
Thomas Vachuska5c2f8132015-04-08 23:09:08 -070032 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 Vachuskaa8f4e7d2015-01-08 17:31:55 -080041
42 /**
43 * Returns the specified driver.
44 *
45 * @param driverName driver name
46 * @return driver
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070047 * @throws org.onlab.util.ItemNotFoundException if driver with the given
48 * name is not found
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080049 */
50 Driver getDriver(String driverName);
51
52 /**
53 * Returns the driver that matches the specified primordial device
54 * discovery information.
55 *
56 * @param mfr device manufacturer
57 * @param hw device hardware name/version
58 * @param sw device software version
59 * @return driver or null of no matching one is found
60 */
61 Driver getDriver(String mfr, String hw, String sw);
62
63 /**
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070064 * Returns the driver for the specified device. If the device carries
65 * {@code driver} annotation, its value is used to look-up the driver.
66 * Otherwise, the device manufacturer, hardware and software version
67 * attributes are used to look-up the driver. First using their literal
68 * values and if no driver is found, using ERE matching against the
69 * driver manufacturer, hardware and software version fields.
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080070 *
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070071 * @param deviceId device identifier
72 * @return driver or null of no matching one is found
73 * @throws org.onlab.util.ItemNotFoundException if device or driver for it
74 * are not found
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080075 */
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070076 Driver getDriver(DeviceId deviceId);
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080077
78 /**
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070079 * Creates a new driver handler for interacting with the specified device.
80 * The driver is looked-up using the same semantics as
81 * {@link #getDriver(DeviceId)} method.
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080082 *
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080083 * @param deviceId device identifier
84 * @param credentials optional login credentials in string form
85 * @return driver handler
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070086 * @throws org.onlab.util.ItemNotFoundException if device or driver for it
87 * are not found
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080088 */
Thomas Vachuskaca88bb72015-04-08 19:38:02 -070089 DriverHandler createHandler(DeviceId deviceId, String... credentials);
90
91 // TODO: Devise a mechanism for retaining DriverData for devices
Thomas Vachuskaa8f4e7d2015-01-08 17:31:55 -080092
93}