blob: e80d1a73b4db6ed359a10cdce2228a5d7a7af248 [file] [log] [blame]
Jian Lidaa7d6a2021-04-13 17:22:56 +09001/*
2 * Copyright 2021-present Open Networking Foundation
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 */
16package org.onosproject.kubevirtnetworking.api;
17
Daniel Park05a94582021-05-12 10:57:02 +090018import org.onlab.packet.IpAddress;
Jian Lidaa7d6a2021-04-13 17:22:56 +090019import org.onosproject.event.AbstractEvent;
20
Daniel Park05a94582021-05-12 10:57:02 +090021import java.util.Set;
22
Jian Lidaa7d6a2021-04-13 17:22:56 +090023public class KubevirtLoadBalancerEvent
24 extends AbstractEvent<KubevirtLoadBalancerEvent.Type, KubevirtLoadBalancer> {
25
Daniel Park05a94582021-05-12 10:57:02 +090026 private final KubevirtLoadBalancer old;
27 private final Set<IpAddress> members;
28
Jian Lidaa7d6a2021-04-13 17:22:56 +090029 /**
30 * LoadBalancerEvent constructor.
31 *
32 * @param type LoadBalancerEvent type
33 * @param lb LoadBalancer object
34 */
35 public KubevirtLoadBalancerEvent(Type type, KubevirtLoadBalancer lb) {
36 super(type, lb);
Daniel Park05a94582021-05-12 10:57:02 +090037 this.old = null;
38 this.members = null;
39 }
40
41 /**
42 * Creates and event of a given type for the specified kubevirt loadbalancer.
43 *
44 * @param type kubevirt loadbalancer event type
45 * @param lb kubevirt loadbalancer
46 * @param old old kubevirt loadbalancer
47 */
48 public KubevirtLoadBalancerEvent(Type type, KubevirtLoadBalancer lb, KubevirtLoadBalancer old) {
49 super(type, lb);
50 this.old = old;
51 this.members = null;
52 }
53
54 /**
55 * Creates and event of a given type for the specified kubevirt loadbalancer.
56 *
57 * @param type kubevirt loadbalancer event type
58 * @param lb kubevirt loadbalancer
59 * @param members kubevirt loadbalancer members
60 */
61 public KubevirtLoadBalancerEvent(Type type, KubevirtLoadBalancer lb, Set<IpAddress> members) {
62 super(type, lb);
63 this.old = null;
64 this.members = members;
65 }
66
67 /**
68 * Returns the old kubevirt loadbalancer of the event.
69 *
70 * @return old kubevirt loadbalancer
71 */
72 public KubevirtLoadBalancer oldLb() {
73 return old;
74 }
75
76 /**
77 * Returns members of kubevirt loadbalancer of the event.
78 *
79 * @return kubevirt loadbalancer members
80 */
81 public Set<IpAddress> members() {
82 return members;
Jian Lidaa7d6a2021-04-13 17:22:56 +090083 }
84
85 public enum Type {
86 /**
87 * Signifies that a new kubevirt load balancer is created.
88 */
89 KUBEVIRT_LOAD_BALANCER_CREATED,
90
91 /**
Daniel Park05a94582021-05-12 10:57:02 +090092 * Signifies that a kubevirt load balancer is removed.
Jian Lidaa7d6a2021-04-13 17:22:56 +090093 */
94 KUBEVIRT_LOAD_BALANCER_REMOVED,
95
96 /**
Daniel Park05a94582021-05-12 10:57:02 +090097 * Signifies that a kubevirt load balancer is updated.
Jian Lidaa7d6a2021-04-13 17:22:56 +090098 */
99 KUBEVIRT_LOAD_BALANCER_UPDATED,
Daniel Park05a94582021-05-12 10:57:02 +0900100
101 /**
102 * Signifies that a kubevirt load balancer member is added.
103 */
104 KUBEVIRT_LOAD_BALANCER_MEMBER_ADDED,
105
106 /**
107 * Signifies that a kubevirt load balancer member is added.
108 */
109 KUBEVIRT_LOAD_BALANCER_MEMBER_REMOVED,
Jian Lidaa7d6a2021-04-13 17:22:56 +0900110 }
111}