Brian O'Connor | 5dcf578 | 2016-04-09 02:13:23 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | d6a135a | 2017-08-03 22:46:05 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Foundation |
Brian O'Connor | 5dcf578 | 2016-04-09 02:13:23 -0700 | [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 | */ |
alshabib | 36a4d73 | 2016-06-01 16:03:59 -0700 | [diff] [blame] | 16 | package org.opencord.olt; |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 17 | |
| 18 | import org.onlab.packet.VlanId; |
| 19 | import org.onosproject.event.AbstractEvent; |
| 20 | import org.onosproject.net.DeviceId; |
Jonathan Hart | 1d34c8b | 2018-05-05 15:37:28 -0700 | [diff] [blame] | 21 | import org.onosproject.net.Port; |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 22 | |
| 23 | import java.util.Optional; |
| 24 | |
| 25 | /** |
| 26 | * Describes an access device event. |
| 27 | */ |
| 28 | public class AccessDeviceEvent extends AbstractEvent<AccessDeviceEvent.Type, DeviceId> { |
| 29 | |
| 30 | private final Optional<VlanId> sVlan; |
| 31 | private final Optional<VlanId> cVlan; |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 32 | private final Optional<Integer> tpId; |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 33 | |
Jonathan Hart | 1d34c8b | 2018-05-05 15:37:28 -0700 | [diff] [blame] | 34 | private final Optional<Port> port; |
| 35 | |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 36 | public enum Type { |
| 37 | /** |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 38 | * An access device connected. |
| 39 | */ |
| 40 | DEVICE_CONNECTED, |
| 41 | |
| 42 | /** |
| 43 | * An access device disconnected. |
| 44 | */ |
Jonathan Hart | 1d34c8b | 2018-05-05 15:37:28 -0700 | [diff] [blame] | 45 | DEVICE_DISCONNECTED, |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 46 | |
Jonathan Hart | 1d34c8b | 2018-05-05 15:37:28 -0700 | [diff] [blame] | 47 | /** |
| 48 | * A new UNI port has been detected. |
| 49 | */ |
| 50 | UNI_ADDED, |
| 51 | |
| 52 | /** |
| 53 | * An existing UNI port was removed. |
| 54 | */ |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 55 | UNI_REMOVED, |
| 56 | |
| 57 | /** |
| 58 | * A uniTag (one service) was registered and provisioned. |
| 59 | */ |
| 60 | SUBSCRIBER_UNI_TAG_REGISTERED, |
| 61 | |
| 62 | /** |
| 63 | * A uniTag (one service) was unregistered and deprovisioned. |
| 64 | */ |
| 65 | SUBSCRIBER_UNI_TAG_UNREGISTERED, |
| 66 | |
| 67 | /** |
| 68 | * A uniTag (one service) was failed while registration. |
| 69 | */ |
| 70 | SUBSCRIBER_UNI_TAG_REGISTRATION_FAILED, |
| 71 | |
| 72 | /** |
| 73 | * A uniTag (one service) was failed while unregistration. |
| 74 | */ |
| 75 | SUBSCRIBER_UNI_TAG_UNREGISTRATION_FAILED |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | /** |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 79 | * Creates an event of a given type and for the specified device, port, |
| 80 | * along with the cVlanId, sVlanId, and tpId. The vlan fields may not be provisioned |
| 81 | * if the event is related to the access device (dis)connection. |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 82 | * |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 83 | * @param type the event type |
| 84 | * @param deviceId the device id |
| 85 | * @param port the device port |
| 86 | * @param sVlanId the service vlan |
| 87 | * @param cVlanId the customer vlan |
| 88 | * @param tpId the technology profile |
| 89 | */ |
| 90 | public AccessDeviceEvent(Type type, DeviceId deviceId, |
| 91 | Port port, |
| 92 | VlanId sVlanId, |
| 93 | VlanId cVlanId, |
| 94 | Integer tpId) { |
| 95 | super(type, deviceId); |
| 96 | this.port = Optional.ofNullable(port); |
| 97 | this.sVlan = Optional.ofNullable(sVlanId); |
| 98 | this.cVlan = Optional.ofNullable(cVlanId); |
| 99 | this.tpId = Optional.ofNullable(tpId); |
| 100 | } |
| 101 | |
| 102 | /** |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 103 | * Creates an event of a given type and for the specified device, |
| 104 | * along with the cVlanId and sVlanId. The vlan fields may not be provisioned |
| 105 | * if the event is related to the access device (dis)connection. |
| 106 | * |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 107 | * @param type the event type |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 108 | * @param deviceId the device id |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 109 | * @param sVlanId the service vlan |
| 110 | * @param cVlanId the customer vlan |
| 111 | * @param tpId the technology profile id |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 112 | */ |
| 113 | public AccessDeviceEvent(Type type, DeviceId deviceId, |
| 114 | VlanId sVlanId, |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 115 | VlanId cVlanId, |
| 116 | Integer tpId) { |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 117 | super(type, deviceId); |
| 118 | this.sVlan = Optional.ofNullable(sVlanId); |
| 119 | this.cVlan = Optional.ofNullable(cVlanId); |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 120 | this.tpId = Optional.ofNullable(tpId); |
Jonathan Hart | 1d34c8b | 2018-05-05 15:37:28 -0700 | [diff] [blame] | 121 | this.port = Optional.empty(); |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 122 | } |
| 123 | |
| 124 | /** |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 125 | * Creates an event of a given type and for the specified device and port. |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 126 | * |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 127 | * @param type the event type |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 128 | * @param deviceId the device id |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 129 | * @param port the device port |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 130 | */ |
Jonathan Hart | 1d34c8b | 2018-05-05 15:37:28 -0700 | [diff] [blame] | 131 | public AccessDeviceEvent(Type type, DeviceId deviceId, Port port) { |
| 132 | super(type, deviceId); |
| 133 | this.sVlan = Optional.empty(); |
| 134 | this.cVlan = Optional.empty(); |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 135 | this.tpId = Optional.empty(); |
Jonathan Hart | 1d34c8b | 2018-05-05 15:37:28 -0700 | [diff] [blame] | 136 | this.port = Optional.ofNullable(port); |
| 137 | } |
| 138 | |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 139 | public Optional<VlanId> sVlanId() { |
| 140 | return sVlan; |
| 141 | } |
| 142 | |
| 143 | public Optional<VlanId> cVlanId() { |
| 144 | return cVlan; |
| 145 | } |
| 146 | |
Jonathan Hart | 1d34c8b | 2018-05-05 15:37:28 -0700 | [diff] [blame] | 147 | public Optional<Port> port() { |
| 148 | return port; |
| 149 | } |
| 150 | |
Andrea Campanella | cbbb795 | 2019-11-25 06:38:41 +0000 | [diff] [blame] | 151 | public Optional<Integer> tpId() { |
| 152 | return tpId; |
| 153 | } |
| 154 | |
alshabib | 8e4fd2f | 2016-01-12 15:55:53 -0800 | [diff] [blame] | 155 | } |