1 package org.onosproject.segmentrouting.config;
 
   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;
 
  11  * Exposes methods to retrieve network configuration.
 
  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.
 
  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.
 
  20  * @deprecated in Drake; see org.onosproject.net.config
 
  23 public interface NetworkConfigService {
 
  26      * Suggests the action to be taken by the caller given the configuration
 
  27      * associated with the queried network-object (eg. switch, link etc.).
 
  29     enum NetworkConfigState {
 
  31          * Associated network object has been configured to not be allowed in
 
  37          * Associated network object has been configured to be allowed in the
 
  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.
 
  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.
 
  55     class SwitchConfigStatus {
 
  56         private NetworkConfigState configState;
 
  57         private SwitchConfig switchConfig;
 
  60         SwitchConfigStatus(NetworkConfigState configState,
 
  61                 SwitchConfig switchConfig, String msg) {
 
  62             this.configState = configState;
 
  63             this.switchConfig = switchConfig;
 
  67         SwitchConfigStatus(NetworkConfigState configState,
 
  68                 SwitchConfig switchConfig) {
 
  69             this.configState = configState;
 
  70             this.switchConfig = switchConfig;
 
  75          * Returns the configuration state for the switch.
 
  77          * @return non-null NetworkConfigState
 
  79         public NetworkConfigState getConfigState() {
 
  84          * Returns the switch configuration, which may be null if no
 
  85          * configuration exists, or if the configuration state disallows the
 
  88          * @return SwitchConfig, the switch configuration, or null
 
  90         public SwitchConfig getSwitchConfig() {
 
  95          * User readable string typically used to specify the reason why a
 
  96          * switch is being disallowed.
 
  98          * @return A non-null but possibly empty String
 
 100         public String getMsg() {
 
 107      * Reserved for future use.
 
 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.
 
 113     class LinkConfigStatus {
 
 114         private NetworkConfigState configState;
 
 115         private LinkConfig linkConfig;
 
 118         LinkConfigStatus(NetworkConfigState configState,
 
 119                 LinkConfig linkConfig, String msg) {
 
 120             this.configState = configState;
 
 121             this.linkConfig = linkConfig;
 
 125         LinkConfigStatus(NetworkConfigState configState,
 
 126                 LinkConfig linkConfig) {
 
 127             this.configState = configState;
 
 128             this.linkConfig = linkConfig;
 
 133          * Returns the configuration state for the link.
 
 135          * @return non-null NetworkConfigState
 
 137         public NetworkConfigState getConfigState() {
 
 142          * Returns the link configuration, which may be null if no configuration
 
 143          * exists, or if the configuration state disallows the link.
 
 145          * @return SwitchConfig, the switch configuration, or null
 
 147         public LinkConfig getLinkConfig() {
 
 152          * User readable string typically used to specify the reason why a link
 
 153          * is being disallowed.
 
 155          * @return msg A non-null but possibly empty String
 
 157         public String getMsg() {
 
 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.
 
 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.
 
 172      * @param dpid device id of the switch to be queried
 
 173      * @return SwitchConfigStatus with outcome of check and associated config.
 
 175     SwitchConfigStatus checkSwitchConfig(DeviceId dpid);
 
 178      * Reserved for future use.
 
 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.
 
 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.
 
 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.
 
 196      * @param linkTuple unidirectional link to be queried
 
 197      * @return LinkConfigStatus with outcome of check and associated config.
 
 199     LinkConfigStatus checkLinkConfig(Link linkTuple);
 
 202      * Retrieves a list of switches that have been configured, and have been
 
 203      * determined to be 'allowed' in the network, according to configuration
 
 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.
 
 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
 
 216      * @return a non-null List of SwitchConfig which may be empty
 
 218     List<SwitchConfig> getConfiguredAllowedSwitches();
 
 221      * Reserved for future use.
 
 223      * Retrieves a list of links that have been configured, and have been
 
 224      * determined to be 'allowed' in the network, according to configuration
 
 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.
 
 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.
 
 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.
 
 241      * @return a non-null List of LinkConfig which may be empty
 
 243     List<LinkConfig> getConfiguredAllowedLinks();
 
 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
 
 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'.
 
 254     DeviceId getDpidForName(String name);