blob: d155a14d77f6ef2c7f30cbd88543a16918fc1e8e [file] [log] [blame]
CNluciusa66c3972015-09-06 20:31:29 +08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
CNluciusa66c3972015-09-06 20:31:29 +08003 *
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 */
16package org.onosproject.net.behaviour;
17
HelloONOSacd863602019-07-31 18:23:25 +090018import java.util.ArrayList;
CNluciusa66c3972015-09-06 20:31:29 +080019import java.util.Collection;
20import java.util.List;
21import java.util.Set;
22
23import org.onosproject.net.PortNumber;
24import org.onosproject.net.device.PortDescription;
25import org.onosproject.net.driver.HandlerBehaviour;
26
27/**
28 * Behaviour for handling various drivers for bridge configurations.
29 */
30public interface BridgeConfig extends HandlerBehaviour {
31
32 /**
Hyunsun Moon1251e192016-06-07 16:57:05 -070033 * Adds a bridge with a given description.
34 *
35 * @param bridgeDescription bridge description
36 * @return true if succeeds, or false
37 */
38 boolean addBridge(BridgeDescription bridgeDescription);
39
40 /**
CNluciusa66c3972015-09-06 20:31:29 +080041 * Remove a bridge.
42 *
43 * @param bridgeName bridge name
44 */
45 void deleteBridge(BridgeName bridgeName);
46
47 /**
48 * Remove a bridge.
49 *
50 * @return bridge collection
51 */
52 Collection<BridgeDescription> getBridges();
53
54 /**
Hyunsun Moon52b93362016-01-19 11:53:57 -080055 * Adds a port to a given bridge.
56 *
57 * @param bridgeName bridge name
58 * @param portName port name
59 */
60 void addPort(BridgeName bridgeName, String portName);
61
62 /**
HelloONOSacd863602019-07-31 18:23:25 +090063 * Adds ports to a given bridge.
64 *
65 * @param bridgeName bridge name
66 * @param portNames list port name
67 */
68 default void addPorts(BridgeName bridgeName, List<String> portNames) {
69 List<String> portsList = new ArrayList<>();
70 for (String portName : portNames) {
71 portsList.add(portName);
72 }
73 }
74
75 /**
Andrea Campanella65ece152016-01-21 13:33:43 -080076 * Removes a port from a given bridge.
77 *
78 * @param bridgeName bridge name
79 * @param portName port name
80 */
81 void deletePort(BridgeName bridgeName, String portName);
82
83 /**
HelloONOS0854c042019-02-18 20:09:17 +090084 * Deletes ports to a given bridge.
85 * @param bridgeName bridge name
86 * @param portNames list port names
87 */
88 default void deletePorts(BridgeName bridgeName, List<String> portNames) {
89 for (String portName : portNames) {
90 deletePort(bridgeName, portName);
91 }
92 }
93
94
95 /**
CNluciusa66c3972015-09-06 20:31:29 +080096 * Delete a logical/virtual port.
97 *
98 * @return collection of port
99 */
100 Collection<PortDescription> getPorts();
101
102 /**
103 * Get a collection of port.
104 *
105 * @return portNumbers set of PortNumber
106 */
107 Set<PortNumber> getPortNumbers();
108
109 /**
110 * Get logical/virtual ports by ifaceIds.
111 *
112 * @param ifaceIds the ifaceid that needed
113 * @return list of PortNumber
114 */
115 List<PortNumber> getLocalPorts(Iterable<String> ifaceIds);
116}