blob: 9367ea58d0618c3310f39b24f8586437e5a2fa1e [file] [log] [blame]
sangho0c2a3da2016-02-16 13:39:07 +09001/*
2 * Copyright 2016 Open Networking Laboratory
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.openstacknetworking.routing;
17
Kyuhwi Choiee9e3712016-02-22 22:49:36 +090018import org.onosproject.openstackinterface.OpenstackFloatingIP;
19import org.onosproject.openstacknetworking.OpenstackPortInfo;
sangho0c2a3da2016-02-16 13:39:07 +090020
21/**
22 * Handle FloatingIP Event for Managing Flow Rules In Openstack Nodes.
23 */
24public class OpenstackFloatingIPHandler implements Runnable {
25
Kyuhwi Choiee9e3712016-02-22 22:49:36 +090026 private final OpenstackFloatingIP floatingIP;
27 private final OpenstackRoutingRulePopulator rulePopulator;
28 private boolean associate;
29 private final OpenstackPortInfo portInfo;
30
31 OpenstackFloatingIPHandler(OpenstackRoutingRulePopulator rulePopulator,
32 OpenstackFloatingIP openstackFloatingIP, boolean associate, OpenstackPortInfo portInfo) {
33 this.floatingIP = openstackFloatingIP;
34 this.rulePopulator = rulePopulator;
35 this.associate = associate;
36 this.portInfo = portInfo;
sangho0c2a3da2016-02-16 13:39:07 +090037 }
38
39 @Override
40 public void run() {
Kyuhwi Choiee9e3712016-02-22 22:49:36 +090041 if (associate) {
42 rulePopulator.populateFloatingIpRules(floatingIP);
43 } else {
44 rulePopulator.removeFloatingIpRules(floatingIP, portInfo);
45 }
sangho0c2a3da2016-02-16 13:39:07 +090046
47 }
48}