CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.net.behaviour; |
| 17 | |
HelloONOS | acd86360 | 2019-07-31 18:23:25 +0900 | [diff] [blame] | 18 | import java.util.ArrayList; |
CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 19 | import java.util.Collection; |
| 20 | import java.util.List; |
| 21 | import java.util.Set; |
| 22 | |
| 23 | import org.onosproject.net.PortNumber; |
| 24 | import org.onosproject.net.device.PortDescription; |
| 25 | import org.onosproject.net.driver.HandlerBehaviour; |
| 26 | |
| 27 | /** |
| 28 | * Behaviour for handling various drivers for bridge configurations. |
| 29 | */ |
| 30 | public interface BridgeConfig extends HandlerBehaviour { |
| 31 | |
| 32 | /** |
Hyunsun Moon | 1251e19 | 2016-06-07 16:57:05 -0700 | [diff] [blame] | 33 | * 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 | /** |
CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 41 | * 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 Moon | 52b9336 | 2016-01-19 11:53:57 -0800 | [diff] [blame] | 55 | * 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 | /** |
HelloONOS | acd86360 | 2019-07-31 18:23:25 +0900 | [diff] [blame] | 63 | * 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 Campanella | 65ece15 | 2016-01-21 13:33:43 -0800 | [diff] [blame] | 76 | * 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 | /** |
HelloONOS | 0854c04 | 2019-02-18 20:09:17 +0900 | [diff] [blame] | 84 | * 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 | /** |
CNlucius | a66c397 | 2015-09-06 20:31:29 +0800 | [diff] [blame] | 96 | * 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 | } |