Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -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 | */ |
| 16 | package org.onosproject.incubator.net.virtual; |
| 17 | |
| 18 | import org.onosproject.event.AbstractEvent; |
| 19 | |
| 20 | /** |
| 21 | * Describes virtual network event. |
| 22 | */ |
| 23 | public 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 Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 48 | 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 Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame] | 60 | 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 Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 75 | private final VirtualDevice virtualDevice; |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame] | 76 | private final VirtualPort virtualPort; |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 77 | |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 78 | /** |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 79 | * Creates an event of a given type and for the specified subject. |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 80 | * |
| 81 | * @param type event type |
| 82 | * @param subject event subject |
| 83 | */ |
| 84 | public VirtualNetworkEvent(Type type, NetworkId subject) { |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame] | 85 | this(type, subject, null, null); |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 86 | } |
| 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 Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame] | 97 | this(type, subject, virtualDevice, null); |
| 98 | } |
| 99 | |
| 100 | /** |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame] | 101 | * 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 Chiu | 465a260 | 2017-03-17 18:33:36 -0400 | [diff] [blame] | 109 | public VirtualNetworkEvent(Type type, NetworkId subject, VirtualDevice virtualDevice, |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame] | 110 | VirtualPort virtualPort) { |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 111 | super(type, subject); |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 112 | this.virtualDevice = virtualDevice; |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame] | 113 | this.virtualPort = virtualPort; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Creates an event of a given type and for the specified subject and time. |
| 118 | * |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame] | 119 | * @param type event type |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 120 | * @param subject event subject |
| 121 | * @param time occurrence time |
| 122 | */ |
| 123 | public VirtualNetworkEvent(Type type, NetworkId subject, long time) { |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame] | 124 | this(type, subject, null, null, time); |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | /** |
| 128 | * Creates an event of a given type and for the specified subject, virtual device and time. |
| 129 | * |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame] | 130 | * @param type event type |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 131 | * @param subject event subject |
| 132 | * @param virtualDevice virtual device |
| 133 | * @param time occurrence time |
| 134 | */ |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame] | 135 | 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 Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 165 | super(type, subject, time); |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 166 | this.virtualDevice = virtualDevice; |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame] | 167 | this.virtualPort = virtualPort; |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Returns virtual device affected by event - may be null (for events relating to |
Claudine Chiu | 465a260 | 2017-03-17 18:33:36 -0400 | [diff] [blame] | 172 | * tenants and virtual networks). |
Claudine Chiu | 945828d | 2016-11-21 12:47:07 -0500 | [diff] [blame] | 173 | * |
| 174 | * @return virtual device |
| 175 | */ |
| 176 | public VirtualDevice virtualDevice() { |
| 177 | return virtualDevice; |
Thomas Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 178 | } |
Claudine Chiu | 7f872a7 | 2016-12-16 13:51:39 -0500 | [diff] [blame] | 179 | |
| 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 Vachuska | 33979fd | 2015-07-31 11:41:14 -0700 | [diff] [blame] | 189 | } |