Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.net.pi.runtime; |
| 18 | |
| 19 | import com.google.common.annotations.Beta; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | import org.onosproject.net.pi.model.PiPipeconf; |
| 22 | import org.onosproject.net.pi.model.PiPipeconfId; |
| 23 | |
| 24 | import java.util.Optional; |
Andrea Campanella | bc112a9 | 2017-06-26 19:06:43 +0200 | [diff] [blame] | 25 | import java.util.concurrent.CompletableFuture; |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * A service to manage the configurations of protocol-independent pipelines. |
| 29 | */ |
| 30 | @Beta |
| 31 | public 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 | /** |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame^] | 44 | * Unregisters the Pipeconf identified by the given PiPipeconfId. Unregistering a Pipeconf removes it from the ONOS |
| 45 | * controller, thus making it un-capable of controlling (e.g installing flow rules) the devices that have the |
| 46 | * pipeconf's P4 program deployed. For now this method DOES NOT remove the P4 program from the devices. |
Andrea Campanella | a9b3c9b | 2017-07-21 14:03:15 +0200 | [diff] [blame] | 47 | * |
| 48 | * @param pipeconfId a pipeconfId |
| 49 | * @throws IllegalStateException if the same pipeconf identifier is already registered. |
| 50 | */ |
| 51 | void remove(PiPipeconfId pipeconfId) throws IllegalStateException; |
| 52 | |
| 53 | /** |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 54 | * Returns all pipeconfs registered. |
| 55 | * |
| 56 | * @return a collection of pipeconfs |
| 57 | */ |
| 58 | Iterable<PiPipeconf> getPipeconfs(); |
| 59 | |
| 60 | /** |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame^] | 61 | * Returns the pipeconf instance associated with the given identifier, if present. If not present, it means that no |
| 62 | * pipeconf with such identifier has been registered so far. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 63 | * |
| 64 | * @param id a pipeconf identifier |
| 65 | * @return an optional pipeconf |
| 66 | */ |
| 67 | Optional<PiPipeconf> getPipeconf(PiPipeconfId id); |
| 68 | |
| 69 | /** |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame^] | 70 | * Binds the given pipeconf to the given infrastructure device. As a result of this method call, if the given |
| 71 | * pipeconf exposes any pipeline-specific behaviours, those will be merged to the device's driver. Returns a |
| 72 | * completable future to provide async methods with a boolean if the merge of the drivers succeeded. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 73 | * |
Andrea Campanella | a9b3c9b | 2017-07-21 14:03:15 +0200 | [diff] [blame] | 74 | * @param deviceId a device identifier |
Andrea Campanella | bc112a9 | 2017-06-26 19:06:43 +0200 | [diff] [blame] | 75 | * @param pipeconfId a pipeconf identifier |
| 76 | * @return a CompletableFuture with a boolean, true if operation succeeded |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 77 | */ |
| 78 | // TODO: This service doesn't make any effort in deploying the configuration to the device. |
| 79 | // Someone else should do that. |
Andrea Campanella | bc112a9 | 2017-06-26 19:06:43 +0200 | [diff] [blame] | 80 | CompletableFuture<Boolean> bindToDevice(PiPipeconfId pipeconfId, DeviceId deviceId); |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 81 | |
| 82 | /** |
Carmelo Cascone | 87892e2 | 2017-11-13 16:01:29 -0800 | [diff] [blame^] | 83 | * Returns the pipeconf identifier currently associated with the given device identifier, if present. If not |
| 84 | * present, it means no pipeconf has been associated with that device so far. |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 85 | * |
| 86 | * @param deviceId device identifier |
| 87 | * @return an optional pipeconf identifier |
| 88 | */ |
| 89 | Optional<PiPipeconfId> ofDevice(DeviceId deviceId); |
Andrea Campanella | f9c409a | 2017-07-13 14:14:41 +0200 | [diff] [blame] | 90 | |
Carmelo Cascone | 1022a4e | 2017-05-25 00:16:18 -0400 | [diff] [blame] | 91 | } |