Merge "LBaaS: include inactive members when retrieving logical config"

This commit is contained in:
Jenkins 2013-09-24 00:24:57 +00:00 committed by Gerrit Code Review
commit a384a3ea3c
4 changed files with 35 additions and 3 deletions

View File

@ -50,6 +50,7 @@ STATS_MAP = {
}
ACTIVE = qconstants.ACTIVE
INACTIVE = qconstants.INACTIVE
def save_config(conf_path, logical_config, socket_path=None):
@ -137,7 +138,7 @@ def _build_backend(config):
# add the members
for member in config['members']:
if member['status'] == ACTIVE and member['admin_state_up']:
if member['status'] in (ACTIVE, INACTIVE) and member['admin_state_up']:
server = (('server %(id)s %(address)s:%(protocol_port)s '
'weight %(weight)s') % member) + server_addon
if _has_http_cookie_persistence(config):

View File

@ -132,7 +132,8 @@ class LoadBalancerCallbacks(object):
)
retval['members'] = [
self.plugin._make_member_dict(m)
for m in pool.members if m.status == constants.ACTIVE
for m in pool.members if m.status in (constants.ACTIVE,
constants.INACTIVE)
]
retval['healthmonitors'] = [
self.plugin._make_health_monitor_dict(hm.healthmonitor)

View File

@ -110,6 +110,12 @@ class TestHaproxyCfg(base.BaseTestCase):
'id': 'member1_id',
'address': '10.0.0.3',
'protocol_port': 80,
'weight': 1},
{'status': 'INACTIVE',
'admin_state_up': True,
'id': 'member2_id',
'address': '10.0.0.4',
'protocol_port': 80,
'weight': 1}],
'healthmonitors': [{'admin_state_up': True,
'delay': 3,
@ -124,7 +130,9 @@ class TestHaproxyCfg(base.BaseTestCase):
'\ttimeout check 2s',
'\tcookie SRV insert indirect nocache',
'\tserver member1_id 10.0.0.3:80 weight 1 '
'check inter 3s fall 4 cookie 0']
'check inter 3s fall 4 cookie 0',
'\tserver member2_id 10.0.0.4:80 weight 1 '
'check inter 3s fall 4 cookie 1']
opts = cfg._build_backend(test_config)
self.assertEqual(expected_opts, list(opts))

View File

@ -227,6 +227,28 @@ class TestLoadBalancerCallbacks(TestLoadBalancerPluginBase):
self.assertEqual(logical_config, expected)
def test_get_logical_device_inactive_member(self):
with self.pool() as pool:
with self.vip(pool=pool) as vip:
with self.member(pool_id=vip['vip']['pool_id']) as member:
ctx = context.get_admin_context()
self.plugin_instance.update_status(ctx, ldb.Pool,
pool['pool']['id'],
'ACTIVE')
self.plugin_instance.update_status(ctx, ldb.Vip,
vip['vip']['id'],
'ACTIVE')
self.plugin_instance.update_status(ctx, ldb.Member,
member['member']['id'],
'INACTIVE')
logical_config = self.callbacks.get_logical_device(
ctx, pool['pool']['id'], activate=False)
member['member']['status'] = constants.INACTIVE
self.assertEqual([member['member']],
logical_config['members'])
def _update_port_test_helper(self, expected, func, **kwargs):
core = self.plugin_instance._core_plugin