blob: 705ecb74d49656ffa3e0efe2dcea017684916297 [file] [log] [blame]
Charles Chan9797ebb2020-02-14 13:23:57 -08001/*
2 * Copyright 2020-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.segmentrouting.phasedrecovery.api;
18
19import org.onosproject.net.DeviceId;
20import org.onosproject.net.PortNumber;
21
22import java.util.Map;
23import java.util.Set;
24
25/**
26 * Service that provides functionality related to phased recovery.
27 */
28public interface PhasedRecoveryService {
29
30 // TODO Make timeout values configurable via Component Config Service
31 /**
32 * Timeout for PAIR phase in seconds.
33 */
34 int PAIR_TIMEOUT = 30;
35
36 /**
37 * Timeout for INFRA phase in seconds.
38 */
39 int INFRA_TIMEOUT = 30;
40
41 /**
42 * Timeout for EDGE phase in seconds.
43 */
44 int EDGE_TIMEOUT = 30;
45
46 //
47 // Phased recovery APIs.
48 //
49
50
51 /**
52 * Returns true if phased recovery is enabled.
53 *
54 * @return true if phased recovery is enabled.
55 */
56 boolean isEnabled();
57
58 /**
59 * Initializes a device. Only the master of the device is allowed to do this.
60 *
61 * @param deviceId device ID
62 * @return true if the device is initialized successfully and the caller should proceed,
63 * false if the device initialization has failed and the caller should abort.
64 */
65 boolean init(DeviceId deviceId);
66
67 /**
68 * Resets a device. Only the master of the device is allowed to do this.
69 *
70 * @param deviceId device ID
71 * @return true if the device is reset successfully.
72 * false if the device has not been previously initialized.
73 */
74 boolean reset(DeviceId deviceId);
75
76 /**
77 * Gets recovery phase of every devices.
78 *
79 * @return a map between device ID and recovery phase
80 */
81 Map<DeviceId, Phase> getPhases();
82
83 /**
84 * Gets recovery phase of given device.
85 *
86 * @param deviceId device ID
87 * @return current phase or null if the device wasn't seen before
88 */
89 Phase getPhase(DeviceId deviceId);
90
91 /**
92 * Sets given device with given recovery phase. Only the master of the device is allowed to do this.
93 *
94 * @param deviceId device ID
95 * @param newPhase recovery phase
96 * @return new phase if transition succeeded, otherwise return current phase.
97 */
98 Phase setPhase(DeviceId deviceId, Phase newPhase);
99
100 //
101 // Port manipulation APIs.
102 //
103
104 /**
105 * Enables every ports on the given device.
106 *
107 * @param deviceId device id
108 * @param enabled true to enable, false to disable
109 * @return ports that have been enabled
110 */
111 Set<PortNumber> changeAllPorts(DeviceId deviceId, boolean enabled);
112
113 /**
114 * Enables pair port on the given device.
115 *
116 * @param deviceId device id
117 * @param enabled true to enable, false to disable
118 * @return ports that have been enabled
119 */
120 Set<PortNumber> changePairPort(DeviceId deviceId, boolean enabled);
121
122 /**
123 * Enables infrastructure ports on the given device.
124 *
125 * @param deviceId device id
126 * @param enabled true to enable, false to disable
127 * @return ports that have been enabled
128 */
129 Set<PortNumber> changeInfraPorts(DeviceId deviceId, boolean enabled);
130
131 /**
132 * Enables edge ports on the given device.
133 *
134 * @param deviceId device id
135 * @param enabled true to enable, false to disable
136 * @return ports that have been enabled
137 */
138 Set<PortNumber> changeEdgePorts(DeviceId deviceId, boolean enabled);
139}