blob: d24348df50a50756c7dd7358431c0b77760cd305 [file] [log] [blame]
Carmelo Cascone1022a4e2017-05-25 00:16:18 -04001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Carmelo Cascone1022a4e2017-05-25 00:16:18 -04003 *
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
Carmelo Cascone39c28ca2017-11-15 13:03:57 -080017package org.onosproject.net.pi.service;
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040018
19import com.google.common.annotations.Beta;
Carmelo Cascone75a9a892019-04-22 12:12:23 -070020import org.onosproject.event.ListenerService;
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040021import org.onosproject.net.DeviceId;
22import org.onosproject.net.pi.model.PiPipeconf;
23import org.onosproject.net.pi.model.PiPipeconfId;
24
25import java.util.Optional;
26
27/**
28 * A service to manage the configurations of protocol-independent pipelines.
29 */
30@Beta
Carmelo Cascone75a9a892019-04-22 12:12:23 -070031public interface PiPipeconfService extends ListenerService<PiPipeconfEvent, PiPipeconfListener> {
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040032
33 // TODO: we might want to extend ListenerService to support the broadcasting of PipeconfEvent.
34
35 /**
Carmelo Cascone75a9a892019-04-22 12:12:23 -070036 * Registers the given pipeconf making it available to other subsystems.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040037 *
38 * @param pipeconf a pipeconf
Carmelo Cascone158b8c42018-07-04 19:42:37 +020039 * @throws IllegalStateException if the same pipeconf identifier is already
40 * registered.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040041 */
42 void register(PiPipeconf pipeconf) throws IllegalStateException;
43
44 /**
Carmelo Cascone75a9a892019-04-22 12:12:23 -070045 * Unregisters the given pipeconf. Once unregistered, other subsystems will
46 * not be able to access the pipeconf content.
Andrea Campanellaa9b3c9b2017-07-21 14:03:15 +020047 *
48 * @param pipeconfId a pipeconfId
Carmelo Cascone158b8c42018-07-04 19:42:37 +020049 * @throws IllegalStateException if the same pipeconf identifier is already
50 * registered.
Andrea Campanellaa9b3c9b2017-07-21 14:03:15 +020051 */
Carmelo Cascone75a9a892019-04-22 12:12:23 -070052 void unregister(PiPipeconfId pipeconfId) throws IllegalStateException;
Andrea Campanellaa9b3c9b2017-07-21 14:03:15 +020053
54 /**
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040055 * Returns all pipeconfs registered.
56 *
57 * @return a collection of pipeconfs
58 */
59 Iterable<PiPipeconf> getPipeconfs();
60
61 /**
Carmelo Cascone158b8c42018-07-04 19:42:37 +020062 * Returns the pipeconf instance associated with the given identifier, if
63 * present. If not present, it means that no pipeconf with such identifier
64 * has been registered so far.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040065 *
66 * @param id a pipeconf identifier
67 * @return an optional pipeconf
68 */
69 Optional<PiPipeconf> getPipeconf(PiPipeconfId id);
70
71 /**
Carmelo Cascone4c289b72019-01-22 15:30:45 -080072 * Returns the pipeconf instance associated with the given device, if
73 * present. If not present, it means no pipeconf has been associated with
74 * that device so far.
75 *
76 * @param deviceId a device identifier
77 * @return an optional pipeconf
78 */
79 Optional<PiPipeconf> getPipeconf(DeviceId deviceId);
80
81 /**
Carmelo Cascone158b8c42018-07-04 19:42:37 +020082 * Signals that the given pipeconf is associated to the given infrastructure
83 * device. As a result of this method, the pipeconf for the given device can
84 * be later retrieved using {@link #ofDevice(DeviceId)}
85 *
86 * @param pipeconfId a pipeconf identifier
87 * @param deviceId a device identifier
88 */
89 void bindToDevice(PiPipeconfId pipeconfId, DeviceId deviceId);
90
91 /**
92 * Returns the name of a driver that is equivalent to the base driver of the
93 * given device plus all the pipeline-specific behaviors exposed by the
94 * given pipeconf (previously registered using {@link
95 * #register(PiPipeconf)}). If such driver does not exist, this method
96 * creates one and registers is with all necessary ONOS subsystems, such
97 * that the returned name can be used to retrieve the driver instance using
98 * {@link org.onosproject.net.driver.DriverService#getDriver(String)}.
99 * <p>
100 * This method needs to be called on all nodes of the cluster that wants to
101 * use such merged driver.
102 * <p>
103 * Returns null if such merged driver cannot be created.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400104 *
Andrea Campanellaa9b3c9b2017-07-21 14:03:15 +0200105 * @param deviceId a device identifier
Andrea Campanellabc112a92017-06-26 19:06:43 +0200106 * @param pipeconfId a pipeconf identifier
Carmelo Cascone158b8c42018-07-04 19:42:37 +0200107 * @return driver name or null.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400108 */
Carmelo Cascone0761cd32018-08-29 19:22:50 -0700109 String getMergedDriver(DeviceId deviceId, PiPipeconfId pipeconfId);
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400110
111 /**
Carmelo Cascone158b8c42018-07-04 19:42:37 +0200112 * Returns the pipeconf identifier currently associated with the given
113 * device identifier, if present. If not present, it means no pipeconf has
114 * been associated with that device so far.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400115 *
116 * @param deviceId device identifier
117 * @return an optional pipeconf identifier
Carmelo Cascone4c289b72019-01-22 15:30:45 -0800118 * @deprecated in ONOS 2.1 use {@link #getPipeconf(DeviceId)} instead
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400119 */
Carmelo Cascone4c289b72019-01-22 15:30:45 -0800120 @Deprecated
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400121 Optional<PiPipeconfId> ofDevice(DeviceId deviceId);
Andrea Campanellaf9c409a2017-07-13 14:14:41 +0200122
Carmelo Cascone1022a4e2017-05-25 00:16:18 -0400123}