blob: 24bb597cb43bfc3af3dc388cc45ae43ac1ac4c78 [file] [log] [blame]
Laszlo Pappf50057c2018-06-15 14:37:35 +01001/*
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
17package org.onosproject.net.behaviour;
18
19import com.google.common.annotations.Beta;
20
21import org.onosproject.net.driver.HandlerBehaviour;
22
Laszlo Pappf50057c2018-06-15 14:37:35 +010023import java.util.concurrent.CompletableFuture;
24
25/**
26 * Behaviour that upgrades the software on a device.
27 *
28 */
29@Beta
30public interface SoftwareUpgrade extends HandlerBehaviour {
31
32 /**
Serhii Boiko992bf522019-03-28 18:38:04 +020033 * 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 Pappf50057c2018-06-15 14:37:35 +010039 */
Serhii Boiko992bf522019-03-28 18:38:04 +020040 public CompletableFuture<String> uploadPackage(String sourcePath, String destinationPath);
Laszlo Pappf50057c2018-06-15 14:37:35 +010041
Serhii Boiko992bf522019-03-28 18:38:04 +020042 /**
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 Pappf50057c2018-06-15 14:37:35 +010082 }
83
Laszlo Pappf50057c2018-06-15 14:37:35 +010084}