Move Loadbalancer Noop driver to the unit tests
Move Loadbalancer Noop driver to the corresponding folder in unit tests to clearly indicate that it is an utility driver that only suitable for unit testing. Closes-Bug: #1250767 Change-Id: Ide2ebf212193f2cf5da9cf7a7f068fd918a55ada
This commit is contained in:
parent
be3a7f5f89
commit
22fd433982
@ -1,16 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright 2013 OpenStack Foundation.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
@ -1,98 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
#
|
||||
# Copyright 2013 Radware LTD.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# @author: Avishay Balderman, Radware
|
||||
|
||||
from neutron.common import log
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.services.loadbalancer.drivers import (
|
||||
abstract_driver
|
||||
)
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class NoopLbaaSDriver(abstract_driver.LoadBalancerAbstractDriver):
|
||||
|
||||
"""A dummy lbass driver that:
|
||||
1) Logs methods input
|
||||
2) Uses the plugin API in order to update
|
||||
the config elements status in DB
|
||||
"""
|
||||
|
||||
def __init__(self, plugin):
|
||||
self.plugin = plugin
|
||||
|
||||
@log.log
|
||||
def create_vip(self, context, vip):
|
||||
pass
|
||||
|
||||
@log.log
|
||||
def update_vip(self, context, old_vip, vip):
|
||||
pass
|
||||
|
||||
@log.log
|
||||
def delete_vip(self, context, vip):
|
||||
self.plugin._delete_db_vip(context, vip["id"])
|
||||
|
||||
@log.log
|
||||
def create_pool(self, context, pool):
|
||||
pass
|
||||
|
||||
@log.log
|
||||
def update_pool(self, context, old_pool, pool):
|
||||
pass
|
||||
|
||||
@log.log
|
||||
def delete_pool(self, context, pool):
|
||||
self.plugin._delete_db_pool(context, pool["id"])
|
||||
|
||||
@log.log
|
||||
def stats(self, context, pool_id):
|
||||
return {"bytes_in": 0,
|
||||
"bytes_out": 0,
|
||||
"active_connections": 0,
|
||||
"total_connections": 0}
|
||||
|
||||
@log.log
|
||||
def create_member(self, context, member):
|
||||
pass
|
||||
|
||||
@log.log
|
||||
def update_member(self, context, old_member, member):
|
||||
pass
|
||||
|
||||
@log.log
|
||||
def delete_member(self, context, member):
|
||||
self.plugin._delete_db_member(context, member["id"])
|
||||
|
||||
@log.log
|
||||
def update_health_monitor(self, context, old_health_monitor,
|
||||
health_monitor,
|
||||
pool_association):
|
||||
pass
|
||||
|
||||
@log.log
|
||||
def create_pool_health_monitor(self, context,
|
||||
health_monitor, pool_id):
|
||||
pass
|
||||
|
||||
@log.log
|
||||
def delete_pool_health_monitor(self, context, health_monitor, pool_id):
|
||||
self.plugin._delete_db_pool_health_monitor(
|
||||
context, health_monitor["id"],
|
||||
pool_id
|
||||
)
|
@ -35,6 +35,9 @@ from neutron.plugins.common import constants
|
||||
from neutron.services.loadbalancer import (
|
||||
plugin as loadbalancer_plugin
|
||||
)
|
||||
from neutron.services.loadbalancer.drivers import (
|
||||
abstract_driver
|
||||
)
|
||||
from neutron.services import provider_configuration as pconf
|
||||
from neutron.tests.unit import test_db_plugin
|
||||
|
||||
@ -46,6 +49,8 @@ DB_LB_PLUGIN_KLASS = (
|
||||
"neutron.services.loadbalancer."
|
||||
"plugin.LoadBalancerPlugin"
|
||||
)
|
||||
NOOP_DRIVER_KLASS = ('neutron.tests.unit.db.loadbalancer.test_db_loadbalancer.'
|
||||
'NoopLbaaSDriver')
|
||||
ROOTDIR = os.path.dirname(__file__) + '../../../..'
|
||||
ETCDIR = os.path.join(ROOTDIR, 'etc')
|
||||
|
||||
@ -58,6 +63,61 @@ def etcdir(*p):
|
||||
return os.path.join(ETCDIR, *p)
|
||||
|
||||
|
||||
class NoopLbaaSDriver(abstract_driver.LoadBalancerAbstractDriver):
|
||||
"""A dummy lbass driver that that only performs object deletion."""
|
||||
|
||||
def __init__(self, plugin):
|
||||
self.plugin = plugin
|
||||
|
||||
def create_vip(self, context, vip):
|
||||
pass
|
||||
|
||||
def update_vip(self, context, old_vip, vip):
|
||||
pass
|
||||
|
||||
def delete_vip(self, context, vip):
|
||||
self.plugin._delete_db_vip(context, vip["id"])
|
||||
|
||||
def create_pool(self, context, pool):
|
||||
pass
|
||||
|
||||
def update_pool(self, context, old_pool, pool):
|
||||
pass
|
||||
|
||||
def delete_pool(self, context, pool):
|
||||
self.plugin._delete_db_pool(context, pool["id"])
|
||||
|
||||
def stats(self, context, pool_id):
|
||||
return {"bytes_in": 0,
|
||||
"bytes_out": 0,
|
||||
"active_connections": 0,
|
||||
"total_connections": 0}
|
||||
|
||||
def create_member(self, context, member):
|
||||
pass
|
||||
|
||||
def update_member(self, context, old_member, member):
|
||||
pass
|
||||
|
||||
def delete_member(self, context, member):
|
||||
self.plugin._delete_db_member(context, member["id"])
|
||||
|
||||
def update_health_monitor(self, context, old_health_monitor,
|
||||
health_monitor,
|
||||
pool_association):
|
||||
pass
|
||||
|
||||
def create_pool_health_monitor(self, context,
|
||||
health_monitor, pool_id):
|
||||
pass
|
||||
|
||||
def delete_pool_health_monitor(self, context, health_monitor, pool_id):
|
||||
self.plugin._delete_db_pool_health_monitor(
|
||||
context, health_monitor["id"],
|
||||
pool_id
|
||||
)
|
||||
|
||||
|
||||
class LoadBalancerTestMixin(object):
|
||||
resource_prefix_map = dict(
|
||||
(k, constants.COMMON_PREFIXES[constants.LOADBALANCER])
|
||||
@ -265,8 +325,7 @@ class LoadBalancerPluginDbTestCase(LoadBalancerTestMixin,
|
||||
if not lbaas_provider:
|
||||
lbaas_provider = (
|
||||
constants.LOADBALANCER +
|
||||
':lbaas:neutron.services.loadbalancer.'
|
||||
'drivers.noop.noop_driver.NoopLbaaSDriver:default')
|
||||
':lbaas:' + NOOP_DRIVER_KLASS + ':default')
|
||||
cfg.CONF.set_override('service_provider',
|
||||
[lbaas_provider],
|
||||
'service_providers')
|
||||
@ -584,8 +643,7 @@ class TestLoadBalancer(LoadBalancerPluginDbTestCase):
|
||||
def _create_pool_directly_via_plugin(self, provider_name):
|
||||
#default provider will be haproxy
|
||||
prov1 = (constants.LOADBALANCER +
|
||||
':lbaas:neutron.services.loadbalancer.'
|
||||
'drivers.noop.noop_driver.NoopLbaaSDriver')
|
||||
':lbaas:' + NOOP_DRIVER_KLASS)
|
||||
prov2 = (constants.LOADBALANCER +
|
||||
':haproxy:neutron.services.loadbalancer.'
|
||||
'drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver'
|
||||
@ -1461,9 +1519,8 @@ class TestLoadBalancer(LoadBalancerPluginDbTestCase):
|
||||
#removing driver
|
||||
cfg.CONF.set_override('service_provider',
|
||||
[constants.LOADBALANCER +
|
||||
':lbaas1:neutron.services.loadbalancer.'
|
||||
'drivers.noop.noop_driver.'
|
||||
'NoopLbaaSDriver:default'],
|
||||
':lbaas1:' + NOOP_DRIVER_KLASS +
|
||||
':default'],
|
||||
'service_providers')
|
||||
sdb.ServiceTypeManager._instance = None
|
||||
# calling _remove_orphan... in constructor
|
||||
|
Loading…
Reference in New Issue
Block a user