blob: 3f96496bf637639f62eb9b83b4ef21bda3451f8d [file] [log] [blame]
Thomas Vachuska33979fd2015-07-31 11:41:14 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Thomas Vachuska33979fd2015-07-31 11:41:14 -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 */
16package org.onosproject.incubator.net.virtual;
17
18import org.onosproject.event.AbstractEvent;
19
20/**
21 * Describes virtual network event.
22 */
23public class VirtualNetworkEvent extends AbstractEvent<VirtualNetworkEvent.Type, NetworkId> {
24
25 /**
26 * Type of virtual network events.
27 */
28 public enum Type {
29 /**
30 * Signifies that a new tenant identifier was registered.
31 */
32 TENANT_REGISTERED,
33 /**
34 * Signifies that a tenant identifier was unregistered.
35 */
36 TENANT_UNREGISTERED,
37 /**
38 * Signifies that a new virtual network was added.
39 */
40 NETWORK_ADDED,
41 /**
42 * Signifies that a virtual network was updated.
43 */
44 NETWORK_UPDATED,
45 /**
46 * Signifies that a virtual network was removed.
47 */
Claudine Chiu945828d2016-11-21 12:47:07 -050048 NETWORK_REMOVED,
49 /**
50 * Signifies that a new virtual network device was added.
51 */
52 VIRTUAL_DEVICE_ADDED,
53 /**
54 * Signifies that a virtual network device was updated.
55 */
56 VIRTUAL_DEVICE_UPDATED,
57 /**
58 * Signifies that a virtual network device was removed.
59 */
Claudine Chiu7f872a72016-12-16 13:51:39 -050060 VIRTUAL_DEVICE_REMOVED,
61 /**
62 * Signifies that a new virtual network port was added.
63 */
64 VIRTUAL_PORT_ADDED,
65 /**
66 * Signifies that a virtual network port was updated.
67 */
68 VIRTUAL_PORT_UPDATED,
69 /**
70 * Signifies that a virtual network port was removed.
71 */
72 VIRTUAL_PORT_REMOVED
Thomas Vachuska33979fd2015-07-31 11:41:14 -070073 }
74
Claudine Chiu945828d2016-11-21 12:47:07 -050075 private final VirtualDevice virtualDevice;
Claudine Chiu7f872a72016-12-16 13:51:39 -050076 private final VirtualPort virtualPort;
Claudine Chiu945828d2016-11-21 12:47:07 -050077
Thomas Vachuska33979fd2015-07-31 11:41:14 -070078 /**
Claudine Chiu945828d2016-11-21 12:47:07 -050079 * Creates an event of a given type and for the specified subject.
Thomas Vachuska33979fd2015-07-31 11:41:14 -070080 *
81 * @param type event type
82 * @param subject event subject
83 */
84 public VirtualNetworkEvent(Type type, NetworkId subject) {
Claudine Chiu7f872a72016-12-16 13:51:39 -050085 this(type, subject, null, null);
Claudine Chiu945828d2016-11-21 12:47:07 -050086 }
87
88 /**
89 * Creates an event of a given type and for the specified subject and the
90 * virtual device.
91 *
92 * @param type event type
93 * @param subject event subject
94 * @param virtualDevice virtual device
95 */
96 public VirtualNetworkEvent(Type type, NetworkId subject, VirtualDevice virtualDevice) {
Claudine Chiu7f872a72016-12-16 13:51:39 -050097 this(type, subject, virtualDevice, null);
98 }
99
100 /**
Claudine Chiu7f872a72016-12-16 13:51:39 -0500101 * Creates an event of a given type and for the specified subject, virtual device and
102 * virtual port.
103 *
104 * @param type event type
105 * @param subject event subject
106 * @param virtualDevice virtual device
107 * @param virtualPort virtual port
108 */
Claudine Chiu465a2602017-03-17 18:33:36 -0400109 public VirtualNetworkEvent(Type type, NetworkId subject, VirtualDevice virtualDevice,
Claudine Chiu7f872a72016-12-16 13:51:39 -0500110 VirtualPort virtualPort) {
Thomas Vachuska33979fd2015-07-31 11:41:14 -0700111 super(type, subject);
Claudine Chiu945828d2016-11-21 12:47:07 -0500112 this.virtualDevice = virtualDevice;
Claudine Chiu7f872a72016-12-16 13:51:39 -0500113 this.virtualPort = virtualPort;
Thomas Vachuska33979fd2015-07-31 11:41:14 -0700114 }
115
116 /**
117 * Creates an event of a given type and for the specified subject and time.
118 *
Claudine Chiu7f872a72016-12-16 13:51:39 -0500119 * @param type event type
Thomas Vachuska33979fd2015-07-31 11:41:14 -0700120 * @param subject event subject
121 * @param time occurrence time
122 */
123 public VirtualNetworkEvent(Type type, NetworkId subject, long time) {
Claudine Chiu7f872a72016-12-16 13:51:39 -0500124 this(type, subject, null, null, time);
Claudine Chiu945828d2016-11-21 12:47:07 -0500125 }
126
127 /**
128 * Creates an event of a given type and for the specified subject, virtual device and time.
129 *
Claudine Chiu7f872a72016-12-16 13:51:39 -0500130 * @param type event type
Claudine Chiu945828d2016-11-21 12:47:07 -0500131 * @param subject event subject
132 * @param virtualDevice virtual device
133 * @param time occurrence time
134 */
Claudine Chiu7f872a72016-12-16 13:51:39 -0500135 public VirtualNetworkEvent(Type type, NetworkId subject, VirtualDevice virtualDevice,
136 long time) {
137 this(type, subject, virtualDevice, null, time);
138 }
139
140 /**
141 * Creates an event of a given type and for the specified subject, virtual port and time.
142 *
143 * @param type device event type
144 * @param subject event subject
145 * @param virtualPort virtual port
146 * @param time occurrence time
147 */
148 public VirtualNetworkEvent(Type type, NetworkId subject, VirtualPort virtualPort,
149 long time) {
150 this(type, subject, null, virtualPort, time);
151 }
152
153 /**
154 * Creates an event of a given type and for the specified subject, virtual device,
155 * virtual port and time.
156 *
157 * @param type device event type
158 * @param subject event subject
159 * @param virtualDevice virtual device
160 * @param virtualPort virtual port
161 * @param time occurrence time
162 */
163 private VirtualNetworkEvent(Type type, NetworkId subject, VirtualDevice virtualDevice,
164 VirtualPort virtualPort, long time) {
Thomas Vachuska33979fd2015-07-31 11:41:14 -0700165 super(type, subject, time);
Claudine Chiu945828d2016-11-21 12:47:07 -0500166 this.virtualDevice = virtualDevice;
Claudine Chiu7f872a72016-12-16 13:51:39 -0500167 this.virtualPort = virtualPort;
Claudine Chiu945828d2016-11-21 12:47:07 -0500168 }
169
170 /**
171 * Returns virtual device affected by event - may be null (for events relating to
Claudine Chiu465a2602017-03-17 18:33:36 -0400172 * tenants and virtual networks).
Claudine Chiu945828d2016-11-21 12:47:07 -0500173 *
174 * @return virtual device
175 */
176 public VirtualDevice virtualDevice() {
177 return virtualDevice;
Thomas Vachuska33979fd2015-07-31 11:41:14 -0700178 }
Claudine Chiu7f872a72016-12-16 13:51:39 -0500179
180 /**
181 * Returns virtual port affected by event - may be null (for events relating to
182 * tenants, virtual networks and virtual devices).
183 *
184 * @return virtual port
185 */
186 public VirtualPort virtualPort() {
187 return virtualPort;
188 }
Thomas Vachuska33979fd2015-07-31 11:41:14 -0700189}