blob: a8c08327af4ef3eaf63475aa9ce02aa83b4dbcbe [file] [log] [blame]
samuel8d6b0a92015-07-11 13:22:57 +08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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 /**
83 * Returns OpenFlow device ID. Valid only if OpenFlow controller is configured
84 * for the bridge.
85 *
86 * @return device id
87 */
88 Optional<DeviceId> deviceId();
89
90 /**
91 * Returns in band control is enabled or not. If set to true, disable in-band
92 * control on the bridge regardless of controller and manager settings.
93 * If it's not set, the default setting of the bridge is used.
94 *
95 * @return true if in-band is disabled, false if in-band is enabled
96 */
97 Optional<Boolean> disableInBand();
98
99 /**
100 * Builder of bridge description entities.
101 */
102 interface Builder {
103
104 /**
105 * Returns bridge description builder with a given name.
106 *
107 * @param name bridge name
108 * @return bridge description builder
109 */
110 Builder name(String name);
111
112 /**
113 * Returns bridge description builder with given controllers.
114 *
115 * @param controllers set of controllers
116 * @return bridge description builder
117 */
118 Builder controllers(List<ControllerInfo> controllers);
119
120 /**
121 * Returns bridge description builder with local controller enabled.
122 *
123 * @return bridge description builder
124 */
125 Builder enableLocalController();
126
127 /**
128 * Returns bridge description builder with a given fail mode.
129 *
130 * @param failMode fail mode
131 * @return bridge description builder
132 */
133 Builder failMode(FailMode failMode);
134
135 /**
136 * Returns bridge description builder with a given datapath ID.
137 *
138 * @param datapathId datapath id
139 * @return bridge description builder
140 */
141 Builder datapathId(String datapathId);
142
143 /**
144 * Returns bridge description builder with in-band control disabled.
145 *
146 * @return bridge description builder
147 */
148 Builder disableInBand();
149
150 /**
151 * Builds an immutable bridge description.
152 *
153 * @return bridge description
154 */
155 BridgeDescription build();
156 }
samuel8d6b0a92015-07-11 13:22:57 +0800157}