blob: 7234b704501da72403f35e50d36798a5b2cfdd1c [file] [log] [blame]
Thomas Vachuska33979fd2015-07-31 11:41:14 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
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 /**
101 * Creates an event of a given type and for the specified subject and the
102 * virtual port.
103 *
104 * @param type event type
105 * @param subject event subject
106 * @param virtualPort virtual port
107 */
108 public VirtualNetworkEvent(Type type, NetworkId subject, VirtualPort virtualPort) {
109 this(type, subject, null, virtualPort);
110 }
111
112 /**
113 * Creates an event of a given type and for the specified subject, virtual device and
114 * virtual port.
115 *
116 * @param type event type
117 * @param subject event subject
118 * @param virtualDevice virtual device
119 * @param virtualPort virtual port
120 */
121 private VirtualNetworkEvent(Type type, NetworkId subject, VirtualDevice virtualDevice,
122 VirtualPort virtualPort) {
Thomas Vachuska33979fd2015-07-31 11:41:14 -0700123 super(type, subject);
Claudine Chiu945828d2016-11-21 12:47:07 -0500124 this.virtualDevice = virtualDevice;
Claudine Chiu7f872a72016-12-16 13:51:39 -0500125 this.virtualPort = virtualPort;
Thomas Vachuska33979fd2015-07-31 11:41:14 -0700126 }
127
128 /**
129 * Creates an event of a given type and for the specified subject and time.
130 *
Claudine Chiu7f872a72016-12-16 13:51:39 -0500131 * @param type event type
Thomas Vachuska33979fd2015-07-31 11:41:14 -0700132 * @param subject event subject
133 * @param time occurrence time
134 */
135 public VirtualNetworkEvent(Type type, NetworkId subject, long time) {
Claudine Chiu7f872a72016-12-16 13:51:39 -0500136 this(type, subject, null, null, time);
Claudine Chiu945828d2016-11-21 12:47:07 -0500137 }
138
139 /**
140 * Creates an event of a given type and for the specified subject, virtual device and time.
141 *
Claudine Chiu7f872a72016-12-16 13:51:39 -0500142 * @param type event type
Claudine Chiu945828d2016-11-21 12:47:07 -0500143 * @param subject event subject
144 * @param virtualDevice virtual device
145 * @param time occurrence time
146 */
Claudine Chiu7f872a72016-12-16 13:51:39 -0500147 public VirtualNetworkEvent(Type type, NetworkId subject, VirtualDevice virtualDevice,
148 long time) {
149 this(type, subject, virtualDevice, null, time);
150 }
151
152 /**
153 * Creates an event of a given type and for the specified subject, virtual port and time.
154 *
155 * @param type device event type
156 * @param subject event subject
157 * @param virtualPort virtual port
158 * @param time occurrence time
159 */
160 public VirtualNetworkEvent(Type type, NetworkId subject, VirtualPort virtualPort,
161 long time) {
162 this(type, subject, null, virtualPort, time);
163 }
164
165 /**
166 * Creates an event of a given type and for the specified subject, virtual device,
167 * virtual port and time.
168 *
169 * @param type device event type
170 * @param subject event subject
171 * @param virtualDevice virtual device
172 * @param virtualPort virtual port
173 * @param time occurrence time
174 */
175 private VirtualNetworkEvent(Type type, NetworkId subject, VirtualDevice virtualDevice,
176 VirtualPort virtualPort, long time) {
Thomas Vachuska33979fd2015-07-31 11:41:14 -0700177 super(type, subject, time);
Claudine Chiu945828d2016-11-21 12:47:07 -0500178 this.virtualDevice = virtualDevice;
Claudine Chiu7f872a72016-12-16 13:51:39 -0500179 this.virtualPort = virtualPort;
Claudine Chiu945828d2016-11-21 12:47:07 -0500180 }
181
182 /**
183 * Returns virtual device affected by event - may be null (for events relating to
Claudine Chiu7f872a72016-12-16 13:51:39 -0500184 * tenants, virtual networks and virtual ports).
Claudine Chiu945828d2016-11-21 12:47:07 -0500185 *
186 * @return virtual device
187 */
188 public VirtualDevice virtualDevice() {
189 return virtualDevice;
Thomas Vachuska33979fd2015-07-31 11:41:14 -0700190 }
Claudine Chiu7f872a72016-12-16 13:51:39 -0500191
192 /**
193 * Returns virtual port affected by event - may be null (for events relating to
194 * tenants, virtual networks and virtual devices).
195 *
196 * @return virtual port
197 */
198 public VirtualPort virtualPort() {
199 return virtualPort;
200 }
Thomas Vachuska33979fd2015-07-31 11:41:14 -0700201}