blob: 3a4146c033d82bfcefedaead220281bce172fc5c [file] [log] [blame]
Brian O'Connor5dcf5782016-04-09 02:13:23 -07001/*
Brian O'Connord6a135a2017-08-03 22:46:05 -07002 * Copyright 2016-present Open Networking Foundation
Brian O'Connor5dcf5782016-04-09 02:13:23 -07003 *
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 */
alshabib36a4d732016-06-01 16:03:59 -070016package org.opencord.olt;
alshabib8e4fd2f2016-01-12 15:55:53 -080017
18import org.onlab.packet.VlanId;
19import org.onosproject.event.AbstractEvent;
20import org.onosproject.net.DeviceId;
Jonathan Hart1d34c8b2018-05-05 15:37:28 -070021import org.onosproject.net.Port;
alshabib8e4fd2f2016-01-12 15:55:53 -080022
23import java.util.Optional;
24
25/**
26 * Describes an access device event.
27 */
28public class AccessDeviceEvent extends AbstractEvent<AccessDeviceEvent.Type, DeviceId> {
29
30 private final Optional<VlanId> sVlan;
31 private final Optional<VlanId> cVlan;
Andrea Campanellacbbb7952019-11-25 06:38:41 +000032 private final Optional<Integer> tpId;
alshabib8e4fd2f2016-01-12 15:55:53 -080033
Jonathan Hart1d34c8b2018-05-05 15:37:28 -070034 private final Optional<Port> port;
35
alshabib8e4fd2f2016-01-12 15:55:53 -080036 public enum Type {
37 /**
alshabib8e4fd2f2016-01-12 15:55:53 -080038 * An access device connected.
39 */
40 DEVICE_CONNECTED,
41
42 /**
43 * An access device disconnected.
44 */
Jonathan Hart1d34c8b2018-05-05 15:37:28 -070045 DEVICE_DISCONNECTED,
alshabib8e4fd2f2016-01-12 15:55:53 -080046
Jonathan Hart1d34c8b2018-05-05 15:37:28 -070047 /**
48 * A new UNI port has been detected.
49 */
50 UNI_ADDED,
51
52 /**
53 * An existing UNI port was removed.
54 */
Andrea Campanellacbbb7952019-11-25 06:38:41 +000055 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
alshabib8e4fd2f2016-01-12 15:55:53 -080076 }
77
78 /**
Andrea Campanellacbbb7952019-11-25 06:38:41 +000079 * 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.
alshabib8e4fd2f2016-01-12 15:55:53 -080082 *
Andrea Campanellacbbb7952019-11-25 06:38:41 +000083 * @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 /**
alshabib8e4fd2f2016-01-12 15:55:53 -0800103 * 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 Campanellacbbb7952019-11-25 06:38:41 +0000107 * @param type the event type
alshabib8e4fd2f2016-01-12 15:55:53 -0800108 * @param deviceId the device id
Andrea Campanellacbbb7952019-11-25 06:38:41 +0000109 * @param sVlanId the service vlan
110 * @param cVlanId the customer vlan
111 * @param tpId the technology profile id
alshabib8e4fd2f2016-01-12 15:55:53 -0800112 */
113 public AccessDeviceEvent(Type type, DeviceId deviceId,
114 VlanId sVlanId,
Andrea Campanellacbbb7952019-11-25 06:38:41 +0000115 VlanId cVlanId,
116 Integer tpId) {
alshabib8e4fd2f2016-01-12 15:55:53 -0800117 super(type, deviceId);
118 this.sVlan = Optional.ofNullable(sVlanId);
119 this.cVlan = Optional.ofNullable(cVlanId);
Andrea Campanellacbbb7952019-11-25 06:38:41 +0000120 this.tpId = Optional.ofNullable(tpId);
Jonathan Hart1d34c8b2018-05-05 15:37:28 -0700121 this.port = Optional.empty();
alshabib8e4fd2f2016-01-12 15:55:53 -0800122 }
123
124 /**
Andrea Campanellacbbb7952019-11-25 06:38:41 +0000125 * Creates an event of a given type and for the specified device and port.
alshabib8e4fd2f2016-01-12 15:55:53 -0800126 *
Andrea Campanellacbbb7952019-11-25 06:38:41 +0000127 * @param type the event type
alshabib8e4fd2f2016-01-12 15:55:53 -0800128 * @param deviceId the device id
Andrea Campanellacbbb7952019-11-25 06:38:41 +0000129 * @param port the device port
alshabib8e4fd2f2016-01-12 15:55:53 -0800130 */
Jonathan Hart1d34c8b2018-05-05 15:37:28 -0700131 public AccessDeviceEvent(Type type, DeviceId deviceId, Port port) {
132 super(type, deviceId);
133 this.sVlan = Optional.empty();
134 this.cVlan = Optional.empty();
Andrea Campanellacbbb7952019-11-25 06:38:41 +0000135 this.tpId = Optional.empty();
Jonathan Hart1d34c8b2018-05-05 15:37:28 -0700136 this.port = Optional.ofNullable(port);
137 }
138
alshabib8e4fd2f2016-01-12 15:55:53 -0800139 public Optional<VlanId> sVlanId() {
140 return sVlan;
141 }
142
143 public Optional<VlanId> cVlanId() {
144 return cVlan;
145 }
146
Jonathan Hart1d34c8b2018-05-05 15:37:28 -0700147 public Optional<Port> port() {
148 return port;
149 }
150
Andrea Campanellacbbb7952019-11-25 06:38:41 +0000151 public Optional<Integer> tpId() {
152 return tpId;
153 }
154
alshabib8e4fd2f2016-01-12 15:55:53 -0800155}