blob: 3c189dd23d24424606c8c5f1e35ba650042e5911 [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;
32
Jonathan Hart1d34c8b2018-05-05 15:37:28 -070033 private final Optional<Port> port;
34
alshabib8e4fd2f2016-01-12 15:55:53 -080035 public enum Type {
36 /**
37 * A subscriber was registered and provisioned.
38 */
39 SUBSCRIBER_REGISTERED,
40
41 /**
42 * A subscriber was unregistered and deprovisioned.
43 */
44 SUBSCRIBER_UNREGISTERED,
45
46 /**
47 * An access device connected.
48 */
49 DEVICE_CONNECTED,
50
51 /**
52 * An access device disconnected.
53 */
Jonathan Hart1d34c8b2018-05-05 15:37:28 -070054 DEVICE_DISCONNECTED,
alshabib8e4fd2f2016-01-12 15:55:53 -080055
Jonathan Hart1d34c8b2018-05-05 15:37:28 -070056 /**
57 * A new UNI port has been detected.
58 */
59 UNI_ADDED,
60
61 /**
62 * An existing UNI port was removed.
63 */
64 UNI_REMOVED
alshabib8e4fd2f2016-01-12 15:55:53 -080065 }
66
67 /**
68 *
69 * Creates an event of a given type and for the specified device,
70 * along with the cVlanId and sVlanId. The vlan fields may not be provisioned
71 * if the event is related to the access device (dis)connection.
72 *
73 * @param type the event type
74 * @param deviceId the device id
75 * @param sVlanId the service vlan
76 * @param cVlanId the customer vlan
77 */
78 public AccessDeviceEvent(Type type, DeviceId deviceId,
79 VlanId sVlanId,
80 VlanId cVlanId) {
81 super(type, deviceId);
82 this.sVlan = Optional.ofNullable(sVlanId);
83 this.cVlan = Optional.ofNullable(cVlanId);
Jonathan Hart1d34c8b2018-05-05 15:37:28 -070084 this.port = Optional.empty();
alshabib8e4fd2f2016-01-12 15:55:53 -080085 }
86
87 /**
88 *
89 * Creates an event of a given type and for the specified device, and timestamp
90 * along with the cVlanId and sVlanId. The vlan fields may not be provisioned
91 * if the event is related to the access device (dis)connection.
92 *
93 * @param type the event type
94 * @param deviceId the device id
95 * @param time a timestamp
96 * @param sVlanId the service vlan
97 * @param cVlanId the customer vlan
98 */
99 protected AccessDeviceEvent(Type type, DeviceId deviceId, long time,
100 VlanId sVlanId,
101 VlanId cVlanId) {
102 super(type, deviceId, time);
103 this.sVlan = Optional.ofNullable(sVlanId);
104 this.cVlan = Optional.ofNullable(cVlanId);
Jonathan Hart1d34c8b2018-05-05 15:37:28 -0700105 this.port = Optional.empty();
alshabib8e4fd2f2016-01-12 15:55:53 -0800106
107 }
108
Jonathan Hart1d34c8b2018-05-05 15:37:28 -0700109 public AccessDeviceEvent(Type type, DeviceId deviceId, Port port) {
110 super(type, deviceId);
111 this.sVlan = Optional.empty();
112 this.cVlan = Optional.empty();
113 this.port = Optional.ofNullable(port);
114 }
115
alshabib8e4fd2f2016-01-12 15:55:53 -0800116 public Optional<VlanId> sVlanId() {
117 return sVlan;
118 }
119
120 public Optional<VlanId> cVlanId() {
121 return cVlan;
122 }
123
Jonathan Hart1d34c8b2018-05-05 15:37:28 -0700124 public Optional<Port> port() {
125 return port;
126 }
127
alshabib8e4fd2f2016-01-12 15:55:53 -0800128}