sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [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.openstacknetworking.routing; |
| 17 | |
sangho | 6032f34 | 2016-07-07 14:32:03 +0900 | [diff] [blame^] | 18 | import org.onosproject.net.Host; |
Kyuhwi Choi | ee9e371 | 2016-02-22 22:49:36 +0900 | [diff] [blame] | 19 | import org.onosproject.openstackinterface.OpenstackFloatingIP; |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 20 | |
| 21 | /** |
| 22 | * Handle FloatingIP Event for Managing Flow Rules In Openstack Nodes. |
| 23 | */ |
| 24 | public class OpenstackFloatingIPHandler implements Runnable { |
| 25 | |
sangho | 6032f34 | 2016-07-07 14:32:03 +0900 | [diff] [blame^] | 26 | public enum Action { |
| 27 | ASSOCIATE, |
| 28 | DISSASSOCIATE |
| 29 | } |
| 30 | |
Kyuhwi Choi | ee9e371 | 2016-02-22 22:49:36 +0900 | [diff] [blame] | 31 | private final OpenstackFloatingIP floatingIP; |
| 32 | private final OpenstackRoutingRulePopulator rulePopulator; |
sangho | 6032f34 | 2016-07-07 14:32:03 +0900 | [diff] [blame^] | 33 | private final Host host; |
| 34 | private final Action action; |
| 35 | |
Kyuhwi Choi | ee9e371 | 2016-02-22 22:49:36 +0900 | [diff] [blame] | 36 | |
| 37 | OpenstackFloatingIPHandler(OpenstackRoutingRulePopulator rulePopulator, |
sangho | 6032f34 | 2016-07-07 14:32:03 +0900 | [diff] [blame^] | 38 | OpenstackFloatingIP openstackFloatingIP, Action action, Host host) { |
Kyuhwi Choi | ee9e371 | 2016-02-22 22:49:36 +0900 | [diff] [blame] | 39 | this.floatingIP = openstackFloatingIP; |
| 40 | this.rulePopulator = rulePopulator; |
sangho | 6032f34 | 2016-07-07 14:32:03 +0900 | [diff] [blame^] | 41 | this.action = action; |
| 42 | this.host = host; |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | @Override |
| 46 | public void run() { |
sangho | 6032f34 | 2016-07-07 14:32:03 +0900 | [diff] [blame^] | 47 | if (action == Action.ASSOCIATE) { |
Kyuhwi Choi | ee9e371 | 2016-02-22 22:49:36 +0900 | [diff] [blame] | 48 | rulePopulator.populateFloatingIpRules(floatingIP); |
| 49 | } else { |
sangho | 6032f34 | 2016-07-07 14:32:03 +0900 | [diff] [blame^] | 50 | rulePopulator.removeFloatingIpRules(floatingIP, host); |
Kyuhwi Choi | ee9e371 | 2016-02-22 22:49:36 +0900 | [diff] [blame] | 51 | } |
sangho | 0c2a3da | 2016-02-16 13:39:07 +0900 | [diff] [blame] | 52 | } |
| 53 | } |