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