|
| 1 | +# Copyright 2016 IBM Corp. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | +# not use this file except in compliance with the License. You may obtain |
| 5 | +# a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | +# License for the specific language governing permissions and limitations |
| 13 | +# under the License. |
| 14 | + |
| 15 | +from oslo_log import log as logging |
| 16 | + |
| 17 | +from octavia.distributor.drivers import driver_base as driver_base |
| 18 | + |
| 19 | +LOG = logging.getLogger(__name__) |
| 20 | + |
| 21 | + |
| 22 | +class NoopManager(object): |
| 23 | + def __init__(self): |
| 24 | + super(NoopManager, self).__init__() |
| 25 | + self.distributor_config = {} |
| 26 | + |
| 27 | + def get_info(self, distributor): |
| 28 | + LOG.debug("distributor %s no-op, info distributor %s", |
| 29 | + self.__class__.__name__, distributor.id) |
| 30 | + self.distributor_config[distributor.id] = (distributor.id, 'get_info') |
| 31 | + |
| 32 | + def get_diagnostics(self, distributor): |
| 33 | + LOG.debug("distributor %s no-op, get diagnostics distributor %s", |
| 34 | + self.__class__.__name__, distributor.id) |
| 35 | + self.distributor_config[distributor.id] = (distributor.id, |
| 36 | + 'get_diagnostics') |
| 37 | + |
| 38 | + def register_amphora(self, distributor, load_balancer, amphora, |
| 39 | + cluster_alg_type, cluster_min_size): |
| 40 | + LOG.debug("distributor %s no-op, register amphora %s with LB %s", |
| 41 | + self.__class__.__name__, amphora.id, load_balancer.id) |
| 42 | + self.distributor_config[(amphora.id, |
| 43 | + distributor.id, |
| 44 | + load_balancer.id, |
| 45 | + cluster_alg_type, |
| 46 | + cluster_min_size)] = (amphora.id, |
| 47 | + distributor.id, |
| 48 | + load_balancer.id, |
| 49 | + cluster_alg_type, |
| 50 | + cluster_min_size, |
| 51 | + 'register_amphora') |
| 52 | + |
| 53 | + def unregister_amphora(self, distributor, load_balancer, amphora, |
| 54 | + cluster_alg_type, cluster_min_size): |
| 55 | + LOG.debug("distributor %s no-op, unregister amphora %s, LB:%s", |
| 56 | + self.__class__.__name__, amphora.id, load_balancer.id) |
| 57 | + self.distributor_config[(amphora.id, |
| 58 | + distributor.id, |
| 59 | + load_balancer.id, |
| 60 | + cluster_alg_type, |
| 61 | + cluster_min_size)] = (amphora.id, |
| 62 | + distributor.id, |
| 63 | + load_balancer.id, |
| 64 | + cluster_alg_type, |
| 65 | + cluster_min_size, |
| 66 | + 'unregister_amphora') |
| 67 | + |
| 68 | + def post_vip_plug(self, distributor, load_balancer, distributor_mac, |
| 69 | + cluster_alg_type, cluster_min_size): |
| 70 | + LOG.debug("distributor %s no-op, post vip plug load balancer %s", |
| 71 | + self.__class__.__name__, load_balancer.id) |
| 72 | + self.distributor_config[(distributor.id, |
| 73 | + load_balancer.id, |
| 74 | + distributor_mac, |
| 75 | + cluster_alg_type, |
| 76 | + cluster_min_size)] = (distributor.id, |
| 77 | + load_balancer.id, |
| 78 | + distributor_mac, |
| 79 | + cluster_alg_type, |
| 80 | + cluster_min_size, |
| 81 | + 'post_vip_plug') |
| 82 | + |
| 83 | + def pre_vip_unplug(self, distributor, load_balancer): |
| 84 | + LOG.debug("distributor %s no-op, pre vip unplug load balancer %s", |
| 85 | + self.__class__.__name__, load_balancer.id) |
| 86 | + self.distributor_config[(load_balancer.id, |
| 87 | + distributor.id)] = (load_balancer.id, |
| 88 | + distributor.id, |
| 89 | + 'pre_vip_unplug') |
| 90 | + |
| 91 | + |
| 92 | +class NoopDistributorDriver(driver_base.DistributorDriver): |
| 93 | + def __init__(self): |
| 94 | + super(NoopDistributorDriver, self).__init__() |
| 95 | + self.driver = NoopManager() |
| 96 | + |
| 97 | + def get_info(self, distributor): |
| 98 | + self.driver.get_info(distributor) |
| 99 | + |
| 100 | + def get_diagnostics(self, distributor): |
| 101 | + self.driver.get_diagnostics(distributor) |
| 102 | + |
| 103 | + def register_amphora(self, distributor, load_balancer, amphora, |
| 104 | + cluster_alg_type, cluster_min_size): |
| 105 | + self.driver.register_amphora(distributor, |
| 106 | + load_balancer, |
| 107 | + amphora, |
| 108 | + cluster_alg_type, |
| 109 | + cluster_min_size) |
| 110 | + |
| 111 | + def unregister_amphora(self, distributor, load_balancer, amphora, |
| 112 | + cluster_alg_type, cluster_min_size): |
| 113 | + self.driver.unregister_amphora(distributor, |
| 114 | + load_balancer, |
| 115 | + amphora, |
| 116 | + cluster_alg_type, |
| 117 | + cluster_min_size) |
| 118 | + |
| 119 | + def post_vip_plug(self, distributor, load_balancer, distributor_mac, |
| 120 | + cluster_alg_type, cluster_min_size): |
| 121 | + self.driver.post_vip_plug(distributor, |
| 122 | + load_balancer, |
| 123 | + distributor_mac, |
| 124 | + cluster_alg_type, |
| 125 | + cluster_min_size) |
| 126 | + |
| 127 | + def pre_vip_unplug(self, distributor, load_balancer): |
| 128 | + self.driver.pre_vip_unplug(distributor, load_balancer) |
0 commit comments