blob: c037eb677af452f27b61bb77bf7fe4aebc19de59 [file] [log] [blame]
Carmelo Cascone1022a4e2017-05-25 00:16:18 -04001/*
2 * Copyright 2017-present 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
17package org.onosproject.net.pi.runtime;
18
19import com.google.common.annotations.Beta;
20import org.onosproject.net.DeviceId;
21import org.onosproject.net.pi.model.PiPipeconf;
22import org.onosproject.net.pi.model.PiPipeconfId;
23
24import java.util.Optional;
25
26/**
27 * A service to manage the configurations of protocol-independent pipelines.
28 */
29@Beta
30public interface PiPipeconfService {
31
32 // TODO: we might want to extend ListenerService to support the broadcasting of PipeconfEvent.
33
34 /**
35 * Registers the given pipeconf.
36 *
37 * @param pipeconf a pipeconf
38 * @throws IllegalStateException if the same pipeconf identifier is already registered.
39 */
40 void register(PiPipeconf pipeconf) throws IllegalStateException;
41
42 /**
43 * Returns all pipeconfs registered.
44 *
45 * @return a collection of pipeconfs
46 */
47 Iterable<PiPipeconf> getPipeconfs();
48
49 /**
50 * Returns the pipeconf instance associated with the given identifier, if present.
51 * If not present, it means that no pipeconf with such identifier has been registered so far.
52 *
53 * @param id a pipeconf identifier
54 * @return an optional pipeconf
55 */
56 Optional<PiPipeconf> getPipeconf(PiPipeconfId id);
57
58 /**
59 * Binds the given pipeconf to the given infrastructure device. As a result of this method call,
60 * if the given pipeconf exposes any pipeline-specific behaviours, those will be merged to the
61 * device's driver.
62 *
63 * @param deviceId a device identifier
64 * @param pipeconf a pipeconf identifier
65 */
66 // TODO: This service doesn't make any effort in deploying the configuration to the device.
67 // Someone else should do that.
68 void bindToDevice(PiPipeconfId pipeconf, DeviceId deviceId);
69
70 /**
71 * Returns the pipeconf identifier currently associated with the given device identifier, if
72 * present. If not present, it means no pipeconf has been associated with that device so far.
73 *
74 * @param deviceId device identifier
75 * @return an optional pipeconf identifier
76 */
77 Optional<PiPipeconfId> ofDevice(DeviceId deviceId);
78}