Laszlo Papp | f50057c | 2018-06-15 14:37:35 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018-present Open Networking Foundation |
| 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.behaviour; |
| 18 | |
| 19 | import com.google.common.annotations.Beta; |
| 20 | |
| 21 | import org.onosproject.net.driver.HandlerBehaviour; |
| 22 | |
Laszlo Papp | f50057c | 2018-06-15 14:37:35 +0100 | [diff] [blame] | 23 | import java.util.concurrent.CompletableFuture; |
| 24 | |
| 25 | /** |
| 26 | * Behaviour that upgrades the software on a device. |
| 27 | * |
| 28 | */ |
| 29 | @Beta |
| 30 | public interface SoftwareUpgrade extends HandlerBehaviour { |
| 31 | |
| 32 | /** |
Serhii Boiko | 992bf52 | 2019-03-28 18:38:04 +0200 | [diff] [blame] | 33 | * Upload a package to device. If no destination path is specified |
| 34 | * the package will be stored in the /tmp folder with a randomized name. |
| 35 | * |
| 36 | * @param sourcePath path to local package. |
| 37 | * @param destinationPath (optional) path where the package will be saved. |
| 38 | * @return path where the package was saved on device or null in case of an error. |
Laszlo Papp | f50057c | 2018-06-15 14:37:35 +0100 | [diff] [blame] | 39 | */ |
Serhii Boiko | 992bf52 | 2019-03-28 18:38:04 +0200 | [diff] [blame] | 40 | public CompletableFuture<String> uploadPackage(String sourcePath, String destinationPath); |
Laszlo Papp | f50057c | 2018-06-15 14:37:35 +0100 | [diff] [blame] | 41 | |
Serhii Boiko | 992bf52 | 2019-03-28 18:38:04 +0200 | [diff] [blame] | 42 | /** |
| 43 | * Causes the device to switch from the current software agent |
| 44 | * to the provided agent. |
| 45 | * |
| 46 | * @param packagePath path to package on device. |
| 47 | * @return success - if no exceptions occured; device uptime; device version. |
| 48 | */ |
| 49 | public CompletableFuture<Response> swapAgent(String packagePath); |
| 50 | |
| 51 | /** |
| 52 | * Response of SwapAgent. |
| 53 | */ |
| 54 | public final class Response { |
| 55 | private final Long uptime; |
| 56 | private final String version; |
| 57 | private final boolean success; |
| 58 | |
| 59 | public Response(Long a, String b) { |
| 60 | uptime = a; |
| 61 | version = b; |
| 62 | success = true; |
| 63 | } |
| 64 | |
| 65 | public Response() { |
| 66 | uptime = 0L; |
| 67 | version = ""; |
| 68 | success = false; |
| 69 | } |
| 70 | |
| 71 | public Long getUptime() { |
| 72 | return uptime; |
| 73 | } |
| 74 | |
| 75 | public String getVersion() { |
| 76 | return version; |
| 77 | } |
| 78 | |
| 79 | public boolean isSuccess() { |
| 80 | return success; |
| 81 | } |
Laszlo Papp | f50057c | 2018-06-15 14:37:35 +0100 | [diff] [blame] | 82 | } |
| 83 | |
Laszlo Papp | f50057c | 2018-06-15 14:37:35 +0100 | [diff] [blame] | 84 | } |