Commit c72cd4fa authored by Zi Lian Ji's avatar Zi Lian Ji

Enable the Load Balancer v2 for the Ceilometer(Part One)

In this change set, add the new methods:
list_pools_v2: Support to list the pools with Load Balancer v2 API.
list_members_v2: Support to list the members with Load Balancer v2
list_health_monitors_v2: Support to list the health monitors with
Load Balancer v2 API.

In the Load Balancer v2, the responses of the Pool and Member don't
contian their status. And the status is included in the response of

We need to query the status_tree to determine the status of them.


Change-Id: Ibc49282fa39fed864ec9a54d1f7fb38d7034aa9d
Implements: blueprint lbaas-v2-enablement
DocImpact: a new option is introduced
parent def7f150
......@@ -16,6 +16,7 @@
import abc
import collections
from oslo_config import cfg
from oslo_log import log
from oslo_utils import timeutils
import six
......@@ -32,8 +33,32 @@ LBStatsData = collections.namedtuple(
['active_connections', 'total_connections', 'bytes_in', 'bytes_out']
'offline': 0,
'online': 1,
'no_monitor': 3,
'error': 4,
'degraded': 5
class LBPoolPollster(base.BaseServicesPollster):
class BaseLBPollster(base.BaseServicesPollster):
"""Base Class for Load Balancer pollster"""
def __init__(self):
super(BaseLBPollster, self).__init__()
self.lb_version = cfg.CONF.service_types.neutron_lbaas_version
def get_load_balancer_status_id(self, value):
if self.lb_version == 'v1':
resource_status = self.get_status_id(value)
elif self.lb_version == 'v2':
status = value.lower()
resource_status = LOAD_BALANCER_STATUS_V2.get(status, -1)
return resource_status
class LBPoolPollster(BaseLBPollster):
"""Pollster to capture Load Balancer pool status samples."""
FIELDS = ['admin_state_up',
......@@ -57,7 +82,7 @@ class LBPoolPollster(base.BaseServicesPollster):
for pool in resources:
LOG.debug("Load Balancer Pool : %s" % pool)
status = self.get_status_id(pool['status'])
status = self.get_load_balancer_status_id(pool['status'])
if status == -1:
# unknown status, skip this sample
LOG.warning(_("Unknown status %(stat)s received on pool "
......@@ -126,7 +151,7 @@ class LBVipPollster(base.BaseServicesPollster):
class LBMemberPollster(base.BaseServicesPollster):
class LBMemberPollster(BaseLBPollster):
"""Pollster to capture Load Balancer Member status samples."""
FIELDS = ['admin_state_up',
......@@ -147,7 +172,7 @@ class LBMemberPollster(base.BaseServicesPollster):
for member in resources:
LOG.debug("Load Balancer Member : %s" % member)
status = self.get_status_id(member['status'])
status = self.get_load_balancer_status_id(member['status'])
if status == -1:
LOG.warning(_("Unknown status %(stat)s received on member "
"%(id)s, skipping sample")
This diff is collapsed.
......@@ -14,6 +14,8 @@
# under the License.
import mock
from oslo_config import cfg
from oslo_context import context
from oslotest import base
from oslotest import mockpatch
......@@ -32,6 +34,9 @@ class _BaseTestLBPollster(base.BaseTestCase):
self.context = context.get_admin_context()
self.manager = manager.AgentManager()
plugin_base._get_keystone = mock.Mock()
catalog = (plugin_base._get_keystone.session.auth.get_access.
......@@ -13,6 +13,7 @@
# under the License.
import mock
from oslotest import base
from ceilometer import neutron_client
......@@ -23,6 +24,7 @@ class TestNeutronClient(base.BaseTestCase):
def setUp(self):
super(TestNeutronClient, self).setUp() = neutron_client.Client() = 'v1'
def fake_ports_list():
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment