Committed by
Gerrit Code Review
Creating L2SwitchVlanConfigBehaviour to manage VLANs on legacy L2 switch devices
- Allows creating/deleting/enabling VLANs on a device as a whole - Not to be confused with applying VLANs on interfaces (e.g. access/trunk VLANs) Change-Id: Ib830ecea77cdf882b3f9486fbea23d2acea6b947
Showing
1 changed file
with
118 additions
and
0 deletions
| 1 | +/* | ||
| 2 | + * Copyright 2016-present 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 | + */ | ||
| 16 | +package org.onosproject.net.behaviour; | ||
| 17 | + | ||
| 18 | +import com.google.common.annotations.Beta; | ||
| 19 | +import org.onlab.packet.VlanId; | ||
| 20 | +import org.onosproject.net.driver.HandlerBehaviour; | ||
| 21 | + | ||
| 22 | +import java.util.Arrays; | ||
| 23 | +import java.util.Collection; | ||
| 24 | + | ||
| 25 | +/** | ||
| 26 | + * Means to configure VLANs on legacy L2 switch devices. | ||
| 27 | + */ | ||
| 28 | +@Beta | ||
| 29 | +public interface L2SwitchVlanConfigBehaviour extends HandlerBehaviour { | ||
| 30 | + /** | ||
| 31 | + * Provides the VLANs configured on a device. | ||
| 32 | + * | ||
| 33 | + * @return the configured VLANs on the device | ||
| 34 | + */ | ||
| 35 | + Collection<VlanId> getVlans(); | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * Adds a VLAN on a device. | ||
| 39 | + * Default enabled/disabled status of VLAN after depends on device. | ||
| 40 | + * | ||
| 41 | + * @param vlanId the VLAN to add | ||
| 42 | + * @return true, if the VLAN was added successfully; false otherwise | ||
| 43 | + */ | ||
| 44 | + default boolean addVlan(VlanId vlanId) { | ||
| 45 | + return addVlan(Arrays.asList(vlanId)); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * Adds VLANs on a device. | ||
| 50 | + * Default enabled/disabled status of VLAN after depends on device. | ||
| 51 | + * | ||
| 52 | + * @param vlanIds the VLANs to add | ||
| 53 | + * @return true, if the VLANs were added successfully; false otherwise | ||
| 54 | + */ | ||
| 55 | + boolean addVlan(Collection<VlanId> vlanIds); | ||
| 56 | + | ||
| 57 | + /** | ||
| 58 | + * Removes a VLAN from a device. | ||
| 59 | + * | ||
| 60 | + * @param vlanId the VLAN to remove | ||
| 61 | + * @return true, if the VLAN was removed successfully; false otherwise | ||
| 62 | + */ | ||
| 63 | + default boolean removeVlan(VlanId vlanId) { | ||
| 64 | + return removeVlan(Arrays.asList(vlanId)); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * Removes VLANs from a device. | ||
| 69 | + * | ||
| 70 | + * @param vlanIds the VLANs to remove | ||
| 71 | + * @return true, if the VLANs were removed successfully; false otherwise | ||
| 72 | + */ | ||
| 73 | + boolean removeVlan(Collection<VlanId> vlanIds); | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * Obtains the status of a VLAN on a device. | ||
| 77 | + * | ||
| 78 | + * @param vlanId the VLAN to check | ||
| 79 | + * @return true, if the VLAN is configured and enabled; false otherwise | ||
| 80 | + */ | ||
| 81 | + boolean isEnabled(VlanId vlanId); | ||
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * Enables a VLAN on a device. | ||
| 85 | + * | ||
| 86 | + * @param vlanId the VLAN to enable | ||
| 87 | + * @return true, if the VLAN was enabled successfully; false otherwise | ||
| 88 | + */ | ||
| 89 | + default boolean enableVlan(VlanId vlanId) { | ||
| 90 | + return enableVlan(Arrays.asList(vlanId)); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * Enables VLANs on a device. | ||
| 95 | + * | ||
| 96 | + * @param vlanIds the VLANs to enable | ||
| 97 | + * @return true, if the VLANs were enabled successfully; false otherwise | ||
| 98 | + */ | ||
| 99 | + boolean enableVlan(Collection<VlanId> vlanIds); | ||
| 100 | + | ||
| 101 | + /** | ||
| 102 | + * Disables a VLAN on a device. | ||
| 103 | + * | ||
| 104 | + * @param vlanId the VLAN to disable | ||
| 105 | + * @return true, if the VLAN was disabled successfully; false otherwise | ||
| 106 | + */ | ||
| 107 | + default boolean disableVlan(VlanId vlanId) { | ||
| 108 | + return disableVlan(Arrays.asList(vlanId)); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + /** | ||
| 112 | + * Disables VLANs on a device. | ||
| 113 | + * | ||
| 114 | + * @param vlanIds VLANs to disable | ||
| 115 | + * @return true, if the VLANs were disabled successfully; false otherwise | ||
| 116 | + */ | ||
| 117 | + boolean disableVlan(Collection<VlanId> vlanIds); | ||
| 118 | +} |
-
Please register or login to post a comment