blob: c43be6dc447d76713ad5cb96583fe0835d55dcf3 [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
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;
Andrea Campanellabc112a92017-06-26 19:06:43 +020025import java.util.concurrent.CompletableFuture;
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040026
27/**
28 * A service to manage the configurations of protocol-independent pipelines.
29 */
30@Beta
31public interface PiPipeconfService {
32
33 // TODO: we might want to extend ListenerService to support the broadcasting of PipeconfEvent.
34
35 /**
36 * Registers the given pipeconf.
37 *
38 * @param pipeconf a pipeconf
39 * @throws IllegalStateException if the same pipeconf identifier is already registered.
40 */
41 void register(PiPipeconf pipeconf) throws IllegalStateException;
42
43 /**
Andrea Campanellaa9b3c9b2017-07-21 14:03:15 +020044 * Unregisters the Pipeconf identified by the given PiPipeconfId.
45 * Unregistering a Pipeconf removes it from the ONOS controller, thus making it un-capable
46 * of controlling (e.g installing flow rules) the devices that have the pipeconf's p4 program deployed.
47 * For now this method DOES NOT remove the p4 program from the devices.
48 *
49 * @param pipeconfId a pipeconfId
50 * @throws IllegalStateException if the same pipeconf identifier is already registered.
51 */
52 void remove(PiPipeconfId pipeconfId) throws IllegalStateException;
53
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 /**
62 * Returns the pipeconf instance associated with the given identifier, if present.
63 * If not present, it means that no pipeconf with such identifier has been registered so far.
64 *
65 * @param id a pipeconf identifier
66 * @return an optional pipeconf
67 */
68 Optional<PiPipeconf> getPipeconf(PiPipeconfId id);
69
70 /**
71 * Binds the given pipeconf to the given infrastructure device. As a result of this method call,
72 * if the given pipeconf exposes any pipeline-specific behaviours, those will be merged to the
Andrea Campanellabc112a92017-06-26 19:06:43 +020073 * device's driver. Returns a completable future to provide async methods with a boolean if the merge
74 * of the drivers succeeded.
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040075 *
Andrea Campanellaa9b3c9b2017-07-21 14:03:15 +020076 * @param deviceId a device identifier
Andrea Campanellabc112a92017-06-26 19:06:43 +020077 * @param pipeconfId a pipeconf identifier
78 * @return a CompletableFuture with a boolean, true if operation succeeded
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040079 */
80 // TODO: This service doesn't make any effort in deploying the configuration to the device.
81 // Someone else should do that.
Andrea Campanellabc112a92017-06-26 19:06:43 +020082 CompletableFuture<Boolean> bindToDevice(PiPipeconfId pipeconfId, DeviceId deviceId);
Carmelo Cascone1022a4e2017-05-25 00:16:18 -040083
84 /**
85 * Returns the pipeconf identifier currently associated with the given device identifier, if
86 * present. If not present, it means no pipeconf has been associated with that device so far.
87 *
88 * @param deviceId device identifier
89 * @return an optional pipeconf identifier
90 */
91 Optional<PiPipeconfId> ofDevice(DeviceId deviceId);
92}