aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java
blob: afbb0fcc9013648ed0ea1798c9f64e47ebc2b342 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/*
 * Copyright 2015 Open Networking Laboratory
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.onosproject.segmentrouting.config;

import java.util.List;

import org.onosproject.net.DeviceId;
import org.onosproject.net.Link;
import org.onosproject.segmentrouting.config.NetworkConfig.LinkConfig;
import org.onosproject.segmentrouting.config.NetworkConfig.SwitchConfig;

/**
 * Exposes methods to retrieve network configuration.
 *
 * TODO: currently only startup-configuration is exposed and such configuration
 * cannot be changed at runtime. Need to add runtime support for changes to
 * configuration (via REST/CLI) in future releases.
 *
 * TODO: return immutable objects or defensive copies of network config so that
 * users of this API do not inadvertently or maliciously change network config.
 *
 * @deprecated in Drake; see org.onosproject.net.config
 */
@Deprecated
public interface NetworkConfigService {

    /**
     * Suggests the action to be taken by the caller given the configuration
     * associated with the queried network-object (eg. switch, link etc.).
     */
    enum NetworkConfigState {
        /**
         * Associated network object has been configured to not be allowed in
         * the network.
         */
        DENY,

        /**
         * Associated network object has been configured to be allowed in the
         * network.
         */
        ACCEPT,

        /**
         * Associated network object has been configured to be allowed in the
         * network. In addition, there are configured parameters that should be
         * added to the object.
         */
        ACCEPT_ADD,
    }

    /**
     * Returns the configuration outcome (accept, deny etc.), and any configured
     * parameters to the caller, in response to a query for the configuration
     * associated with a switch.
     */
    class SwitchConfigStatus {
        private NetworkConfigState configState;
        private SwitchConfig switchConfig;
        private String msg;

        SwitchConfigStatus(NetworkConfigState configState,
                SwitchConfig switchConfig, String msg) {
            this.configState = configState;
            this.switchConfig = switchConfig;
            this.msg = msg;
        }

        SwitchConfigStatus(NetworkConfigState configState,
                SwitchConfig switchConfig) {
            this.configState = configState;
            this.switchConfig = switchConfig;
            this.msg = "";
        }

        /**
         * Returns the configuration state for the switch.
         *
         * @return non-null NetworkConfigState
         */
        public NetworkConfigState getConfigState() {
            return configState;
        }

        /**
         * Returns the switch configuration, which may be null if no
         * configuration exists, or if the configuration state disallows the
         * switch.
         *
         * @return SwitchConfig, the switch configuration, or null
         */
        public SwitchConfig getSwitchConfig() {
            return switchConfig;
        }

        /**
         * User readable string typically used to specify the reason why a
         * switch is being disallowed.
         *
         * @return A non-null but possibly empty String
         */
        public String getMsg() {
            return msg;
        }

    }

    /**
     * Reserved for future use.
     *
     * Returns the configuration outcome (accept, deny etc.), and any configured
     * parameters to the caller, in response to a query for the configuration
     * associated with a link.
     */
    class LinkConfigStatus {
        private NetworkConfigState configState;
        private LinkConfig linkConfig;
        private String msg;

        LinkConfigStatus(NetworkConfigState configState,
                LinkConfig linkConfig, String msg) {
            this.configState = configState;
            this.linkConfig = linkConfig;
            this.msg = msg;
        }

        LinkConfigStatus(NetworkConfigState configState,
                LinkConfig linkConfig) {
            this.configState = configState;
            this.linkConfig = linkConfig;
            this.msg = "";
        }

        /**
         * Returns the configuration state for the link.
         *
         * @return non-null NetworkConfigState
         */
        public NetworkConfigState getConfigState() {
            return configState;
        }

        /**
         * Returns the link configuration, which may be null if no configuration
         * exists, or if the configuration state disallows the link.
         *
         * @return SwitchConfig, the switch configuration, or null
         */
        public LinkConfig getLinkConfig() {
            return linkConfig;
        }

        /**
         * User readable string typically used to specify the reason why a link
         * is being disallowed.
         *
         * @return msg A non-null but possibly empty String
         */
        public String getMsg() {
            return msg;
        }

    }

    /**
     * Checks the switch configuration (if any) associated with the 'dpid'.
     * Determines if the switch should be allowed or denied according to
     * configuration rules.
     *
     * The method always returns a non-null SwitchConfigStatus. The enclosed
     * ConfigState contains the result of the check. The enclosed SwitchConfig
     * may or may not be null, depending on the outcome of the check.
     *
     * @param dpid device id of the switch to be queried
     * @return SwitchConfigStatus with outcome of check and associated config.
     */
    SwitchConfigStatus checkSwitchConfig(DeviceId dpid);

    /**
     * Reserved for future use.
     *
     * Checks the link configuration (if any) associated with the 'link'.
     * Determines if the link should be allowed or denied according to
     * configuration rules. Note that the 'link' is a unidirectional link which
     * checked against configuration that is typically defined for a
     * bidirectional link. The caller may make a second call if it wishes to
     * check the 'reverse' direction.
     *
     * Also note that the configuration may not specify ports for a given
     * bidirectional link. In such cases, the configuration applies to all links
     * between the two switches. This method will check the given 'link' against
     * such configuration.

     * The method always returns a non-null LinkConfigStatus. The enclosed
     * ConfigState contains the result of the check. The enclosed LinkConfig may
     * or may not be null, depending on the outcome of the check.
     *
     * @param linkTuple unidirectional link to be queried
     * @return LinkConfigStatus with outcome of check and associated config.
     */
    LinkConfigStatus checkLinkConfig(Link linkTuple);

    /**
     * Retrieves a list of switches that have been configured, and have been
     * determined to be 'allowed' in the network, according to configuration
     * rules.
     *
     * Note that it is possible that there are other switches that are allowed
     * in the network that have NOT been configured. Such switches will not be a
     * part of the returned list.
     *
     * Also note that it is possible that some switches will not be discovered
     * and the only way the controller can know about these switches is via
     * configuration. Such switches will be included in this list. It is up to
     * the caller to determine which SwitchConfig applies to non-discovered
     * switches.
     *
     * @return a non-null List of SwitchConfig which may be empty
     */
    List<SwitchConfig> getConfiguredAllowedSwitches();

    /**
     * Reserved for future use.
     *
     * Retrieves a list of links that have been configured, and have been
     * determined to be 'allowed' in the network, according to configuration
     * rules.
     *
     * Note that it is possible that there are other links that are allowed in
     * the network that have NOT been configured. Such links will not be a part
     * of the returned list.
     *
     * Also note that it is possible that some links will not be discovered and
     * the only way the controller can know about these links is via
     * configuration. Such links will be included in this list. It is up to the
     * caller to determine which LinkConfig applies to non-discovered links.
     *
     * In addition, note that the LinkConfig applies to the configured
     * bi-directional link, which may or may not have declared ports. The
     * associated unidirectional LinkTuple can be retrieved from the
     * getLinkTupleList() method in the LinkConfig object.
     *
     * @return a non-null List of LinkConfig which may be empty
     */
    List<LinkConfig> getConfiguredAllowedLinks();

    /**
     * Retrieves the Dpid associated with a 'name' for a configured switch
     * object. This method does not check of the switches are 'allowed' by
     * config.
     *
     * @param name device name
     * @return the Dpid corresponding to a given 'name', or null if no
     *         configured switch was found for the given 'name'.
     */
    DeviceId getDpidForName(String name);

}