blob: 945fd5b55e96aca19cd22465824c84b5b76a4f55 [file] [log] [blame]
samuel8d6b0a92015-07-11 13:22:57 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
samuel8d6b0a92015-07-11 13:22:57 +08003 *
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 */
16package org.onosproject.net.behaviour;
17
18import org.onosproject.net.Description;
19import org.onosproject.net.DeviceId;
20
Hyunsun Moon1251e192016-06-07 16:57:05 -070021import java.util.List;
22import java.util.Optional;
23
samuel8d6b0a92015-07-11 13:22:57 +080024/**
Hyunsun Moon1251e192016-06-07 16:57:05 -070025 * The abstraction of a bridge. Bridge represents an Ethernet switch with no or
26 * multiple OpenFlow controllers. Only OVSDB device provides bridge config behavior
27 * now and the bridge description is based on OVSDB schema.
samuel8d6b0a92015-07-11 13:22:57 +080028 */
29public interface BridgeDescription extends Description {
30
Hyunsun Moon1251e192016-06-07 16:57:05 -070031 enum FailMode {
32 /**
33 * The bridge will not set up flows on its own when the controller
34 * connection fails or no controllers are defined.
35 */
36 SECURE,
37 /**
38 * The bridge will take over responsibility of setting up flows.
39 */
40 STANDALONE
41 }
42
samuel8d6b0a92015-07-11 13:22:57 +080043 /**
44 * Returns bridge name.
45 *
46 * @return bridge name
47 */
Hyunsun Moon1251e192016-06-07 16:57:05 -070048 String name();
samuel8d6b0a92015-07-11 13:22:57 +080049
50 /**
Hyunsun Moon1251e192016-06-07 16:57:05 -070051 * Returns OpenFlow controllers of the bridge.
52 * If it's empty, then no OpenFlow controllers are used for the bridge.
samuel8d6b0a92015-07-11 13:22:57 +080053 *
Hyunsun Moon1251e192016-06-07 16:57:05 -070054 * @return set of controllers
samuel8d6b0a92015-07-11 13:22:57 +080055 */
Hyunsun Moon1251e192016-06-07 16:57:05 -070056 List<ControllerInfo> controllers();
samuel8d6b0a92015-07-11 13:22:57 +080057
58 /**
Hyunsun Moon1251e192016-06-07 16:57:05 -070059 * Returns whether to use local controller as an OpenFlow controller of the
60 * bridge if no controllers are specified.
samuel8d6b0a92015-07-11 13:22:57 +080061 *
Hyunsun Moon1251e192016-06-07 16:57:05 -070062 * @return true to set local controller, false otherwise
samuel8d6b0a92015-07-11 13:22:57 +080063 */
Hyunsun Moon1251e192016-06-07 16:57:05 -070064 boolean enableLocalController();
65
66 /**
67 * Returns fail mode of the bridge.
68 * If it's not set, the default setting of the bridge is used.
69 *
70 * @return fail mode
71 */
72 Optional<FailMode> failMode();
73
74 /**
75 * Returns OpenFlow datapath ID of the bridge. Valid only if OpenFlow controller
76 * is configured for the bridge.
77 *
78 * @return datapath id
79 */
80 Optional<String> datapathId();
81
82 /**
jaegonkim80bee532017-05-15 15:16:38 +090083 * Returns OVSDB datapath Type of the bridge.
84 *
85 * @return datapath type
86 */
87 Optional<String> datapathType();
88
89 /**
Hyunsun Moon1251e192016-06-07 16:57:05 -070090 * Returns OpenFlow device ID. Valid only if OpenFlow controller is configured
91 * for the bridge.
92 *
93 * @return device id
94 */
95 Optional<DeviceId> deviceId();
96
97 /**
98 * Returns in band control is enabled or not. If set to true, disable in-band
99 * control on the bridge regardless of controller and manager settings.
100 * If it's not set, the default setting of the bridge is used.
101 *
102 * @return true if in-band is disabled, false if in-band is enabled
103 */
104 Optional<Boolean> disableInBand();
105
106 /**
107 * Builder of bridge description entities.
108 */
109 interface Builder {
110
111 /**
112 * Returns bridge description builder with a given name.
113 *
114 * @param name bridge name
115 * @return bridge description builder
116 */
117 Builder name(String name);
118
119 /**
120 * Returns bridge description builder with given controllers.
121 *
122 * @param controllers set of controllers
123 * @return bridge description builder
124 */
125 Builder controllers(List<ControllerInfo> controllers);
126
127 /**
128 * Returns bridge description builder with local controller enabled.
129 *
130 * @return bridge description builder
131 */
132 Builder enableLocalController();
133
134 /**
135 * Returns bridge description builder with a given fail mode.
136 *
137 * @param failMode fail mode
138 * @return bridge description builder
139 */
140 Builder failMode(FailMode failMode);
141
142 /**
143 * Returns bridge description builder with a given datapath ID.
144 *
145 * @param datapathId datapath id
146 * @return bridge description builder
147 */
148 Builder datapathId(String datapathId);
149
150 /**
jaegonkim80bee532017-05-15 15:16:38 +0900151 * Returns bridge description builder with a given datapath type.
152 *
153 * @param datapathType datapath type
154 * @return bridge description builder
155 */
156 Builder datapathType(String datapathType);
157
158 /**
Hyunsun Moon1251e192016-06-07 16:57:05 -0700159 * Returns bridge description builder with in-band control disabled.
160 *
161 * @return bridge description builder
162 */
163 Builder disableInBand();
164
165 /**
166 * Builds an immutable bridge description.
167 *
168 * @return bridge description
169 */
170 BridgeDescription build();
171 }
samuel8d6b0a92015-07-11 13:22:57 +0800172}