Remove support for neutron-lbaas

... because it is of no use since neutron-lbaas was retired and was
replaced by Octavia. This feature was officially deprecated during
Yoga cycle[1] so we are ready to remove it.

[1] 8917c73964

Change-Id: Ic145c23cc0b0372ef78f4a45ffb084bec24936c3
This commit is contained in:
Takashi Kajinami 2022-04-12 10:53:11 +09:00
parent 0ca700e986
commit 318c54648c
14 changed files with 5 additions and 2564 deletions

View File

@ -240,12 +240,6 @@ resources_update_operations = [
"value": {"type": "string", "min_length": 0, "max_length": 255, "value": {"type": "string", "min_length": 0, "max_length": 255,
"required": False} "required": False}
}]}, }]},
{"desc": "add loadbalancer resource type",
"type": "create_resource_type",
"resource_type": "loadbalancer",
"data": [{
"attributes": {}
}]},
] ]
# NOTE(sileht): We use LooseVersion because pbr can generate invalid # NOTE(sileht): We use LooseVersion because pbr can generate invalid

View File

@ -25,59 +25,6 @@ class _BaseServicesDiscovery(plugin_base.DiscoveryBase):
self.neutron_cli = neutron_client.Client(conf) self.neutron_cli = neutron_client.Client(conf)
class LBPoolsDiscovery(_BaseServicesDiscovery):
def discover(self, manager, param=None):
"""Discover resources to monitor."""
pools = self.neutron_cli.pool_get_all()
return [i for i in pools
if i.get('status') != 'error']
class LBVipsDiscovery(_BaseServicesDiscovery):
def discover(self, manager, param=None):
"""Discover resources to monitor."""
vips = self.neutron_cli.vip_get_all()
return [i for i in vips
if i.get('status', None) != 'error']
class LBMembersDiscovery(_BaseServicesDiscovery):
def discover(self, manager, param=None):
"""Discover resources to monitor."""
members = self.neutron_cli.member_get_all()
return [i for i in members
if i.get('status', None) != 'error']
class LBListenersDiscovery(_BaseServicesDiscovery):
def discover(self, manager, param=None):
"""Discover load balancer listener resources to monitor."""
listeners = self.neutron_cli.list_listener()
return [i for i in listeners
if i.get('operating_status', None) != 'error']
class LBLoadBalancersDiscovery(_BaseServicesDiscovery):
def discover(self, manager, param=None):
"""Discover load balancer resources to monitor."""
loadbalancers = self.neutron_cli.list_loadbalancer()
return [i for i in loadbalancers
if i.get('operating_status', None) != 'error']
class LBHealthMonitorsDiscovery(_BaseServicesDiscovery):
def discover(self, manager, param=None):
"""Discover resources to monitor."""
probes = self.neutron_cli.health_monitor_get_all()
return probes
class VPNServicesDiscovery(_BaseServicesDiscovery): class VPNServicesDiscovery(_BaseServicesDiscovery):
def discover(self, manager, param=None): def discover(self, manager, param=None):
"""Discover resources to monitor.""" """Discover resources to monitor."""

View File

@ -1,466 +0,0 @@
#
# Copyright 2014 Cisco Systems,Inc.
#
# 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.
import abc
import collections
import warnings
from oslo_log import log
from ceilometer.i18n import _
from ceilometer.network.services import base
from ceilometer import neutron_client
from ceilometer import sample
LOG = log.getLogger(__name__)
LBStatsData = collections.namedtuple(
'LBStats',
['active_connections', 'total_connections', 'bytes_in', 'bytes_out']
)
LOAD_BALANCER_STATUS_V2 = {
'offline': 0,
'online': 1,
'no_monitor': 3,
'error': 4,
'degraded': 5,
'disabled': 6
}
class BaseLBPollster(base.BaseServicesPollster):
"""Base Class for Load Balancer pollster"""
def __init__(self, conf):
super(BaseLBPollster, self).__init__(conf)
self.lb_version = self.conf.service_types.neutron_lbaas_version
warnings.warn('Support for Neutron LBaaS has been deprecated '
'and will be removed in a future release.',
category=DeprecationWarning, stacklevel=3)
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',
'description',
'lb_method',
'name',
'protocol',
'provider',
'status',
'status_description',
'subnet_id',
'vip_id'
]
@property
def default_discovery(self):
return 'lb_pools'
def get_samples(self, manager, cache, resources):
resources = resources or []
for pool in resources:
LOG.debug("Load Balancer Pool : %s" % pool)
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 "
"%(id)s, skipping sample")
% {'stat': pool['status'], 'id': pool['id']})
continue
yield sample.Sample(
name='network.services.lb.pool',
type=sample.TYPE_GAUGE,
unit='pool',
volume=status,
user_id=None,
project_id=pool['tenant_id'],
resource_id=pool['id'],
resource_metadata=self.extract_metadata(pool)
)
class LBVipPollster(base.BaseServicesPollster):
"""Pollster to capture Load Balancer Vip status samples."""
FIELDS = ['admin_state_up',
'address',
'connection_limit',
'description',
'name',
'pool_id',
'port_id',
'protocol',
'protocol_port',
'status',
'status_description',
'subnet_id',
'session_persistence',
]
@property
def default_discovery(self):
return 'lb_vips'
def get_samples(self, manager, cache, resources):
resources = resources or []
for vip in resources:
LOG.debug("Load Balancer Vip : %s" % vip)
status = self.get_status_id(vip['status'])
if status == -1:
# unknown status, skip this sample
LOG.warning(_("Unknown status %(stat)s received on vip "
"%(id)s, skipping sample")
% {'stat': vip['status'], 'id': vip['id']})
continue
yield sample.Sample(
name='network.services.lb.vip',
type=sample.TYPE_GAUGE,
unit='vip',
volume=status,
user_id=None,
project_id=vip['tenant_id'],
resource_id=vip['id'],
resource_metadata=self.extract_metadata(vip)
)
class LBMemberPollster(BaseLBPollster):
"""Pollster to capture Load Balancer Member status samples."""
FIELDS = ['admin_state_up',
'address',
'pool_id',
'protocol_port',
'status',
'status_description',
'weight',
]
@property
def default_discovery(self):
return 'lb_members'
def get_samples(self, manager, cache, resources):
resources = resources or []
for member in resources:
LOG.debug("Load Balancer Member : %s" % member)
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")
% {'stat': member['status'], 'id': member['id']})
continue
yield sample.Sample(
name='network.services.lb.member',
type=sample.TYPE_GAUGE,
unit='member',
volume=status,
user_id=None,
project_id=member['tenant_id'],
resource_id=member['id'],
resource_metadata=self.extract_metadata(member)
)
class LBHealthMonitorPollster(base.BaseServicesPollster):
"""Pollster to capture Load Balancer Health probes status samples."""
FIELDS = ['admin_state_up',
'delay',
'max_retries',
'pools',
'timeout',
'type'
]
@property
def default_discovery(self):
return 'lb_health_probes'
def get_samples(self, manager, cache, resources):
for probe in resources:
LOG.debug("Load Balancer Health probe : %s" % probe)
yield sample.Sample(
name='network.services.lb.health_monitor',
type=sample.TYPE_GAUGE,
unit='health_monitor',
volume=1,
user_id=None,
project_id=probe['tenant_id'],
resource_id=probe['id'],
resource_metadata=self.extract_metadata(probe)
)
class _LBStatsPollster(base.BaseServicesPollster, metaclass=abc.ABCMeta):
"""Base Statistics pollster.
It is capturing the statistics info and yielding samples for connections
and bandwidth.
"""
def __init__(self, conf):
super(_LBStatsPollster, self).__init__(conf)
self.client = neutron_client.Client(self.conf)
self.lb_version = self.conf.service_types.neutron_lbaas_version
@staticmethod
def make_sample_from_pool(pool, name, type, unit, volume,
resource_metadata=None):
if not resource_metadata:
resource_metadata = {}
return sample.Sample(
name=name,
type=type,
unit=unit,
volume=volume,
user_id=None,
project_id=pool['tenant_id'],
resource_id=pool['id'],
resource_metadata=resource_metadata,
)
def _populate_stats_cache(self, pool_id, cache):
i_cache = cache.setdefault("lbstats", {})
if pool_id not in i_cache:
stats = self.client.pool_stats(pool_id)['stats']
i_cache[pool_id] = LBStatsData(
active_connections=stats['active_connections'],
total_connections=stats['total_connections'],
bytes_in=stats['bytes_in'],
bytes_out=stats['bytes_out'],
)
return i_cache[pool_id]
def _populate_stats_cache_v2(self, loadbalancer_id, cache):
i_cache = cache.setdefault("lbstats", {})
if loadbalancer_id not in i_cache:
stats = self.client.get_loadbalancer_stats(loadbalancer_id)
i_cache[loadbalancer_id] = LBStatsData(
active_connections=stats['active_connections'],
total_connections=stats['total_connections'],
bytes_in=stats['bytes_in'],
bytes_out=stats['bytes_out'],
)
return i_cache[loadbalancer_id]
@property
def default_discovery(self):
discovery_resource = 'lb_pools'
if self.lb_version == 'v2':
discovery_resource = 'lb_loadbalancers'
return discovery_resource
@abc.abstractmethod
def _get_sample(pool, c_data):
"""Return one Sample."""
def get_samples(self, manager, cache, resources):
if self.lb_version == 'v1':
for pool in resources:
try:
c_data = self._populate_stats_cache(pool['id'], cache)
yield self._get_sample(pool, c_data)
except Exception:
LOG.exception('Ignoring pool %(pool_id)s',
{'pool_id': pool['id']})
elif self.lb_version == 'v2':
for loadbalancer in resources:
try:
c_data = self._populate_stats_cache_v2(loadbalancer['id'],
cache)
yield self._get_sample(loadbalancer, c_data)
except Exception:
LOG.exception(
'Ignoring loadbalancer %(loadbalancer_id)s',
{'loadbalancer_id': loadbalancer['id']})
class LBActiveConnectionsPollster(_LBStatsPollster):
"""Pollster to capture Active Load Balancer connections."""
@staticmethod
def _get_sample(pool, data):
return make_sample_from_pool(
pool,
name='network.services.lb.active.connections',
type=sample.TYPE_GAUGE,
unit='connection',
volume=data.active_connections,
)
class LBTotalConnectionsPollster(_LBStatsPollster):
"""Pollster to capture Total Load Balancer connections."""
@staticmethod
def _get_sample(pool, data):
return make_sample_from_pool(
pool,
name='network.services.lb.total.connections',
type=sample.TYPE_CUMULATIVE,
unit='connection',
volume=data.total_connections,
)
class LBBytesInPollster(_LBStatsPollster):
"""Pollster to capture incoming bytes."""
@staticmethod
def _get_sample(pool, data):
return make_sample_from_pool(
pool,
name='network.services.lb.incoming.bytes',
type=sample.TYPE_GAUGE,
unit='B',
volume=data.bytes_in,
)
class LBBytesOutPollster(_LBStatsPollster):
"""Pollster to capture outgoing bytes."""
@staticmethod
def _get_sample(pool, data):
return make_sample_from_pool(
pool,
name='network.services.lb.outgoing.bytes',
type=sample.TYPE_GAUGE,
unit='B',
volume=data.bytes_out,
)
def make_sample_from_pool(pool, name, type, unit, volume,
resource_metadata=None):
resource_metadata = resource_metadata or {}
return sample.Sample(
name=name,
type=type,
unit=unit,
volume=volume,
user_id=None,
project_id=pool['tenant_id'],
resource_id=pool['id'],
resource_metadata=resource_metadata,
)
class LBListenerPollster(BaseLBPollster):
"""Pollster to capture Load Balancer Listener status samples."""
FIELDS = ['admin_state_up',
'connection_limit',
'description',
'name',
'default_pool_id',
'protocol',
'protocol_port',
'operating_status',
'loadbalancers'
]
@property
def default_discovery(self):
return 'lb_listeners'
def get_samples(self, manager, cache, resources):
resources = resources or []
for listener in resources:
LOG.debug("Load Balancer Listener : %s" % listener)
status = self.get_load_balancer_status_id(
listener['operating_status'])
if status == -1:
# unknown status, skip this sample
LOG.warning(_("Unknown status %(stat)s received on listener "
"%(id)s, skipping sample")
% {'stat': listener['operating_status'],
'id': listener['id']})
continue
yield sample.Sample(
name='network.services.lb.listener',
type=sample.TYPE_GAUGE,
unit='listener',
volume=status,
user_id=None,
project_id=listener['tenant_id'],
resource_id=listener['id'],
resource_metadata=self.extract_metadata(listener)
)
class LBLoadBalancerPollster(BaseLBPollster):
"""Pollster to capture Load Balancer status samples."""
FIELDS = ['admin_state_up',
'description',
'vip_address',
'listeners',
'name',
'vip_subnet_id',
'operating_status',
]
@property
def default_discovery(self):
return 'lb_loadbalancers'
def get_samples(self, manager, cache, resources):
resources = resources or []
for loadbalancer in resources:
LOG.debug("Load Balancer: %s" % loadbalancer)
status = self.get_load_balancer_status_id(
loadbalancer['operating_status'])
if status == -1:
# unknown status, skip this sample
LOG.warning(_("Unknown status %(stat)s received "
"on Load Balancer "
"%(id)s, skipping sample")
% {'stat': loadbalancer['operating_status'],
'id': loadbalancer['id']})
continue
yield sample.Sample(
name='network.services.lb.loadbalancer',
type=sample.TYPE_GAUGE,
unit='loadbalancer',
volume=status,
user_id=None,
project_id=loadbalancer['tenant_id'],
resource_id=loadbalancer['id'],
resource_metadata=self.extract_metadata(loadbalancer)
)

View File

@ -25,12 +25,6 @@ SERVICE_OPTS = [
cfg.StrOpt('neutron', cfg.StrOpt('neutron',
default='network', default='network',
help='Neutron service type.'), help='Neutron service type.'),
cfg.StrOpt('neutron_lbaas_version',
default='v2',
deprecated_for_removal=True,
deprecated_reason='Neutron LBaaS has been retired',
choices=('v1', 'v2'),
help='Neutron load balancer version.')
] ]
LOG = log.getLogger(__name__) LOG = log.getLogger(__name__)
@ -67,52 +61,12 @@ class Client(object):
'service_type': conf.service_types.neutron, 'service_type': conf.service_types.neutron,
} }
self.client = clientv20.Client(**params) self.client = clientv20.Client(**params)
self.lb_version = conf.service_types.neutron_lbaas_version
@logged @logged
def port_get_all(self): def port_get_all(self):
resp = self.client.list_ports() resp = self.client.list_ports()
return resp.get('ports') return resp.get('ports')
@logged
def vip_get_all(self):
resp = self.client.list_vips()
return resp.get('vips')
@logged
def pool_get_all(self):
resources = []
if self.lb_version == 'v1':
resp = self.client.list_pools()
resources = resp.get('pools')
elif self.lb_version == 'v2':
resources = self.list_pools_v2()
return resources
@logged
def member_get_all(self):
resources = []
if self.lb_version == 'v1':
resp = self.client.list_members()
resources = resp.get('members')
elif self.lb_version == 'v2':
resources = self.list_members_v2()
return resources
@logged
def health_monitor_get_all(self):
resources = []
if self.lb_version == 'v1':
resp = self.client.list_health_monitors()
resources = resp.get('health_monitors')
elif self.lb_version == 'v2':
resources = self.list_health_monitors_v2()
return resources
@logged
def pool_stats(self, pool):
return self.client.retrieve_pool_stats(pool)
@logged @logged
def vpn_get_all(self): def vpn_get_all(self):
resp = self.client.list_vpnservices() resp = self.client.list_vpnservices()
@ -137,291 +91,3 @@ class Client(object):
def fip_get_all(self): def fip_get_all(self):
fips = self.client.list_floatingips()['floatingips'] fips = self.client.list_floatingips()['floatingips']
return fips return fips
@logged
def list_pools_v2(self):
"""This method is used to get the pools list.
This method uses Load Balancer v2_0 API to achieve
the detailed list of the pools.
:returns: The list of the pool resources
"""
pool_status = dict()
resp = self.client.list_lbaas_pools()
temp_pools = resp.get('pools')
resources = []
pool_listener_dict = self._get_pool_and_listener_ids(temp_pools)
for k, v in pool_listener_dict.items():
loadbalancer_id = self._get_loadbalancer_id_with_listener_id(v)
status = self._get_pool_status(loadbalancer_id, v)
for k, v in status.items():
pool_status[k] = v
for pool in temp_pools:
pool_id = pool.get('id')
pool['status'] = pool_status[pool_id]
pool['lb_method'] = pool.get('lb_algorithm')
pool['status_description'] = pool['status']
# Based on the LBaaSv2 design, the properties 'vip_id'
# and 'subnet_id' should belong to the loadbalancer resource and
# not to the pool resource. However, because we don't want to
# change the metadata of the pool resource this release,
# we set them to empty values manually.
pool['provider'] = ''
pool['vip_id'] = ''
pool['subnet_id'] = ''
resources.append(pool)
return resources
@logged
def list_members_v2(self):
"""Method is used to list the members info.
This method is used to get the detailed list of the members
with Load Balancer v2_0 API
:returns: The list of the member resources
"""
resources = []
pools = self.client.list_lbaas_pools().get('pools')
for pool in pools:
pool_id = pool.get('id')
listeners = pool.get('listeners')
if not listeners:
continue
# NOTE(sileht): Can we have more than 1 listener
listener_id = listeners[0].get('id')
lb_id = self._get_loadbalancer_id_with_listener_id(listener_id)
status = self._get_member_status(lb_id, [listener_id, pool_id])
resp = self.client.list_lbaas_members(pool_id)
temp_members = resp.get('members')
for member in temp_members:
member['status'] = status[member.get('id')]
member['pool_id'] = pool_id
member['status_description'] = member['status']
resources.append(member)
return resources
@logged
def list_health_monitors_v2(self):
"""Method is used to list the health monitors
This method is used to get the detailed list of the health
monitors with Load Balancer v2_0
:returns: The list of the health monitor resources
"""
resp = self.client.list_lbaas_healthmonitors()
resources = resp.get('healthmonitors')
return resources
def _get_pool_and_listener_ids(self, pools):
"""Method is used to get the mapping between pool and listener
This method is used to get the pool ids and listener ids
from the pool list.
:param pools: The list of the polls
:returns: The relationship between pool and listener.
It's a dictionary type. The key of this dict is
the id of pool and the value of it is the id of the first
listener which the pool belongs to
"""
pool_listener_dict = dict()
for pool in pools:
key = pool.get("id")
value = pool.get('listeners')[0].get('id')
pool_listener_dict[key] = value
return pool_listener_dict
def _retrieve_loadbalancer_status_tree(self, loadbalancer_id):
"""Method is used to get the status of a LB.
This method is used to get the status tree of a specific
Load Balancer.
:param loadbalancer_id: The ID of the specific Load
Balancer.
:returns: The status of the specific Load Balancer.
It consists of the load balancer and all of its
children's provisioning and operating statuses
"""
lb_status_tree = self.client.retrieve_loadbalancer_status(
loadbalancer_id)
return lb_status_tree
def _get_loadbalancer_id_with_listener_id(self, listener_id):
"""This method is used to get the loadbalancer id.
:param listener_id: The ID of the listener
:returns: The ID of the Loadbalancer
"""
listener = self.client.show_listener(listener_id)
listener_lbs = listener.get('listener').get('loadbalancers')
loadbalancer_id = listener_lbs[0].get('id')
return loadbalancer_id
def _get_member_status(self, loadbalancer_id, parent_id):
"""Method used to get the status of member resource.
This method is used to get the status of member
resource belonged to the specific Load Balancer.
:param loadbalancer_id: The ID of the Load Balancer.
:param parent_id: The parent ID list of the member resource.
For the member resource, the parent_id should be [listener_id,
pool_id].
:returns: The status dictionary of the member
resource. The key is the ID of the member. The value is
the operating status of the member resource.
"""
# FIXME(liamji) the following meters are experimental and
# may generate a large load against neutron api. The future
# enhancements can be tracked against:
# https://review.opendev.org/#/c/218560.
# After it has been merged and the neutron client supports
# with the corresponding apis, will change to use the new
# method to get the status of the members.
resp = self._retrieve_loadbalancer_status_tree(loadbalancer_id)
status_tree = resp.get('statuses').get('loadbalancer')
status_dict = dict()
listeners_status = status_tree.get('listeners')
for listener_status in listeners_status:
listener_id = listener_status.get('id')
if listener_id == parent_id[0]:
pools_status = listener_status.get('pools')
for pool_status in pools_status:
if pool_status.get('id') == parent_id[1]:
members_status = pool_status.get('members')
for member_status in members_status:
key = member_status.get('id')
# If the item has no the property 'id', skip
# it.
if key is None:
continue
# The situation that the property
# 'operating_status' is none is handled in
# the method get_sample() in lbaas.py.
value = member_status.get('operating_status')
status_dict[key] = value
break
break
return status_dict
def _get_listener_status(self, loadbalancer_id):
"""Method used to get the status of the listener resource.
This method is used to get the status of the listener
resources belonged to the specific Load Balancer.
:param loadbalancer_id: The ID of the Load Balancer.
:returns: The status dictionary of the listener
resource. The key is the ID of the listener resource. The
value is the operating status of the listener resource.
"""
# FIXME(liamji) the following meters are experimental and
# may generate a large load against neutron api. The future
# enhancements can be tracked against:
# https://review.opendev.org/#/c/218560.
# After it has been merged and the neutron client supports
# with the corresponding apis, will change to use the new
# method to get the status of the listeners.
resp = self._retrieve_loadbalancer_status_tree(loadbalancer_id)
status_tree = resp.get('statuses').get('loadbalancer')
status_dict = dict()
listeners_status = status_tree.get('listeners')
for listener_status in listeners_status:
key = listener_status.get('id')
# If the item has no the property 'id', skip
# it.
if key is None:
continue
# The situation that the property
# 'operating_status' is none is handled in
# the method get_sample() in lbaas.py.
value = listener_status.get('operating_status')
status_dict[key] = value
return status_dict
def _get_pool_status(self, loadbalancer_id, parent_id):
"""Method used to get the status of pool resource.
This method is used to get the status of the pool
resources belonged to the specific Load Balancer.
:param loadbalancer_id: The ID of the Load Balancer.
:param parent_id: The parent ID of the pool resource.
:returns: The status dictionary of the pool resource.
The key is the ID of the pool resource. The value is
the operating status of the pool resource.
"""
# FIXME(liamji) the following meters are experimental and
# may generate a large load against neutron api. The future
# enhancements can be tracked against:
# https://review.opendev.org/#/c/218560.
# After it has been merged and the neutron client supports
# with the corresponding apis, will change to use the new
# method to get the status of the pools.
resp = self._retrieve_loadbalancer_status_tree(loadbalancer_id)
status_tree = resp.get('statuses').get('loadbalancer')
status_dict = dict()
listeners_status = status_tree.get('listeners')
for listener_status in listeners_status:
listener_id = listener_status.get('id')
if listener_id == parent_id:
pools_status = listener_status.get('pools')
for pool_status in pools_status:
key = pool_status.get('id')
# If the item has no the property 'id', skip
# it.
if key is None:
continue
# The situation that the property
# 'operating_status' is none is handled in
# the method get_sample() in lbaas.py.
value = pool_status.get('operating_status')
status_dict[key] = value
break
return status_dict
@logged
def list_listener(self):
"""This method is used to get the list of the listeners."""
resources = []
if self.lb_version == 'v2':
# list_listeners works only with lbaas v2 extension
resp = self.client.list_listeners()
resources = resp.get('listeners')
for listener in resources:
loadbalancer_id = listener.get('loadbalancers')[0].get('id')
status = self._get_listener_status(loadbalancer_id)
listener['operating_status'] = status[listener.get('id')]
return resources
@logged
def list_loadbalancer(self):
"""This method is used to get the list of the loadbalancers."""
resources = []
if self.lb_version == 'v2':
# list_loadbalancers works only with lbaas v2 extension
resp = self.client.list_loadbalancers()
resources = resp.get('loadbalancers')
return resources
@logged
def get_loadbalancer_stats(self, loadbalancer_id):
"""This method is used to get the statistics of the loadbalancer.
:param loadbalancer_id: the ID of the specified loadbalancer
"""
resp = self.client.retrieve_loadbalancer_stats(loadbalancer_id)
resource = resp.get('stats')
return resource

View File

@ -322,7 +322,7 @@
fields: payload.target.metadata.object fields: payload.target.metadata.object
observer_id: observer_id:
fields: payload.observer.id fields: payload.observer.id
- event_type: ['network.*', 'subnet.*', 'port.*', 'router.*', 'floatingip.*', 'pool.*', 'vip.*', 'member.*', 'health_monitor.*', 'healthmonitor.*', 'listener.*', 'loadbalancer.*', 'firewall.*', 'firewall_policy.*', 'firewall_rule.*', 'vpnservice.*', 'ipsecpolicy.*', 'ikepolicy.*', 'ipsec_site_connection.*'] - event_type: ['network.*', 'subnet.*', 'port.*', 'router.*', 'floatingip.*', 'firewall.*', 'firewall_policy.*', 'firewall_rule.*', 'vpnservice.*', 'ipsecpolicy.*', 'ikepolicy.*', 'ipsec_site_connection.*']
traits: &network_traits traits: &network_traits
user_id: user_id:
fields: ctxt.user_id fields: ctxt.user_id
@ -361,51 +361,6 @@
<<: *network_traits <<: *network_traits
resource_id: resource_id:
fields: ['payload.floatingip.id', 'payload.id'] fields: ['payload.floatingip.id', 'payload.id']
- event_type: pool.*
traits:
<<: *network_traits
name:
fields: payload.pool.name
resource_id:
fields: ['payload.pool.id', 'payload.id']
- event_type: vip.*
traits:
<<: *network_traits
resource_id:
fields: ['payload.vip.id', 'payload.id']
- event_type: member.*
traits:
<<: *network_traits
resource_id:
fields: ['payload.member.id', 'payload.id']
- event_type: health_monitor.*
traits:
<<: *network_traits
name:
fields: payload.health_monitor.name
resource_id:
fields: ['payload.health_monitor.id', 'payload.id']
- event_type: healthmonitor.*
traits:
<<: *network_traits
name:
fields: payload.healthmonitor.name
resource_id:
fields: ['payload.healthmonitor.id', 'payload.id']
- event_type: listener.*
traits:
<<: *network_traits
name:
fields: payload.listener.name
resource_id:
fields: ['payload.listener.id', 'payload.id']
- event_type: loadbalancer.*
traits:
<<: *network_traits
name:
fields: payload.loadbalancer.name
resource_id:
fields: ['payload.loadbalancer.id', 'payload.id']
- event_type: firewall.* - event_type: firewall.*
traits: traits:
<<: *network_traits <<: *network_traits

View File

@ -403,17 +403,3 @@ resources:
attributes: attributes:
controller: resource_metadata.controller controller: resource_metadata.controller
switch: resource_metadata.switch switch: resource_metadata.switch
- resource_type: loadbalancer
metrics:
network.services.lb.outgoing.bytes:
network.services.lb.incoming.bytes:
network.services.lb.pool:
network.services.lb.listener:
network.services.lb.member:
network.services.lb.health_monitor:
network.services.lb.loadbalancer:
network.services.lb.total.connections:
network.services.lb.active.connections:

View File

@ -1,506 +0,0 @@
#
# Copyright 2014 Cisco Systems,Inc.
#
# 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.
from unittest import mock
import fixtures
from oslotest import base
from ceilometer.network.services import discovery
from ceilometer.network.services import lbaas
from ceilometer.polling import manager
from ceilometer.polling import plugin_base
from ceilometer import service
class _BaseTestLBPollster(base.BaseTestCase):
def setUp(self):
super(_BaseTestLBPollster, self).setUp()
self.addCleanup(mock.patch.stopall)
self.CONF = service.prepare_service([], [])
self.manager = manager.AgentManager(0, self.CONF)
self.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)
catalog.get_endpoints = mock.MagicMock(
return_value={'network': mock.ANY})
class TestLBPoolPollster(_BaseTestLBPollster):
def setUp(self):
super(TestLBPoolPollster, self).setUp()
self.pollster = lbaas.LBPoolPollster(self.CONF)
fake_pools = self.fake_get_pools()
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'pool_get_all',
return_value=fake_pools))
@staticmethod
def fake_get_pools():
return [{'status': 'ACTIVE',
'lb_method': 'ROUND_ROBIN',
'protocol': 'HTTP',
'description': '',
'health_monitors': [],
'members': [],
'provider': 'haproxy',
'status_description': None,
'id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'vip_id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'mylb',
'admin_state_up': True,
'subnet_id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'health_monitors_status': []},
{'status': 'INACTIVE',
'lb_method': 'ROUND_ROBIN',
'protocol': 'HTTP',
'description': '',
'health_monitors': [],
'members': [],
'provider': 'haproxy',
'status_description': None,
'id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'vip_id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'mylb02',
'admin_state_up': True,
'subnet_id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'health_monitors_status': []},
{'status': 'PENDING_CREATE',
'lb_method': 'ROUND_ROBIN',
'protocol': 'HTTP',
'description': '',
'health_monitors': [],
'members': [],
'provider': 'haproxy',
'status_description': None,
'id': 'fe7rad36-437d-4c84-aee1-186027d3bdcd',
'vip_id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'mylb03',
'admin_state_up': True,
'subnet_id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'health_monitors_status': []},
{'status': 'UNKNOWN',
'lb_method': 'ROUND_ROBIN',
'protocol': 'HTTP',
'description': '',
'health_monitors': [],
'members': [],
'provider': 'haproxy',
'status_description': None,
'id': 'fe7rad36-437d-4c84-aee1-186027d3bdcd',
'vip_id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'mylb03',
'admin_state_up': True,
'subnet_id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'health_monitors_status': []},
{'status': 'error',
'lb_method': 'ROUND_ROBIN',
'protocol': 'HTTP',
'description': '',
'health_monitors': [],
'members': [],
'provider': 'haproxy',
'status_description': None,
'id': 'fe7rad36-437d-4c84-aee1-186027d3bdcd',
'vip_id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'mylb_error',
'admin_state_up': True,
'subnet_id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'health_monitors_status': []},
]
def test_pool_get_samples(self):
samples = list(self.pollster.get_samples(
self.manager, {},
resources=self.fake_get_pools()))
self.assertEqual(4, len(samples))
for field in self.pollster.FIELDS:
self.assertEqual(self.fake_get_pools()[0][field],
samples[0].resource_metadata[field])
def test_pool_volume(self):
samples = list(self.pollster.get_samples(
self.manager, {},
resources=self.fake_get_pools()))
self.assertEqual(1, samples[0].volume)
self.assertEqual(0, samples[1].volume)
self.assertEqual(2, samples[2].volume)
def test_get_pool_meter_names(self):
samples = list(self.pollster.get_samples(
self.manager, {},
resources=self.fake_get_pools()))
self.assertEqual(set(['network.services.lb.pool']),
set([s.name for s in samples]))
def test_pool_discovery(self):
discovered_pools = discovery.LBPoolsDiscovery(
self.CONF).discover(self.manager)
self.assertEqual(4, len(discovered_pools))
for pool in self.fake_get_pools():
if pool['status'] == 'error':
self.assertNotIn(pool, discovered_pools)
else:
self.assertIn(pool, discovered_pools)
class TestLBVipPollster(_BaseTestLBPollster):
def setUp(self):
super(TestLBVipPollster, self).setUp()
self.pollster = lbaas.LBVipPollster(self.CONF)
fake_vips = self.fake_get_vips()
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'vip_get_all',
return_value=fake_vips))
@staticmethod
def fake_get_vips():
return [{'status': 'ACTIVE',
'status_description': None,
'protocol': 'HTTP',
'description': '',
'admin_state_up': True,
'subnet_id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'connection_limit': -1,
'pool_id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'session_persistence': None,
'address': '10.0.0.2',
'protocol_port': 80,
'port_id': '3df3c4de-b32e-4ca1-a7f4-84323ba5f291',
'id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'myvip'},
{'status': 'INACTIVE',
'status_description': None,
'protocol': 'HTTP',
'description': '',
'admin_state_up': True,
'subnet_id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'connection_limit': -1,
'pool_id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'session_persistence': None,
'address': '10.0.0.3',
'protocol_port': 80,
'port_id': '3df3c4de-b32e-4ca1-a7f4-84323ba5f291',
'id': 'ba6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'myvip02'},
{'status': 'PENDING_CREATE',
'status_description': None,
'protocol': 'HTTP',
'description': '',
'admin_state_up': True,
'subnet_id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'connection_limit': -1,
'pool_id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'session_persistence': None,
'address': '10.0.0.4',
'protocol_port': 80,
'port_id': '3df3c4de-b32e-4ca1-a7f4-84323ba5f291',
'id': 'fg6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'myvip03'},
{'status': 'UNKNOWN',
'status_description': None,
'protocol': 'HTTP',
'description': '',
'admin_state_up': True,
'subnet_id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'connection_limit': -1,
'pool_id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'session_persistence': None,
'address': '10.0.0.8',
'protocol_port': 80,
'port_id': '3df3c4de-b32e-4ca1-a7f4-84323ba5f291',
'id': 'fg6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'myvip03'},
{'status': 'error',
'status_description': None,
'protocol': 'HTTP',
'description': '',
'admin_state_up': True,
'subnet_id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'connection_limit': -1,
'pool_id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'session_persistence': None,
'address': '10.0.0.8',
'protocol_port': 80,
'port_id': '3df3c4de-b32e-4ca1-a7f4-84323ba5f291',
'id': 'fg6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'myvip_error'},
]
def test_vip_get_samples(self):
samples = list(self.pollster.get_samples(
self.manager, {},
resources=self.fake_get_vips()))
self.assertEqual(4, len(samples))
for field in self.pollster.FIELDS:
self.assertEqual(self.fake_get_vips()[0][field],
samples[0].resource_metadata[field])
def test_pool_volume(self):
samples = list(self.pollster.get_samples(
self.manager, {},
resources=self.fake_get_vips()))
self.assertEqual(1, samples[0].volume)
self.assertEqual(0, samples[1].volume)
self.assertEqual(2, samples[2].volume)
def test_get_vip_meter_names(self):
samples = list(self.pollster.get_samples(
self.manager, {},
resources=self.fake_get_vips()))
self.assertEqual(set(['network.services.lb.vip']),
set([s.name for s in samples]))
def test_vip_discovery(self):
discovered_vips = discovery.LBVipsDiscovery(
self.CONF).discover(self.manager)
self.assertEqual(4, len(discovered_vips))
for pool in self.fake_get_vips():
if pool['status'] == 'error':
self.assertNotIn(pool, discovered_vips)
else:
self.assertIn(pool, discovered_vips)
class TestLBMemberPollster(_BaseTestLBPollster):
def setUp(self):
super(TestLBMemberPollster, self).setUp()
self.pollster = lbaas.LBMemberPollster(self.CONF)
fake_members = self.fake_get_members()
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'member_get_all',
return_value=fake_members))
@staticmethod
def fake_get_members():
return [{'status': 'ACTIVE',
'protocol_port': 80,
'weight': 1,
'admin_state_up': True,
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'pool_id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'address': '10.0.0.3',
'status_description': None,
'id': '290b61eb-07bc-4372-9fbf-36459dd0f96b'},
{'status': 'INACTIVE',
'protocol_port': 80,
'weight': 1,
'admin_state_up': True,
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'pool_id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'address': '10.0.0.5',
'status_description': None,
'id': '2456661eb-07bc-4372-9fbf-36459dd0f96b'},
{'status': 'PENDING_CREATE',
'protocol_port': 80,
'weight': 1,
'admin_state_up': True,
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'pool_id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'address': '10.0.0.6',
'status_description': None,
'id': '45630b61eb-07bc-4372-9fbf-36459dd0f96b'},
{'status': 'UNKNOWN',
'protocol_port': 80,
'weight': 1,
'admin_state_up': True,
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'pool_id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'address': '10.0.0.6',
'status_description': None,
'id': '45630b61eb-07bc-4372-9fbf-36459dd0f96b'},
{'status': 'error',
'protocol_port': 80,
'weight': 1,
'admin_state_up': True,
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'pool_id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'address': '10.0.0.6',
'status_description': None,
'id': '45630b61eb-07bc-4372-9fbf-36459dd0f96b'},
]
def test_get_samples_not_empty(self):
samples = list(self.pollster.get_samples(
self.manager, {},
self.fake_get_members()))
self.assertEqual(4, len(samples))
for field in self.pollster.FIELDS:
self.assertEqual(self.fake_get_members()[0][field],
samples[0].resource_metadata[field])
def test_pool_volume(self):
samples = list(self.pollster.get_samples(
self.manager, {},
self.fake_get_members()))
self.assertEqual(1, samples[0].volume)
self.assertEqual(0, samples[1].volume)
self.assertEqual(2, samples[2].volume)
def test_get_meter_names(self):
samples = list(self.pollster.get_samples(
self.manager, {},
self.fake_get_members()))
self.assertEqual(set(['network.services.lb.member']),
set([s.name for s in samples]))
def test_members_discovery(self):
discovered_members = discovery.LBMembersDiscovery(
self.CONF).discover(self.manager)
self.assertEqual(4, len(discovered_members))
for pool in self.fake_get_members():
if pool['status'] == 'error':
self.assertNotIn(pool, discovered_members)
else:
self.assertIn(pool, discovered_members)
class TestLBHealthProbePollster(_BaseTestLBPollster):
def setUp(self):
super(TestLBHealthProbePollster, self).setUp()
self.pollster = lbaas.LBHealthMonitorPollster(self.CONF)
fake_health_monitor = self.fake_get_health_monitor()
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'health_monitor_get_all',
return_value=fake_health_monitor))
@staticmethod
def fake_get_health_monitor():
return [{'id': '34ae33e1-0035-49e2-a2ca-77d5d3fab365',
'admin_state_up': True,
'tenant_id': "d5d2817dae6b42159be9b665b64beb0e",
'delay': 2,
'max_retries': 5,
'timeout': 5,
'pools': [],
'type': 'PING',
}]
def test_get_samples_not_empty(self):
samples = list(self.pollster.get_samples(
self.manager, {},
self.fake_get_health_monitor()))
self.assertEqual(1, len(samples))
for field in self.pollster.FIELDS:
self.assertEqual(self.fake_get_health_monitor()[0][field],
samples[0].resource_metadata[field])
def test_get_meter_names(self):
samples = list(self.pollster.get_samples(
self.manager, {},
self.fake_get_health_monitor()))
self.assertEqual(set(['network.services.lb.health_monitor']),
set([s.name for s in samples]))
def test_probes_discovery(self):
discovered_probes = discovery.LBHealthMonitorsDiscovery(
self.CONF).discover(self.manager)
self.assertEqual(discovered_probes, self.fake_get_health_monitor())
class TestLBStatsPollster(_BaseTestLBPollster):
def setUp(self):
super(TestLBStatsPollster, self).setUp()
fake_pool_stats = self.fake_pool_stats()
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'pool_stats',
return_value=fake_pool_stats))
fake_pools = self.fake_get_pools()
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'pool_get_all',
return_value=fake_pools))
@staticmethod
def fake_get_pools():
return [{'status': 'ACTIVE',
'lb_method': 'ROUND_ROBIN',
'protocol': 'HTTP',
'description': '',
'health_monitors': [],
'members': [],
'provider': 'haproxy',
'status_description': None,
'id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'vip_id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'mylb',
'admin_state_up': True,
'subnet_id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'health_monitors_status': []},
]
@staticmethod
def fake_pool_stats():
return {'stats': {'active_connections': 2,
'bytes_in': 1,
'bytes_out': 3,
'total_connections': 4
}
}
def _check_get_samples(self, factory, sample_name, expected_volume,
expected_type):
pollster = factory(self.CONF)
cache = {}
samples = list(pollster.get_samples(self.manager, cache,
self.fake_get_pools()))
self.assertEqual(1, len(samples))
self.assertIsNotNone(samples)
self.assertIn('lbstats', cache)
self.assertEqual(set([sample_name]), set([s.name for s in samples]))
match = [s for s in samples if s.name == sample_name]
self.assertEqual(1, len(match), 'missing counter %s' % sample_name)
self.assertEqual(expected_volume, match[0].volume)
self.assertEqual(expected_type, match[0].type)
def test_lb_total_connections(self):
self._check_get_samples(lbaas.LBTotalConnectionsPollster,
'network.services.lb.total.connections',
4, 'cumulative')
def test_lb_active_connections(self):
self._check_get_samples(lbaas.LBActiveConnectionsPollster,
'network.services.lb.active.connections',
2, 'gauge')
def test_lb_incoming_bytes(self):
self._check_get_samples(lbaas.LBBytesInPollster,
'network.services.lb.incoming.bytes',
1, 'gauge')
def test_lb_outgoing_bytes(self):
self._check_get_samples(lbaas.LBBytesOutPollster,
'network.services.lb.outgoing.bytes',
3, 'gauge')

View File

@ -1,301 +0,0 @@
#
#
# 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.
from unittest import mock
import fixtures
from oslotest import base
from ceilometer.network.services import discovery
from ceilometer.network.services import lbaas
from ceilometer.polling import manager
from ceilometer.polling import plugin_base
from ceilometer import service
class _BaseTestLBPollster(base.BaseTestCase):
def setUp(self):
super(_BaseTestLBPollster, self).setUp()
self.addCleanup(mock.patch.stopall)
self.CONF = service.prepare_service([], [])
self.manager = manager.AgentManager(0, self.CONF)
plugin_base._get_keystone = mock.Mock()
catalog = (plugin_base._get_keystone.session.auth.get_access.
return_value.service_catalog)
catalog.get_endpoints = mock.MagicMock(
return_value={'network': mock.ANY})
class TestLBListenerPollster(_BaseTestLBPollster):
def setUp(self):
super(TestLBListenerPollster, self).setUp()
self.pollster = lbaas.LBListenerPollster(self.CONF)
self.pollster.lb_version = 'v2'
fake_listeners = self.fake_list_listeners()
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'list_listener',
return_value=fake_listeners))
@staticmethod
def fake_list_listeners():
return [{'default_pool_id': None,
'protocol': 'HTTP',
'description': '',
'loadbalancers': [
{'id': 'a9729389-6147-41a3-ab22-a24aed8692b2'}],
'id': '35cb8516-1173-4035-8dae-0dae3453f37f',
'name': 'mylistener_online',
'admin_state_up': True,
'connection_limit': 100,
'tenant_id': '3e4d8bec50a845fcb09e03a4375c691d',
'protocol_port': 80,
'operating_status': 'ONLINE'},
{'default_pool_id': None,
'protocol': 'HTTP',
'description': '',
'loadbalancers': [
{'id': 'ce73ad36-437d-4c84-aee1-186027d3da9a'}],
'id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'mylistener_offline',
'admin_state_up': True,
'connection_limit': 100,
'tenant_id': '3e4d8bec50a845fcb09e03a4375c691d',
'protocol_port': 80,
'operating_status': 'OFFLINE'},
{'default_pool_id': None,
'protocol': 'HTTP',
'description': '',
'loadbalancers': [
{'id': 'fe7rad36-437d-4c84-aee1-186027d3bdcd'}],
'id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'name': 'mylistener_error',
'admin_state_up': True,
'connection_limit': 100,
'tenant_id': '3e4d8bec50a845fcb09e03a4375c691d',
'protocol_port': 80,
'operating_status': 'ERROR'},
{'default_pool_id': None,
'protocol': 'HTTP',
'description': '',
'loadbalancers': [
{'id': 'fe7rad36-437d-4c84-aee1-186027d3bdcd'}],
'id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'name': 'mylistener_pending_create',
'admin_state_up': True,
'connection_limit': 100,
'tenant_id': '3e4d8bec50a845fcb09e03a4375c691d',
'protocol_port': 80,
'operating_status': 'PENDING_CREATE'}
]
def test_listener_get_samples(self):
samples = list(self.pollster.get_samples(
self.manager, {},
resources=self.fake_list_listeners()))
self.assertEqual(3, len(samples))
for field in self.pollster.FIELDS:
self.assertEqual(self.fake_list_listeners()[0][field],
samples[0].resource_metadata[field])
def test_listener_volume(self):
samples = list(self.pollster.get_samples(
self.manager, {},
resources=self.fake_list_listeners()))
self.assertEqual(1, samples[0].volume)
self.assertEqual(0, samples[1].volume)
self.assertEqual(4, samples[2].volume)
def test_list_listener_meter_names(self):
samples = list(self.pollster.get_samples(
self.manager, {},
resources=self.fake_list_listeners()))
self.assertEqual(set(['network.services.lb.listener']),
set([s.name for s in samples]))
def test_listener_discovery(self):
discovered_listeners = discovery.LBListenersDiscovery(
self.CONF).discover(self.manager)
self.assertEqual(4, len(discovered_listeners))
for listener in self.fake_list_listeners():
if listener['operating_status'] == 'pending_create':
self.assertNotIn(listener, discovered_listeners)
else:
self.assertIn(listener, discovered_listeners)
class TestLBLoadBalancerPollster(_BaseTestLBPollster):
def setUp(self):
super(TestLBLoadBalancerPollster, self).setUp()
self.pollster = lbaas.LBLoadBalancerPollster(self.CONF)
self.pollster.lb_version = 'v2'
fake_loadbalancers = self.fake_list_loadbalancers()
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'list_loadbalancer',
return_value=fake_loadbalancers))
@staticmethod
def fake_list_loadbalancers():
return [{'operating_status': 'ONLINE',
'description': '',
'admin_state_up': True,
'tenant_id': '1a3e005cf9ce40308c900bcb08e5320c',
'provisioning_status': 'ACTIVE',
'listeners': [{'id': 'fe7rad36-437d-4c84-aee1-186027d3bdcd'}],
'vip_address': '10.0.0.2',
'vip_subnet_id': '013d3059-87a4-45a5-91e9-d721068ae0b2',
'id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'loadbalancer_online'},
{'operating_status': 'OFFLINE',
'description': '',
'admin_state_up': True,
'tenant_id': '1a3e005cf9ce40308c900bcb08e5320c',
'provisioning_status': 'INACTIVE',
'listeners': [{'id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a'}],
'vip_address': '10.0.0.3',
'vip_subnet_id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'name': 'loadbalancer_offline'},
{'operating_status': 'ERROR',
'description': '',
'admin_state_up': True,
'tenant_id': '1a3e005cf9ce40308c900bcb08e5320c',
'provisioning_status': 'INACTIVE',
'listeners': [{'id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d8b'}],
'vip_address': '10.0.0.4',
'vip_subnet_id': '213d3059-87a4-45a5-91e9-d721068df0b2',
'id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'loadbalancer_error'},
{'operating_status': 'PENDING_CREATE',
'description': '',
'admin_state_up': True,
'tenant_id': '1a3e005cf9ce40308c900bcb08e5320c',
'provisioning_status': 'INACTIVE',
'listeners': [{'id': 'fe7rad36-437d-4c84-aee1-186027d4ed7c'}],
'vip_address': '10.0.0.5',
'vip_subnet_id': '123d3059-87a4-45a5-91e9-d721068ae0c3',
'id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395763b2',
'name': 'loadbalancer_pending_create'}
]
def test_loadbalancer_get_samples(self):
samples = list(self.pollster.get_samples(
self.manager, {},
resources=self.fake_list_loadbalancers()))
self.assertEqual(3, len(samples))
for field in self.pollster.FIELDS:
self.assertEqual(self.fake_list_loadbalancers()[0][field],
samples[0].resource_metadata[field])
def test_loadbalancer_volume(self):
samples = list(self.pollster.get_samples(
self.manager, {},
resources=self.fake_list_loadbalancers()))
self.assertEqual(1, samples[0].volume)
self.assertEqual(0, samples[1].volume)
self.assertEqual(4, samples[2].volume)
def test_list_loadbalancer_meter_names(self):
samples = list(self.pollster.get_samples(
self.manager, {},
resources=self.fake_list_loadbalancers()))
self.assertEqual(set(['network.services.lb.loadbalancer']),
set([s.name for s in samples]))
def test_loadbalancer_discovery(self):
discovered_loadbalancers = discovery.LBLoadBalancersDiscovery(
self.CONF).discover(self.manager)
self.assertEqual(4, len(discovered_loadbalancers))
for loadbalancer in self.fake_list_loadbalancers():
if loadbalancer['operating_status'] == 'pending_create':
self.assertNotIn(loadbalancer, discovered_loadbalancers)
else:
self.assertIn(loadbalancer, discovered_loadbalancers)
class TestLBStatsPollster(_BaseTestLBPollster):
def setUp(self):
super(TestLBStatsPollster, self).setUp()
fake_balancer_stats = self.fake_balancer_stats()
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'get_loadbalancer_stats',
return_value=fake_balancer_stats))
fake_loadbalancers = self.fake_list_loadbalancers()
self.useFixture(fixtures.MockPatch('ceilometer.neutron_client.Client.'
'list_loadbalancer',
return_value=fake_loadbalancers))
self.CONF.set_override('neutron_lbaas_version',
'v2',
group='service_types')
@staticmethod
def fake_list_loadbalancers():
return [{'operating_status': 'ONLINE',
'description': '',
'admin_state_up': True,
'tenant_id': '1a3e005cf9ce40308c900bcb08e5320c',
'provisioning_status': 'ACTIVE',
'listeners': [{'id': 'fe7rad36-437d-4c84-aee1-186027d3bdcd'}],
'vip_address': '10.0.0.2',
'vip_subnet_id': '013d3059-87a4-45a5-91e9-d721068ae0b2',
'id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'loadbalancer_online'},
]
@staticmethod
def fake_balancer_stats():
return {'active_connections': 2,
'bytes_in': 1,
'bytes_out': 3,
'total_connections': 4}
def _check_get_samples(self, factory, sample_name, expected_volume,
expected_type):
pollster = factory(self.CONF)
cache = {}
samples = list(pollster.get_samples(self.manager, cache,
self.fake_list_loadbalancers()))
self.assertEqual(1, len(samples))
self.assertIsNotNone(samples)
self.assertIn('lbstats', cache)
self.assertEqual(set([sample_name]), set([s.name for s in samples]))
match = [s for s in samples if s.name == sample_name]
self.assertEqual(1, len(match), 'missing counter %s' % sample_name)
self.assertEqual(expected_volume, match[0].volume)
self.assertEqual(expected_type, match[0].type)
def test_lb_total_connections(self):
self._check_get_samples(lbaas.LBTotalConnectionsPollster,
'network.services.lb.total.connections',
4, 'cumulative')
def test_lb_active_connections(self):
self._check_get_samples(lbaas.LBActiveConnectionsPollster,
'network.services.lb.active.connections',
2, 'gauge')
def test_lb_incoming_bytes(self):
self._check_get_samples(lbaas.LBBytesInPollster,
'network.services.lb.incoming.bytes',
1, 'gauge')
def test_lb_outgoing_bytes(self):
self._check_get_samples(lbaas.LBBytesOutPollster,
'network.services.lb.outgoing.bytes',
3, 'gauge')

View File

@ -67,128 +67,3 @@ class TestNeutronClient(base.BaseTestCase):
'subnets': [u'c4b6f5b8-3508-4896-b238-a441f25fb492'], 'subnets': [u'c4b6f5b8-3508-4896-b238-a441f25fb492'],
'tenant_id': '62d6f08bbd3a44f6ad6f00ca15cce4e5'}, 'tenant_id': '62d6f08bbd3a44f6ad6f00ca15cce4e5'},
]} ]}
@staticmethod
def fake_pool_list():
return {'pools': [{'status': 'ACTIVE',
'lb_method': 'ROUND_ROBIN',
'protocol': 'HTTP',
'description': '',
'health_monitors': [],
'members': [],
'status_description': None,
'id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'vip_id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'mylb',
'admin_state_up': True,
'subnet_id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'health_monitors_status': []},
]}
def test_pool_list(self):
with mock.patch.object(self.nc.client, 'list_pools',
side_effect=self.fake_pool_list):
pools = self.nc.pool_get_all()
self.assertEqual(1, len(pools))
self.assertEqual('ce73ad36-437d-4c84-aee1-186027d3da9a',
pools[0]['id'])
@staticmethod
def fake_vip_list():
return {'vips': [{'status': 'ACTIVE',
'status_description': None,
'protocol': 'HTTP',
'description': '',
'admin_state_up': True,
'subnet_id': 'bbe3d818-bdcb-4e4b-b47f-5650dc8a9d7a',
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'connection_limit': -1,
'pool_id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'session_persistence': None,
'address': '10.0.0.2',
'protocol_port': 80,
'port_id': '3df3c4de-b32e-4ca1-a7f4-84323ba5f291',
'id': 'cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
'name': 'myvip'},
]}
def test_vip_list(self):
with mock.patch.object(self.nc.client, 'list_vips',
side_effect=self.fake_vip_list):
vips = self.nc.vip_get_all()
self.assertEqual(1, len(vips))
self.assertEqual('cd6a6fee-e2fa-4e6c-b3c2-bfbe395752c1',
vips[0]['id'])
@staticmethod
def fake_member_list():
return {'members': [{'status': 'ACTIVE',
'protocol_port': 80,
'weight': 1,
'admin_state_up': True,
'tenant_id': 'a4eb9f4938bb418bbc4f8eb31802fefa',
'pool_id': 'ce73ad36-437d-4c84-aee1-186027d3da9a',
'address': '10.0.0.3',
'status_description': None,
'id': '290b61eb-07bc-4372-9fbf-36459dd0f96b'},
]}
def test_member_list(self):
with mock.patch.object(self.nc.client, 'list_members',
side_effect=self.fake_member_list):
members = self.nc.member_get_all()
self.assertEqual(1, len(members))
self.assertEqual('290b61eb-07bc-4372-9fbf-36459dd0f96b',
members[0]['id'])
@staticmethod
def fake_monitors_list():
return {'health_monitors':
[{'id': '34ae33e1-0035-49e2-a2ca-77d5d3fab365',
'admin_state_up': True,
'tenant_id': "d5d2817dae6b42159be9b665b64beb0e",
'delay': 2,
'max_retries': 5,
'timeout': 5,
'pools': [],
'type': 'PING',
}]}
def test_monitor_list(self):
with mock.patch.object(self.nc.client, 'list_health_monitors',
side_effect=self.fake_monitors_list):
monitors = self.nc.health_monitor_get_all()
self.assertEqual(1, len(monitors))
self.assertEqual('34ae33e1-0035-49e2-a2ca-77d5d3fab365',
monitors[0]['id'])
@staticmethod
def fake_pool_stats(fake_pool):
return {'stats':
[{'active_connections': 1,
'total_connections': 2,
'bytes_in': 3,
'bytes_out': 4
}]}
def test_pool_stats(self):
with mock.patch.object(self.nc.client, 'retrieve_pool_stats',
side_effect=self.fake_pool_stats):
stats = self.nc.pool_stats('fake_pool')['stats']
self.assertEqual(1, len(stats))
self.assertEqual(1, stats[0]['active_connections'])
self.assertEqual(2, stats[0]['total_connections'])
self.assertEqual(3, stats[0]['bytes_in'])
self.assertEqual(4, stats[0]['bytes_out'])
def test_v1_list_loadbalancer_returns_empty_list(self):
self.assertEqual([], self.nc.list_loadbalancer())
def test_v1_list_listener_returns_empty_list(self):
self.assertEqual([], self.nc.list_listener())

View File

@ -1,339 +0,0 @@
#
# 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.
from unittest import mock
from neutronclient.v2_0 import client
from oslotest import base
from ceilometer import neutron_client
from ceilometer import service
class TestNeutronClientLBaaSV2(base.BaseTestCase):
def setUp(self):
super(TestNeutronClientLBaaSV2, self).setUp()
conf = service.prepare_service([], [])
self.nc = neutron_client.Client(conf)
@staticmethod
def fake_list_lbaas_pools():
return {
'pools': [{
'lb_algorithm': 'ROUND_ROBIN',
'protocol': 'HTTP',
'description': 'simple pool',
'admin_state_up': True,
'tenant_id': '1a3e005cf9ce40308c900bcb08e5320c',
'healthmonitor_id': None,
'listeners': [{
'id': "35cb8516-1173-4035-8dae-0dae3453f37f"
}
],
'members': [{
'id': 'fcf23bde-8cf9-4616-883f-208cebcbf858'}
],
'id': '4c0a0a5f-cf8f-44b7-b912-957daa8ce5e5',
'name': 'pool1'
}]
}
@staticmethod
def fake_list_lbaas_members():
return {
'members': [{
'weight': 1,
'admin_state_up': True,
'subnet_id': '013d3059-87a4-45a5-91e9-d721068ae0b2',
'tenant_id': '1a3e005cf9ce40308c900bcb08e5320c',
'address': '10.0.0.8',
'protocol_port': 80,
'id': 'fcf23bde-8cf9-4616-883f-208cebcbf858'
}]
}
@staticmethod
def fake_list_lbaas_healthmonitors():
return {
'healthmonitors': [{
'admin_state_up': True,
'tenant_id': '6f3584d5754048a18e30685362b88411',
'delay': 1,
'expected_codes': '200,201,202',
'max_retries': 5,
'http_method': 'GET',
'timeout': 1,
'pools': [{
'id': '74aa2010-a59f-4d35-a436-60a6da882819'
}],
'url_path': '/index.html',
'type': 'HTTP',
'id': '0a9ac99d-0a09-4b18-8499-a0796850279a'
}]
}
@staticmethod
def fake_show_listener():
return {
'listener': {
'default_pool_id': None,
'protocol': 'HTTP',
'description': '',
'admin_state_up': True,
'loadbalancers': [{
'id': 'a9729389-6147-41a3-ab22-a24aed8692b2'
}],
'tenant_id': '3e4d8bec50a845fcb09e03a4375c691d',
'connection_limit': 100,
'protocol_port': 80,
'id': '35cb8516-1173-4035-8dae-0dae3453f37f',
'name': ''
}
}
@staticmethod
def fake_retrieve_loadbalancer_status():
return {
'statuses': {
'loadbalancer': {
'operating_status': 'ONLINE',
'provisioning_status': 'ACTIVE',
'listeners': [{
'id': '35cb8516-1173-4035-8dae-0dae3453f37f',
'operating_status': 'ONLINE',
'provisioning_status': 'ACTIVE',
'pools': [{
'id': '4c0a0a5f-cf8f-44b7-b912-957daa8ce5e5',
'operating_status': 'ONLINE',
'provisioning_status': 'ACTIVE',
'members': [{
'id': 'fcf23bde-8cf9-4616-883f-208cebcbf858',
'operating_status': 'ONLINE',
'provisioning_status': 'ACTIVE'
}],
'healthmonitor': {
'id': '785131d2-8f7b-4fee-a7e7-3196e11b4518',
'provisioning_status': 'ACTIVE'
}
}]
}]
}
}
}
@staticmethod
def fake_retrieve_loadbalancer_status_complex():
return {
'statuses': {
'loadbalancer': {
'operating_status': 'ONLINE',
'provisioning_status': 'ACTIVE',
'listeners': [{
'id': '35cb8516-1173-4035-8dae-0dae3453f37f',
'operating_status': 'ONLINE',
'provisioning_status': 'ACTIVE',
'pools': [{
'id': '4c0a0a5f-cf8f-44b7-b912-957daa8ce5e5',
'operating_status': 'ONLINE',
'provisioning_status': 'ACTIVE',
'members': [{
'id': 'fcf23bde-8cf9-4616-883f-208cebcbf858',
'operating_status': 'ONLINE',
'provisioning_status': 'ACTIVE'
},
{
'id': 'fcf23bde-8cf9-4616-883f-208cebcbf969',
'operating_status': 'OFFLINE',
'provisioning_status': 'ACTIVE'
}],
'healthmonitor': {
'id': '785131d2-8f7b-4fee-a7e7-3196e11b4518',
'provisioning_status': 'ACTIVE'
}
},
{
'id': '4c0a0a5f-cf8f-44b7-b912-957daa8ce6f6',
'operating_status': 'OFFLINE',
'provisioning_status': 'ACTIVE',
'members': [{
'id': 'fcf23bde-8cf9-4616-883f-208cebcbfa7a',
'operating_status': 'ONLINE',
'provisioning_status': 'ACTIVE'
}],
'healthmonitor': {
'id': '785131d2-8f7b-4fee-a7e7-3196e11b4629',
'provisioning_status': 'ACTIVE'
}
}]
},
{
'id': '35cb8516-1173-4035-8dae-0dae3453f48e',
'operating_status': 'OFFLINE',
'provisioning_status': 'ACTIVE',
'pools': [{
'id': '4c0a0a5f-cf8f-44b7-b912-957daa8ce7g7',
'operating_status': 'ONLINE',
'provisioning_status': 'ACTIVE',
'members': [{
'id': 'fcf23bde-8cf9-4616-883f-208cebcbfb8b',
'operating_status': 'ONLINE',
'provisioning_status': 'ACTIVE'
}],
'healthmonitor': {
'id': '785131d2-8f7b-4fee-a7e7-3196e11b473a',
'provisioning_status': 'ACTIVE'
}
}]
}]
}
}
}
@staticmethod
def fake_list_lbaas_listeners():
return {
'listeners': [{
'default_pool_id': None,
'protocol': 'HTTP',
'description': '',
'admin_state_up': True,
'loadbalancers': [{
'id': 'a9729389-6147-41a3-ab22-a24aed8692b2'
}],
'tenant_id': '3e4d8bec50a845fcb09e03a4375c691d',
'connection_limit': 100,
'protocol_port': 80,
'id': '35cb8516-1173-4035-8dae-0dae3453f37f',
'name': 'listener_one'
}]}
@mock.patch.object(client.Client,
'list_lbaas_pools')
@mock.patch.object(client.Client,
'show_listener')
@mock.patch.object(neutron_client.Client,
'_retrieve_loadbalancer_status_tree')
def test_list_pools_v2(self, mock_status, mock_show, mock_list):
mock_status.return_value = self.fake_retrieve_loadbalancer_status()
mock_show.return_value = self.fake_show_listener()
mock_list.return_value = self.fake_list_lbaas_pools()
pools = self.nc.list_pools_v2()
self.assertEqual(1, len(pools))
for pool in pools:
self.assertEqual('ONLINE', pool['status'])
self.assertEqual('ROUND_ROBIN', pool['lb_method'])
@mock.patch.object(client.Client,
'list_lbaas_pools')
@mock.patch.object(client.Client,
'list_lbaas_members')
@mock.patch.object(client.Client,
'show_listener')
@mock.patch.object(neutron_client.Client,
'_retrieve_loadbalancer_status_tree')
def test_list_members_v2(self, mock_status, mock_show, mock_list_members,
mock_list_pools):
mock_status.return_value = self.fake_retrieve_loadbalancer_status()
mock_show.return_value = self.fake_show_listener()
mock_list_pools.return_value = self.fake_list_lbaas_pools()
mock_list_members.return_value = self.fake_list_lbaas_members()
members = self.nc.list_members_v2()
self.assertEqual(1, len(members))
for member in members:
self.assertEqual('ONLINE', member['status'])
self.assertEqual('4c0a0a5f-cf8f-44b7-b912-957daa8ce5e5',
member['pool_id'])
@mock.patch.object(client.Client,
'list_lbaas_healthmonitors')
def test_list_health_monitors_v2(self, mock_list_healthmonitors):
mock_list_healthmonitors.return_value = (
self.fake_list_lbaas_healthmonitors())
healthmonitors = self.nc.list_health_monitors_v2()
self.assertEqual(1, len(healthmonitors))
for healthmonitor in healthmonitors:
self.assertEqual(5, healthmonitor['max_retries'])
@mock.patch.object(neutron_client.Client,
'_retrieve_loadbalancer_status_tree')
def test_get_member_status(self, mock_status):
mock_status.return_value = (
self.fake_retrieve_loadbalancer_status_complex())
loadbalancer_id = '5b1b1b6e-cf8f-44b7-b912-957daa8ce5e5'
listener_id = '35cb8516-1173-4035-8dae-0dae3453f37f'
pool_id = '4c0a0a5f-cf8f-44b7-b912-957daa8ce5e5'
parent_id = [listener_id, pool_id]
result_status = self.nc._get_member_status(loadbalancer_id,
parent_id)
expected_keys = ['fcf23bde-8cf9-4616-883f-208cebcbf858',
'fcf23bde-8cf9-4616-883f-208cebcbf969']
excepted_status = {
'fcf23bde-8cf9-4616-883f-208cebcbf858': 'ONLINE',
'fcf23bde-8cf9-4616-883f-208cebcbf969': 'OFFLINE'}
for key in result_status:
self.assertIn(key, expected_keys)
self.assertEqual(excepted_status[key], result_status[key])
@mock.patch.object(neutron_client.Client,
'_retrieve_loadbalancer_status_tree')
def test_get_pool_status(self, mock_status):
mock_status.return_value = (
self.fake_retrieve_loadbalancer_status_complex())
loadbalancer_id = '5b1b1b6e-cf8f-44b7-b912-957daa8ce5e5'
parent_id = '35cb8516-1173-4035-8dae-0dae3453f37f'
result_status = self.nc._get_pool_status(loadbalancer_id,
parent_id)
expected_keys = ['4c0a0a5f-cf8f-44b7-b912-957daa8ce5e5',
'4c0a0a5f-cf8f-44b7-b912-957daa8ce6f6']
excepted_status = {
'4c0a0a5f-cf8f-44b7-b912-957daa8ce5e5': 'ONLINE',
'4c0a0a5f-cf8f-44b7-b912-957daa8ce6f6': 'OFFLINE'}
for key in result_status:
self.assertIn(key, expected_keys)
self.assertEqual(excepted_status[key], result_status[key])
@mock.patch.object(neutron_client.Client,
'_retrieve_loadbalancer_status_tree')
def test_get_listener_status(self, mock_status):
mock_status.return_value = (
self.fake_retrieve_loadbalancer_status_complex())
loadbalancer_id = '5b1b1b6e-cf8f-44b7-b912-957daa8ce5e5'
result_status = self.nc._get_listener_status(loadbalancer_id)
expected_keys = ['35cb8516-1173-4035-8dae-0dae3453f37f',
'35cb8516-1173-4035-8dae-0dae3453f48e']
excepted_status = {
'35cb8516-1173-4035-8dae-0dae3453f37f': 'ONLINE',
'35cb8516-1173-4035-8dae-0dae3453f48e': 'OFFLINE'}
for key in result_status:
self.assertIn(key, expected_keys)
self.assertEqual(excepted_status[key], result_status[key])
@mock.patch.object(client.Client,
'list_listeners')
@mock.patch.object(neutron_client.Client,
'_retrieve_loadbalancer_status_tree')
def test_list_listener(self, mock_status, mock_list_listeners):
mock_list_listeners.return_value = (
self.fake_list_lbaas_listeners())
mock_status.return_value = (
self.fake_retrieve_loadbalancer_status())
listeners = self.nc.list_listener()
expected_key = '35cb8516-1173-4035-8dae-0dae3453f37f'
expected_status = 'ONLINE'
self.assertEqual(1, len(listeners))
self.assertEqual(expected_key, listeners[0]['id'])
self.assertEqual(expected_status, listeners[0]['operating_status'])

View File

@ -835,99 +835,6 @@ The following meters are collected for SDN:
These meters are available for OpenFlow based switches. In order to These meters are available for OpenFlow based switches. In order to
enable these meters, each driver needs to be properly configured. enable these meters, each driver needs to be properly configured.
Load-Balancer-as-a-Service (LBaaS v1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following meters are collected for LBaaS v1:
+---------------+---------+---------+-----------+-----------+-----------------+
| Name | Type | Unit | Resource | Origin | Note |
+===============+=========+=========+===========+===========+=================+
| **Meters added in the Mitaka release or earlier** |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | pool | pool ID | Pollster | Existence of a |
| ices.lb.pool | | | | | LB pool |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | vip | vip ID | Pollster | Existence of a |
| ices.lb.vip | | | | | LB VIP |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | member | member ID | Pollster | Existence of a |
| ices.lb.memb\ | | | | | LB member |
| er | | | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | health\ | monitor ID| Pollster | Existence of a |
| ices.lb.heal\ | | _monit\ | | | LB health probe |
| th_monitor | | or | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Cumula\ | connec\ | pool ID | Pollster | Total connectio\|
| ices.lb.tota\ | tive | tion | | | ns on a LB |
| l.connections | | | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | connec\ | pool ID | Pollster | Active connecti\|
| ices.lb.acti\ | | tion | | | ons on a LB |
| ve.connections| | | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | B | pool ID | Pollster | Number of incom\|
| ices.lb.inco\ | | | | | ing Bytes |
| ming.bytes | | | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | B | pool ID | Pollster | Number of outgo\|
| ices.lb.outg\ | | | | | ing Bytes |
| oing.bytes | | | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
Load-Balancer-as-a-Service (LBaaS v2)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following meters are collected for LBaaS v2.
+---------------+---------+---------+-----------+-----------+-----------------+
| Name | Type | Unit | Resource | Origin | Note |
+===============+=========+=========+===========+===========+=================+
| **Meters added in the Mitaka release or earlier** |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | pool | pool ID | Pollster | Existence of a |
| ices.lb.pool | | | | | LB pool |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | listen\ | listener | Pollster | Existence of a |
| ices.lb.list\ | | er | ID | | LB listener |
| ener | | | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | member | member ID | Pollster | Existence of a |
| ices.lb.memb\ | | | | | LB member |
| er | | | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | health\ | monitor ID| Pollster | Existence of a |
| ices.lb.heal\ | | _monit\ | | | LB health probe |
| th_monitor | | or | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | loadba\ | loadbala\ | Pollster | Existence of a |
| ices.lb.load\ | | lancer | ncer ID | | LB loadbalancer |
| balancer | | | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Cumula\ | connec\ | pool ID | Pollster | Total connectio\|
| ices.lb.tota\ | tive | tion | | | ns on a LB |
| l.connections | | | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | connec\ | pool ID | Pollster | Active connecti\|
| ices.lb.acti\ | | tion | | | ons on a LB |
| ve.connections| | | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | B | pool ID | Pollster | Number of incom\|
| ices.lb.inco\ | | | | | ing Bytes |
| ming.bytes | | | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
| network.serv\ | Gauge | B | pool ID | Pollster | Number of outgo\|
| ices.lb.outg\ | | | | | ing Bytes |
| oing.bytes | | | | | |
+---------------+---------+---------+-----------+-----------+-----------------+
.. note::
The above meters are experimental and may generate a large load against the
Neutron APIs. The future enhancement will be implemented when Neutron
supports the new APIs.
VPN-as-a-Service (VPNaaS) VPN-as-a-Service (VPNaaS)
~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1,265 +0,0 @@
metric:
# LBaaS V2
- name: "loadbalancer.create"
event_type:
- "loadbalancer.create.end"
type: "delta"
unit: "loadbalancer"
volume: 1
resource_id: $.payload.loadbalancer.id
project_id: $.payload.loadbalancer.tenant_id
metadata:
name: $.payload.loadbalancer.name
description: $.payload.loadbalancer.description
listeners: $.payload.loadbalancer.listeners
operating_status: $.payload.loadbalancer.operating_status
vip_address: $.payload.loadbalancer.vip_address
vip_subnet_id: $.payload.loadbalancer.vip_subnet_id
admin_state_up: $.payload.loadbalancer.admin_state_up
- name: "loadbalancer.update"
event_type:
- "loadbalancer.update.end"
type: "delta"
unit: "loadbalancer"
volume: 1
resource_id: $.payload.loadbalancer.id
project_id: $.payload.loadbalancer.tenant_id
metadata:
name: $.payload.loadbalancer.name
description: $.payload.loadbalancer.description
listeners: $.payload.loadbalancer.listeners
operating_status: $.payload.loadbalancer.operating_status
vip_address: $.payload.loadbalancer.vip_address
vip_subnet_id: $.payload.loadbalancer.vip_subnet_id
admin_state_up: $.payload.loadbalancer.admin_state_up
- name: "loadbalancer.delete"
event_type:
- "loadbalancer.delete.end"
type: "delta"
unit: "loadbalancer"
volume: 1
resource_id: $.payload.loadbalancer.id
project_id: $.payload.loadbalancer.tenant_id
metadata:
name: $.payload.loadbalancer.name
description: $.payload.loadbalancer.description
listeners: $.payload.loadbalancer.listeners
operating_status: $.payload.loadbalancer.operating_status
vip_address: $.payload.loadbalancer.vip_address
vip_subnet_id: $.payload.loadbalancer.vip_subnet_id
admin_state_up: $.payload.loadbalancer.admin_state_up
- name: "listener.create"
event_type:
- "listener.create.end"
type: "delta"
unit: "listener"
volume: 1
resource_id: $.payload.listener.id
project_id: $.payload.listener.tenant_id
metadata:
name: $.payload.listener.name
description: $.payload.listener.description
admin_state_up: $.payload.listener.admin_state_up
loadbalancers: $.payload.listener.loadbalancers
default_pool_id: $.payload.listener.default_pool_id
protocol: $.payload.listener.protocol
connection_limit: $.payload.listener.connection_limit
- name: "listener.update"
event_type:
- "listener.update.end"
type: "delta"
unit: "listener"
volume: 1
resource_id: $.payload.listener.id
project_id: $.payload.listener.tenant_id
metadata:
name: $.payload.listener.name
description: $.payload.listener.description
admin_state_up: $.payload.listener.admin_state_up
loadbalancers: $.payload.listener.loadbalancers
default_pool_id: $.payload.listener.default_pool_id
protocol: $.payload.listener.protocol
connection_limit: $.payload.listener.connection_limit
- name: "listener.delete"
event_type:
- "listener.delete.end"
type: "delta"
unit: "listener"
volume: 1
resource_id: $.payload.listener.id
project_id: $.payload.listener.tenant_id
metadata:
name: $.payload.listener.name
description: $.payload.listener.description
admin_state_up: $.payload.listener.admin_state_up
loadbalancers: $.payload.listener.loadbalancers
default_pool_id: $.payload.listener.default_pool_id
protocol: $.payload.listener.protocol
connection_limit: $.payload.listener.connection_limit
- name: "healthmonitor.create"
event_type:
- "healthmonitor.create.end"
type: "delta"
unit: "healthmonitor"
volume: 1
resource_id: $.payload.healthmonitor.id
project_id: $.payload.healthmonitor.tenant_id
metadata:
name: $.payload.healthmonitor.name
description: $.payload.healthmonitor.description
admin_state_up: $.payload.healthmonitor.admin_state_up
max_retries: $.payload.healthmonitor.max_retries
delay: $.payload.healthmonitor.delay
timeout: $.payload.healthmonitor.timeout
pools: $.payload.healthmonitor.pools
type: $.payload.healthmonitor.type
- name: "healthmonitor.update"
event_type:
- "healthmonitor.update.end"
type: "delta"
unit: "healthmonitor"
volume: 1
resource_id: $.payload.healthmonitor.id
project_id: $.payload.healthmonitor.tenant_id
metadata:
name: $.payload.healthmonitor.name
description: $.payload.healthmonitor.description
admin_state_up: $.payload.healthmonitor.admin_state_up
max_retries: $.payload.healthmonitor.max_retries
delay: $.payload.healthmonitor.delay
timeout: $.payload.healthmonitor.timeout
pools: $.payload.healthmonitor.pools
type: $.payload.healthmonitor.type
- name: "healthmonitor.delete"
event_type:
- "healthmonitor.delete.end"
type: "delta"
unit: "healthmonitor"
volume: 1
resource_id: $.payload.healthmonitor.id
project_id: $.payload.healthmonitor.tenant_id
metadata:
name: $.payload.healthmonitor.name
description: $.payload.healthmonitor.description
admin_state_up: $.payload.healthmonitor.admin_state_up
max_retries: $.payload.healthmonitor.max_retries
delay: $.payload.healthmonitor.delay
timeout: $.payload.healthmonitor.timeout
pools: $.payload.healthmonitor.pools
type: $.payload.healthmonitor.type
- name: "pool.create"
event_type:
- "pool.create.end"
type: "delta"
unit: "pool"
volume: 1
resource_id: $.payload.pool.id
project_id: $.payload.pool.tenant_id
metadata:
name: $.payload.pool.name
description: $.payload.pool.description
admin_state_up: $.payload.pool.admin_state_up
lb_method: $.payload.pool.lb_method
protocol: $.payload.pool.protocol
subnet_id: $.payload.pool.subnet_id
vip_id: $.payload.pool.vip_id
status: $.payload.pool.status
status_description: $.payload.pool.status_description
- name: "pool.update"
event_type:
- "pool.update.end"
type: "delta"
unit: "pool"
volume: 1
resource_id: $.payload.pool.id
project_id: $.payload.pool.tenant_id
metadata:
name: $.payload.pool.name
description: $.payload.pool.description
admin_state_up: $.payload.pool.admin_state_up
lb_method: $.payload.pool.lb_method
protocol: $.payload.pool.protocol
subnet_id: $.payload.pool.subnet_id
vip_id: $.payload.pool.vip_id
status: $.payload.pool.status
status_description: $.payload.pool.status_description
- name: "pool.delete"
event_type:
- "pool.delete.end"
type: "delta"
unit: "pool"
volume: 1
resource_id: $.payload.pool.id
project_id: $.payload.pool.tenant_id
metadata:
name: $.payload.pool.name
description: $.payload.pool.description
admin_state_up: $.payload.pool.admin_state_up
lb_method: $.payload.pool.lb_method
protocol: $.payload.pool.protocol
subnet_id: $.payload.pool.subnet_id
vip_id: $.payload.pool.vip_id
status: $.payload.pool.status
status_description: $.payload.pool.status_description
- name: "member.create"
event_type:
- "member.create.end"
type: "delta"
unit: "member"
volume: 1
resource_id: $.payload.member.id
project_id: $.payload.member.tenant_id
metadata:
address: $.payload.member.address
status: $.payload.member.status
status_description: $.payload.member.status_description
weight: $.payload.member.weight
admin_state_up: $.payload.member.admin_state_up
protocol_port: $.payload.member.protocol_port
pool_id: $.payload.member.pool_id
- name: "member.update"
event_type:
- "member.update.end"
type: "delta"
unit: "member"
volume: 1
resource_id: $.payload.member.id
project_id: $.payload.member.tenant_id
metadata:
address: $.payload.member.address
status: $.payload.member.status
status_description: $.payload.member.status_description
weight: $.payload.member.weight
admin_state_up: $.payload.member.admin_state_up
protocol_port: $.payload.member.protocol_port
pool_id: $.payload.member.pool_id
- name: "member.delete"
event_type:
- "member.delete.end"
type: "delta"
unit: "member"
volume: 1
resource_id: $.payload.member.id
project_id: $.payload.member.tenant_id
metadata:
address: $.payload.member.address
status: $.payload.member.status
status_description: $.payload.member.status_description
weight: $.payload.member.weight
admin_state_up: $.payload.member.admin_state_up
protocol_port: $.payload.member.protocol_port
pool_id: $.payload.member.pool_id

View File

@ -0,0 +1,4 @@
---
upgrade:
- |
Support for neutron-lbaas resources has been removed.

View File

@ -52,12 +52,6 @@ ceilometer.discover.central =
barbican = ceilometer.polling.discovery.non_openstack_credentials_discovery:NonOpenStackCredentialsDiscovery barbican = ceilometer.polling.discovery.non_openstack_credentials_discovery:NonOpenStackCredentialsDiscovery
endpoint = ceilometer.polling.discovery.endpoint:EndpointDiscovery endpoint = ceilometer.polling.discovery.endpoint:EndpointDiscovery
tenant = ceilometer.polling.discovery.tenant:TenantDiscovery tenant = ceilometer.polling.discovery.tenant:TenantDiscovery
lb_pools = ceilometer.network.services.discovery:LBPoolsDiscovery
lb_vips = ceilometer.network.services.discovery:LBVipsDiscovery
lb_members = ceilometer.network.services.discovery:LBMembersDiscovery
lb_listeners = ceilometer.network.services.discovery:LBListenersDiscovery
lb_loadbalancers = ceilometer.network.services.discovery:LBLoadBalancersDiscovery
lb_health_probes = ceilometer.network.services.discovery:LBHealthMonitorsDiscovery
vpn_services = ceilometer.network.services.discovery:VPNServicesDiscovery vpn_services = ceilometer.network.services.discovery:VPNServicesDiscovery
ipsec_connections = ceilometer.network.services.discovery:IPSecConnectionsDiscovery ipsec_connections = ceilometer.network.services.discovery:IPSecConnectionsDiscovery
fw_services = ceilometer.network.services.discovery:FirewallDiscovery fw_services = ceilometer.network.services.discovery:FirewallDiscovery
@ -171,16 +165,6 @@ ceilometer.poll.central =
switch.flow.duration.nanoseconds = ceilometer.network.statistics.flow:FlowPollsterDurationNanoseconds switch.flow.duration.nanoseconds = ceilometer.network.statistics.flow:FlowPollsterDurationNanoseconds
switch.flow.duration.seconds = ceilometer.network.statistics.flow:FlowPollsterDurationSeconds switch.flow.duration.seconds = ceilometer.network.statistics.flow:FlowPollsterDurationSeconds
switch.flow.packets = ceilometer.network.statistics.flow:FlowPollsterPackets switch.flow.packets = ceilometer.network.statistics.flow:FlowPollsterPackets
network.services.lb.pool = ceilometer.network.services.lbaas:LBPoolPollster
network.services.lb.vip = ceilometer.network.services.lbaas:LBVipPollster
network.services.lb.member = ceilometer.network.services.lbaas:LBMemberPollster
network.services.lb.listener = ceilometer.network.services.lbaas:LBListenerPollster
network.services.lb.loadbalancer = ceilometer.network.services.lbaas:LBLoadBalancerPollster
network.services.lb.health_monitor = ceilometer.network.services.lbaas:LBHealthMonitorPollster
network.services.lb.total.connections = ceilometer.network.services.lbaas:LBTotalConnectionsPollster
network.services.lb.active.connections = ceilometer.network.services.lbaas:LBActiveConnectionsPollster
network.services.lb.incoming.bytes = ceilometer.network.services.lbaas:LBBytesInPollster
network.services.lb.outgoing.bytes = ceilometer.network.services.lbaas:LBBytesOutPollster
network.services.vpn = ceilometer.network.services.vpnaas:VPNServicesPollster network.services.vpn = ceilometer.network.services.vpnaas:VPNServicesPollster
network.services.vpn.connections = ceilometer.network.services.vpnaas:IPSecConnectionsPollster network.services.vpn.connections = ceilometer.network.services.vpnaas:IPSecConnectionsPollster
network.services.firewall = ceilometer.network.services.fwaas:FirewallPollster network.services.firewall = ceilometer.network.services.fwaas:FirewallPollster