blob: 174759bb946ad984ac0f3226404dea05bec372e4 [file] [log] [blame]
Saurav Dasfb93c252014-08-18 20:40:13 -07001package net.onrc.onos.core.configmanager;
2
3import java.util.List;
4
5import net.floodlightcontroller.core.module.IFloodlightService;
6import net.onrc.onos.core.configmanager.NetworkConfig.LinkConfig;
7import net.onrc.onos.core.configmanager.NetworkConfig.SwitchConfig;
Saurav Dasfb93c252014-08-18 20:40:13 -07008import net.onrc.onos.core.util.Dpid;
Jonathan Hart8c802b42014-09-08 15:40:48 -07009import net.onrc.onos.core.util.LinkTuple;
Saurav Dasfb93c252014-08-18 20:40:13 -070010
11/**
12 * Exposes methods to retrieve network configuration.
13 * <p>
14 * TODO: currently only startup-configuration is exposed and such configuration
15 * cannot be changed at runtime. Need to add runtime support for changes to
16 * configuration (via REST/CLI) in future releases.
17 * <p>
18 * TODO: return immutable objects or defensive copies of network config so that
19 * users of this API do not inadvertently or maliciously change network config.
20 */
21public interface INetworkConfigService extends IFloodlightService {
22
23 /**
24 * Suggests the action to be taken by the caller given the configuration
25 * associated with the queried network-object (eg. switch, link etc.).
26 */
27 public enum NetworkConfigState {
28 /**
29 * Associated network object has been configured to not be allowed in
30 * the network.
31 */
32 DENY,
33
34 /**
35 * Associated network object has been configured to be allowed in the
36 * network.
37 */
38 ACCEPT,
39
40 /**
41 * Associated network object has been configured to be allowed in the
42 * network. In addition, there are configured parameters that should be
43 * added to the object.
44 */
45 ACCEPT_ADD,
46 }
47
48 /**
49 * Returns the configuration outcome (accept, deny etc.), and any configured
50 * parameters to the caller, in response to a query for the configuration
51 * associated with a switch.
52 */
53 public class SwitchConfigStatus {
54 private NetworkConfigState configState;
55 private SwitchConfig switchConfig;
56 private String msg;
57
58 SwitchConfigStatus(NetworkConfigState configState,
59 SwitchConfig switchConfig, String msg) {
60 this.configState = configState;
61 this.switchConfig = switchConfig;
62 this.msg = msg;
63 }
64
65 SwitchConfigStatus(NetworkConfigState configState,
66 SwitchConfig switchConfig) {
67 this.configState = configState;
68 this.switchConfig = switchConfig;
69 this.msg = "";
70 }
71
72 /**
73 * Returns the configuration state for the switch.
74 *
75 * @return non-null NetworkConfigState
76 */
77 public NetworkConfigState getConfigState() {
78 return configState;
79 }
80
81 /**
82 * Returns the switch configuration, which may be null if no
83 * configuration exists, or if the configuration state disallows the
84 * switch.
85 *
86 * @return SwitchConfig, the switch configuration, or null
87 */
88 public SwitchConfig getSwitchConfig() {
89 return switchConfig;
90 }
91
92 /**
93 * User readable string typically used to specify the reason why a
94 * switch is being disallowed.
95 *
96 * @return A non-null but possibly empty String
97 */
98 public String getMsg() {
99 return msg;
100 }
101
102 }
103
104 /**
105 * Returns the configuration outcome (accept, deny etc.), and any configured
106 * parameters to the caller, in response to a query for the configuration
107 * associated with a link.
108 */
109 public class LinkConfigStatus {
110 private NetworkConfigState configState;
111 private LinkConfig linkConfig;
112 private String msg;
113
114 LinkConfigStatus(NetworkConfigState configState,
115 LinkConfig linkConfig, String msg) {
116 this.configState = configState;
117 this.linkConfig = linkConfig;
118 this.msg = msg;
119 }
120
121 LinkConfigStatus(NetworkConfigState configState,
122 LinkConfig linkConfig) {
123 this.configState = configState;
124 this.linkConfig = linkConfig;
125 this.msg = "";
126 }
127
128 /**
129 * Returns the configuration state for the link.
130 *
131 * @return non-null NetworkConfigState
132 */
133 public NetworkConfigState getConfigState() {
134 return configState;
135 }
136
137 /**
138 * Returns the link configuration, which may be null if no configuration
139 * exists, or if the configuration state disallows the link.
140 *
141 * @return SwitchConfig, the switch configuration, or null
142 */
143 public LinkConfig getLinkConfig() {
144 return linkConfig;
145 }
146
147 /**
148 * User readable string typically used to specify the reason why a link
149 * is being disallowed.
150 *
151 * @return msg A non-null but possibly empty String
152 */
153 public String getMsg() {
154 return msg;
155 }
156
157 }
158
159 /**
160 * Checks the switch configuration (if any) associated with the 'dpid'.
161 * Determines if the switch should be allowed or denied according to
162 * configuration rules.
163 * <p>
164 * The method always returns a non-null SwitchConfigStatus. The enclosed
165 * ConfigState contains the result of the check. The enclosed SwitchConfig
166 * may or may not be null, depending on the outcome of the check.
167 *
168 * @param dpid of the switch to be queried
169 * @return SwitchConfigStatus with outcome of check and associated config.
170 */
171 public SwitchConfigStatus checkSwitchConfig(Dpid dpid);
172
173 /**
174 * Checks the link configuration (if any) associated with the 'link'.
175 * Determines if the link should be allowed or denied according to
176 * configuration rules. Note that the 'link' is a unidirectional link which
177 * checked against configuration that is typically defined for a
178 * bidirectional link. The caller may make a second call if it wishes to
179 * check the 'reverse' direction.
180 * <p>
181 * Also note that the configuration may not specify ports for a given
182 * bidirectional link. In such cases, the configuration applies to all links
183 * between the two switches. This method will check the given 'link' against
184 * such configuration.
185 * <p>
186 * The method always returns a non-null LinkConfigStatus. The enclosed
187 * ConfigState contains the result of the check. The enclosed LinkConfig may
188 * or may not be null, depending on the outcome of the check.
189 *
Jonathan Hart8c802b42014-09-08 15:40:48 -0700190 * @param linkTuple unidirectional link to be queried
Saurav Dasfb93c252014-08-18 20:40:13 -0700191 * @return LinkConfigStatus with outcome of check and associated config.
192 */
Jonathan Hart8c802b42014-09-08 15:40:48 -0700193 public LinkConfigStatus checkLinkConfig(LinkTuple linkTuple);
Saurav Dasfb93c252014-08-18 20:40:13 -0700194
195 /**
196 * Retrieves a list of switches that have been configured, and have been
197 * determined to be 'allowed' in the network, according to configuration
198 * rules.
199 * <p>
200 * Note that it is possible that there are other switches that are allowed
201 * in the network that have NOT been configured. Such switches will not be a
202 * part of the returned list.
203 * <p>
204 * Also note that it is possible that some switches will not be discovered
205 * and the only way the controller can know about these switches is via
206 * configuration. Such switches will be included in this list. It is up to
207 * the caller to determine which SwitchConfig applies to non-discovered
208 * switches.
209 *
210 * @return a non-null List of SwitchConfig which may be empty
211 */
212 public List<SwitchConfig> getConfiguredAllowedSwitches();
213
214 /**
215 * Retrieves a list of links that have been configured, and have been
216 * determined to be 'allowed' in the network, according to configuration
217 * rules.
218 * <p>
219 * Note that it is possible that there are other links that are allowed in
220 * the network that have NOT been configured. Such links will not be a part
221 * of the returned list.
222 * <p>
223 * Also note that it is possible that some links will not be discovered and
224 * the only way the controller can know about these links is via
225 * configuration. Such links will be included in this list. It is up to the
226 * caller to determine which LinkConfig applies to non-discovered links.
227 * <p>
228 * In addition, note that the LinkConfig applies to the configured
229 * bi-directional link, which may or may not have declared ports. The
230 * associated unidirectional LinkTuple can be retrieved from the
231 * getLinkTupleList() method in the LinkConfig object.
232 *
233 * @return a non-null List of LinkConfig which may be empty
234 */
235 public List<LinkConfig> getConfiguredAllowedLinks();
236
237 /**
238 * Retrieves the configured optical (wave) reachability matrix. The String
239 * is the 'name' associated with a configured switch object.
240 * <p>
241 * This method does not check if the switches are 'allowed' by config. TODO:
242 * This method should check if the 'name's in the matrix are valid names
243 * corresponding to configured switches.
244 *
245 * @return a non-null List which may be empty if no reachability matrix has
246 * been configured
247 */
248 public List<List<String>> getOpticalReachabiltyConfig();
249
250 /**
251 * Retrieves the Dpid associated with a 'name' for a configured switch
252 * object. This method does not check of the switches are 'allowed' by
253 * config.
254 *
255 * @return the Dpid corresponding to a given 'name', or null if no
256 * configured switch was found for the given 'name'.
257 */
258 public Dpid getDpidForName(String name);
259
260}