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