Commit 2a2b75ad authored by Jenkins's avatar Jenkins Committed by Gerrit Code Review

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

parents 6255a435 c72cd4fa
......@@ -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']
)
LOAD_BALANCER_STATUS_V2 = {
'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.addCleanup(mock.patch.stopall)
self.context = context.get_admin_context()
self.manager = manager.AgentManager()
cfg.CONF.set_override('neutron_lbaas_version',
'v1',
group='service_types')
plugin_base._get_keystone = mock.Mock()
catalog = (plugin_base._get_keystone.session.auth.get_access.
return_value.service_catalog)
......
......@@ -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()
self.nc = neutron_client.Client()
self.nc.lb_version = 'v1'
@staticmethod
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