Merge "Remove OpenContrail support"
This commit is contained in:
commit
a5457a7ad7
@ -151,36 +151,6 @@ resources_update_operations = [
|
||||
"max_length": 255,
|
||||
"required": True}}
|
||||
}]},
|
||||
{"desc": "add switch resource type",
|
||||
"type": "create_resource_type",
|
||||
"resource_type": "switch",
|
||||
"data": [{
|
||||
"attributes": {"controller": {"type": "string", "min_length": 0,
|
||||
"max_length": 255, "required": True}}
|
||||
}]},
|
||||
{"desc": "add switch_port resource type",
|
||||
"type": "create_resource_type",
|
||||
"resource_type": "switch_port",
|
||||
"data": [{
|
||||
"attributes": {"switch": {"type": "string", "min_length": 0,
|
||||
"max_length": 64, "required": True},
|
||||
"port_number_on_switch": {"type": "number", "min": 0,
|
||||
"max": 4294967295,
|
||||
"required": False},
|
||||
"neutron_port_id": {"type": "string",
|
||||
"min_length": 0,
|
||||
"max_length": 255,
|
||||
"required": False},
|
||||
"controller": {"type": "string", "min_length": 0,
|
||||
"max_length": 255, "required": True}}
|
||||
}]},
|
||||
{"desc": "add port resource type",
|
||||
"type": "create_resource_type",
|
||||
"resource_type": "port",
|
||||
"data": [{
|
||||
"attributes": {"controller": {"type": "string", "min_length": 0,
|
||||
"max_length": 255, "required": True}}
|
||||
}]},
|
||||
{"desc": "add volume provider resource type",
|
||||
"type": "create_resource_type",
|
||||
"resource_type": "volume_provider",
|
||||
|
@ -1,101 +0,0 @@
|
||||
#
|
||||
# Copyright 2014 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import abc
|
||||
|
||||
from oslo_utils import netutils
|
||||
from stevedore import driver as _driver
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from ceilometer.polling import plugin_base
|
||||
from ceilometer import sample
|
||||
|
||||
|
||||
class _Base(plugin_base.PollsterBase, metaclass=abc.ABCMeta):
|
||||
|
||||
NAMESPACE = 'network.statistics.drivers'
|
||||
drivers = {}
|
||||
|
||||
@property
|
||||
def default_discovery(self):
|
||||
# this signifies that the pollster gets its resources from
|
||||
# elsewhere, in this case they're manually listed in the
|
||||
# pipeline configuration
|
||||
return None
|
||||
|
||||
@property
|
||||
@abc.abstractmethod
|
||||
def meter_name(self):
|
||||
"""Return a Meter Name."""
|
||||
|
||||
@property
|
||||
@abc.abstractmethod
|
||||
def meter_type(self):
|
||||
"""Return a Meter Type."""
|
||||
|
||||
@property
|
||||
@abc.abstractmethod
|
||||
def meter_unit(self):
|
||||
"""Return a Meter Unit."""
|
||||
|
||||
@staticmethod
|
||||
def _parse_my_resource(resource):
|
||||
|
||||
parse_url = netutils.urlsplit(resource)
|
||||
|
||||
params = urlparse.parse_qs(parse_url.query)
|
||||
parts = urlparse.ParseResult(parse_url.scheme,
|
||||
parse_url.netloc,
|
||||
parse_url.path,
|
||||
None,
|
||||
None,
|
||||
None)
|
||||
return parts, params
|
||||
|
||||
@staticmethod
|
||||
def get_driver(conf, scheme):
|
||||
if scheme not in _Base.drivers:
|
||||
_Base.drivers[scheme] = _driver.DriverManager(_Base.NAMESPACE,
|
||||
scheme).driver(conf)
|
||||
return _Base.drivers[scheme]
|
||||
|
||||
def get_samples(self, manager, cache, resources):
|
||||
resources = resources or []
|
||||
for resource in resources:
|
||||
parse_url, params = self._parse_my_resource(resource)
|
||||
ext = self.get_driver(self.conf, parse_url.scheme)
|
||||
sample_data = ext.get_sample_data(self.meter_name,
|
||||
parse_url,
|
||||
params,
|
||||
cache)
|
||||
|
||||
for data in sample_data or []:
|
||||
if data is None:
|
||||
continue
|
||||
if not isinstance(data, list):
|
||||
data = [data]
|
||||
for (volume, resource_id,
|
||||
resource_metadata, project_id) in data:
|
||||
|
||||
yield sample.Sample(
|
||||
name=self.meter_name,
|
||||
type=self.meter_type,
|
||||
unit=self.meter_unit,
|
||||
volume=volume,
|
||||
user_id=None,
|
||||
project_id=project_id,
|
||||
resource_id=resource_id,
|
||||
resource_metadata=resource_metadata
|
||||
)
|
@ -1,28 +0,0 @@
|
||||
#
|
||||
# Copyright 2014 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import abc
|
||||
|
||||
|
||||
class Driver(object, metaclass=abc.ABCMeta):
|
||||
def __init__(self, conf):
|
||||
self.conf = conf
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_sample_data(self, meter_name, parse_url, params, cache):
|
||||
"""Return volume, resource_id, resource_metadata, timestamp in tuple.
|
||||
|
||||
If not implemented for meter_name, returns None
|
||||
"""
|
@ -1,121 +0,0 @@
|
||||
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# 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 copy
|
||||
|
||||
from oslo_log import log
|
||||
import requests
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from ceilometer.i18n import _
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class OpencontrailAPIFailed(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class AnalyticsAPIBaseClient(object):
|
||||
"""Opencontrail Base Statistics REST API Client."""
|
||||
|
||||
def __init__(self, conf, endpoint, data):
|
||||
self.conf = conf
|
||||
self.endpoint = endpoint
|
||||
self.data = data or {}
|
||||
|
||||
def request(self, path, fqdn_uuid, data=None):
|
||||
req_data = copy.copy(self.data)
|
||||
if data:
|
||||
req_data.update(data)
|
||||
|
||||
req_params = self._get_req_params(data=req_data)
|
||||
|
||||
url = urlparse.urljoin(self.endpoint, path + fqdn_uuid)
|
||||
self._log_req(url, req_params)
|
||||
resp = requests.get(url, **req_params)
|
||||
self._log_res(resp)
|
||||
|
||||
if resp.status_code != 200:
|
||||
raise OpencontrailAPIFailed(
|
||||
_('Opencontrail API returned %(status)s %(reason)s') %
|
||||
{'status': resp.status_code, 'reason': resp.reason})
|
||||
|
||||
return resp
|
||||
|
||||
def _get_req_params(self, data=None):
|
||||
req_params = {
|
||||
'headers': {
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
'data': data,
|
||||
'allow_redirects': False,
|
||||
'timeout': self.conf.http_timeout,
|
||||
}
|
||||
|
||||
return req_params
|
||||
|
||||
def _log_req(self, url, req_params):
|
||||
if not self.conf.debug:
|
||||
return
|
||||
|
||||
curl_command = ['REQ: curl -i -X GET ']
|
||||
|
||||
params = []
|
||||
for name, value in req_params['data'].items():
|
||||
params.append("%s=%s" % (name, value))
|
||||
|
||||
curl_command.append('"%s?%s" ' % (url, '&'.join(params)))
|
||||
|
||||
for name, value in req_params['headers'].items():
|
||||
curl_command.append('-H "%s: %s" ' % (name, value))
|
||||
|
||||
LOG.debug(''.join(curl_command))
|
||||
|
||||
def _log_res(self, resp):
|
||||
if not self.conf.debug:
|
||||
return
|
||||
|
||||
dump = ['RES: \n', 'HTTP %.1f %s %s\n' % (resp.raw.version,
|
||||
resp.status_code,
|
||||
resp.reason)]
|
||||
dump.extend('%s: %s\n' % (k, v)
|
||||
for k, v in resp.headers.items())
|
||||
dump.append('\n')
|
||||
if resp.content:
|
||||
dump.extend([resp.content, '\n'])
|
||||
|
||||
LOG.debug(''.join(dump))
|
||||
|
||||
|
||||
class NetworksAPIClient(AnalyticsAPIBaseClient):
|
||||
"""Opencontrail Statistics REST API Client."""
|
||||
|
||||
def get_vm_statistics(self, fqdn_uuid, data=None):
|
||||
"""Get statistics of a virtual-machines.
|
||||
|
||||
URL:
|
||||
{endpoint}/analytics/uves/virtual-machine/{fqdn_uuid}
|
||||
"""
|
||||
|
||||
path = '/analytics/uves/virtual-machine/'
|
||||
resp = self.request(path, fqdn_uuid, data)
|
||||
|
||||
return resp.json()
|
||||
|
||||
|
||||
class Client(object):
|
||||
def __init__(self, conf, endpoint, data=None):
|
||||
self.networks = NetworksAPIClient(conf, endpoint, data)
|
@ -1,204 +0,0 @@
|
||||
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# 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 re
|
||||
import warnings
|
||||
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from ceilometer.network.statistics import driver
|
||||
from ceilometer.network.statistics.opencontrail import client
|
||||
from ceilometer import neutron_client
|
||||
|
||||
|
||||
class OpencontrailDriver(driver.Driver):
|
||||
"""Driver of network analytics of Opencontrail.
|
||||
|
||||
This driver uses resources in "pipeline.yaml".
|
||||
|
||||
Resource requires below conditions:
|
||||
|
||||
* resource is url
|
||||
* scheme is "opencontrail"
|
||||
|
||||
This driver can be configured via query parameters.
|
||||
Supported parameters:
|
||||
|
||||
* scheme:
|
||||
The scheme of request url to Opencontrail Analytics endpoint.
|
||||
(default "http")
|
||||
* virtual_network
|
||||
Specify the virtual network.
|
||||
(default None)
|
||||
* fqdn_uuid:
|
||||
Specify the VM fqdn UUID.
|
||||
(default "*")
|
||||
* resource:
|
||||
The resource on which the counters are retrieved.
|
||||
(default "if_stats_list")
|
||||
|
||||
* fip_stats_list:
|
||||
Traffic on floating ips
|
||||
* if_stats_list:
|
||||
Traffic on VM interfaces
|
||||
|
||||
e.g.::
|
||||
|
||||
opencontrail://localhost:8081/?resource=fip_stats_list&
|
||||
virtual_network=default-domain:openstack:public
|
||||
"""
|
||||
def __init__(self, conf):
|
||||
warnings.warn('Support for OpenContrail is deprecated.',
|
||||
category=DeprecationWarning, stacklevel=2)
|
||||
super(OpencontrailDriver, self).__init__(conf)
|
||||
|
||||
def _prepare_cache(self, endpoint, params, cache):
|
||||
|
||||
if 'network.statistics.opencontrail' in cache:
|
||||
return cache['network.statistics.opencontrail']
|
||||
|
||||
data = {
|
||||
'o_client': client.Client(self.conf, endpoint),
|
||||
'n_client': neutron_client.Client(self.conf)
|
||||
}
|
||||
|
||||
cache['network.statistics.opencontrail'] = data
|
||||
|
||||
return data
|
||||
|
||||
def get_sample_data(self, meter_name, parse_url, params, cache):
|
||||
|
||||
parts = urlparse.ParseResult(params.get('scheme', ['http'])[0],
|
||||
parse_url.netloc,
|
||||
parse_url.path,
|
||||
None,
|
||||
None,
|
||||
None)
|
||||
endpoint = urlparse.urlunparse(parts)
|
||||
|
||||
iter = self._get_iter(meter_name)
|
||||
if iter is None:
|
||||
# The extractor for this meter is not implemented or the API
|
||||
# doesn't have method to get this meter.
|
||||
return
|
||||
|
||||
extractor = self._get_extractor(meter_name)
|
||||
if extractor is None:
|
||||
# The extractor for this meter is not implemented or the API
|
||||
# doesn't have method to get this meter.
|
||||
return
|
||||
|
||||
data = self._prepare_cache(endpoint, params, cache)
|
||||
|
||||
ports = data['n_client'].port_get_all()
|
||||
ports_map = dict((port['id'], port) for port in ports)
|
||||
|
||||
resource = params.get('resource', ['if_stats_list'])[0]
|
||||
fqdn_uuid = params.get('fqdn_uuid', ['*'])[0]
|
||||
virtual_network = params.get('virtual_network', [None])[0]
|
||||
|
||||
statistics = data['o_client'].networks.get_vm_statistics(fqdn_uuid)
|
||||
if not statistics:
|
||||
return
|
||||
|
||||
for value in statistics['value']:
|
||||
for sample in iter(extractor, value, ports_map,
|
||||
resource, virtual_network):
|
||||
if sample is not None:
|
||||
yield sample + (None, )
|
||||
|
||||
def _get_iter(self, meter_name):
|
||||
if meter_name.startswith('switch.port'):
|
||||
return self._iter_port
|
||||
|
||||
def _get_extractor(self, meter_name):
|
||||
method_name = '_' + meter_name.replace('.', '_')
|
||||
return getattr(self, method_name, None)
|
||||
|
||||
@staticmethod
|
||||
def _explode_name(fq_name):
|
||||
m = re.match(
|
||||
"(?P<domain>[^:]+):(?P<project>.+):(?P<port_id>[^:]+)",
|
||||
fq_name)
|
||||
if not m:
|
||||
return
|
||||
return m.group('domain'), m.group('project'), m.group('port_id')
|
||||
|
||||
@staticmethod
|
||||
def _get_resource_meta(ports_map, stat, resource, network):
|
||||
if resource == 'fip_stats_list':
|
||||
if network and (network != stat['virtual_network']):
|
||||
return
|
||||
name = stat['iface_name']
|
||||
else:
|
||||
name = stat['name']
|
||||
|
||||
domain, project, port_id = OpencontrailDriver._explode_name(name)
|
||||
port = ports_map.get(port_id)
|
||||
|
||||
tenant_id = None
|
||||
network_id = None
|
||||
device_owner_id = None
|
||||
|
||||
if port:
|
||||
tenant_id = port['tenant_id']
|
||||
network_id = port['network_id']
|
||||
device_owner_id = port['device_id']
|
||||
|
||||
resource_meta = {'device_owner_id': device_owner_id,
|
||||
'network_id': network_id,
|
||||
'project_id': tenant_id,
|
||||
'project': project,
|
||||
'resource': resource,
|
||||
'domain': domain}
|
||||
|
||||
return port_id, resource_meta
|
||||
|
||||
@staticmethod
|
||||
def _iter_port(extractor, value, ports_map, resource,
|
||||
virtual_network=None):
|
||||
stats = value['value']['UveVirtualMachineAgent'].get(resource, [])
|
||||
for stat in stats:
|
||||
if type(stat) is list:
|
||||
for sub_stats, node in zip(*[iter(stat)] * 2):
|
||||
for sub_stat in sub_stats:
|
||||
result = OpencontrailDriver._get_resource_meta(
|
||||
ports_map, sub_stat, resource, virtual_network)
|
||||
if not result:
|
||||
continue
|
||||
port_id, resource_meta = result
|
||||
yield extractor(sub_stat, port_id, resource_meta)
|
||||
else:
|
||||
result = OpencontrailDriver._get_resource_meta(
|
||||
ports_map, stat, resource, virtual_network)
|
||||
if not result:
|
||||
continue
|
||||
port_id, resource_meta = result
|
||||
yield extractor(stat, port_id, resource_meta)
|
||||
|
||||
@staticmethod
|
||||
def _switch_port_receive_packets(statistic, resource_id, resource_meta):
|
||||
return int(statistic['in_pkts']), resource_id, resource_meta
|
||||
|
||||
@staticmethod
|
||||
def _switch_port_transmit_packets(statistic, resource_id, resource_meta):
|
||||
return int(statistic['out_pkts']), resource_id, resource_meta
|
||||
|
||||
@staticmethod
|
||||
def _switch_port_receive_bytes(statistic, resource_id, resource_meta):
|
||||
return int(statistic['in_bytes']), resource_id, resource_meta
|
||||
|
||||
@staticmethod
|
||||
def _switch_port_transmit_bytes(statistic, resource_id, resource_meta):
|
||||
return int(statistic['out_bytes']), resource_id, resource_meta
|
@ -1,60 +0,0 @@
|
||||
#
|
||||
# Copyright 2014 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
from ceilometer.network import statistics
|
||||
from ceilometer import sample
|
||||
|
||||
|
||||
class PortPollster(statistics._Base):
|
||||
|
||||
meter_name = 'switch.port'
|
||||
meter_type = sample.TYPE_GAUGE
|
||||
meter_unit = 'port'
|
||||
|
||||
|
||||
class PortPollsterUptime(statistics._Base):
|
||||
|
||||
meter_name = 'switch.port.uptime'
|
||||
meter_type = sample.TYPE_GAUGE
|
||||
meter_unit = 's'
|
||||
|
||||
|
||||
class PortPollsterReceivePackets(statistics._Base):
|
||||
|
||||
meter_name = 'switch.port.receive.packets'
|
||||
meter_type = sample.TYPE_CUMULATIVE
|
||||
meter_unit = 'packet'
|
||||
|
||||
|
||||
class PortPollsterTransmitPackets(statistics._Base):
|
||||
|
||||
meter_name = 'switch.port.transmit.packets'
|
||||
meter_type = sample.TYPE_CUMULATIVE
|
||||
meter_unit = 'packet'
|
||||
|
||||
|
||||
class PortPollsterReceiveBytes(statistics._Base):
|
||||
|
||||
meter_name = 'switch.port.receive.bytes'
|
||||
meter_type = sample.TYPE_CUMULATIVE
|
||||
meter_unit = 'B'
|
||||
|
||||
|
||||
class PortPollsterTransmitBytes(statistics._Base):
|
||||
|
||||
meter_name = 'switch.port.transmit.bytes'
|
||||
meter_type = sample.TYPE_CUMULATIVE
|
||||
meter_unit = 'B'
|
@ -1,74 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2017 Ericsson India Global Services Pvt Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
from ceilometer.network import statistics
|
||||
from ceilometer import sample
|
||||
|
||||
|
||||
class PortPollster(statistics._Base):
|
||||
|
||||
meter_name = 'port'
|
||||
meter_type = sample.TYPE_GAUGE
|
||||
meter_unit = 'port'
|
||||
|
||||
|
||||
class PortPollsterUptime(statistics._Base):
|
||||
|
||||
meter_name = 'port.uptime'
|
||||
meter_type = sample.TYPE_GAUGE
|
||||
meter_unit = 's'
|
||||
|
||||
|
||||
class PortPollsterReceivePackets(statistics._Base):
|
||||
|
||||
meter_name = 'port.receive.packets'
|
||||
meter_type = sample.TYPE_CUMULATIVE
|
||||
meter_unit = 'packet'
|
||||
|
||||
|
||||
class PortPollsterTransmitPackets(statistics._Base):
|
||||
|
||||
meter_name = 'port.transmit.packets'
|
||||
meter_type = sample.TYPE_CUMULATIVE
|
||||
meter_unit = 'packet'
|
||||
|
||||
|
||||
class PortPollsterReceiveBytes(statistics._Base):
|
||||
|
||||
meter_name = 'port.receive.bytes'
|
||||
meter_type = sample.TYPE_CUMULATIVE
|
||||
meter_unit = 'B'
|
||||
|
||||
|
||||
class PortPollsterTransmitBytes(statistics._Base):
|
||||
|
||||
meter_name = 'port.transmit.bytes'
|
||||
meter_type = sample.TYPE_CUMULATIVE
|
||||
meter_unit = 'B'
|
||||
|
||||
|
||||
class PortPollsterReceiveDrops(statistics._Base):
|
||||
|
||||
meter_name = 'port.receive.drops'
|
||||
meter_type = sample.TYPE_CUMULATIVE
|
||||
meter_unit = 'packet'
|
||||
|
||||
|
||||
class PortPollsterReceiveErrors(statistics._Base):
|
||||
|
||||
meter_name = 'port.receive.errors'
|
||||
meter_type = sample.TYPE_CUMULATIVE
|
||||
meter_unit = 'packet'
|
@ -1,32 +0,0 @@
|
||||
#
|
||||
# Copyright 2014 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
from ceilometer.network import statistics
|
||||
from ceilometer import sample
|
||||
|
||||
|
||||
class SWPollster(statistics._Base):
|
||||
|
||||
meter_name = 'switch'
|
||||
meter_type = sample.TYPE_GAUGE
|
||||
meter_unit = 'switch'
|
||||
|
||||
|
||||
class SwitchPollsterPorts(statistics._Base):
|
||||
|
||||
meter_name = 'switch.ports'
|
||||
meter_type = sample.TYPE_GAUGE
|
||||
meter_unit = 'ports'
|
@ -299,37 +299,3 @@ resources:
|
||||
status: resource_metadata.status
|
||||
availability_zone: resource_metadata.availability_zone
|
||||
protocol: resource_metadata.protocol
|
||||
|
||||
- resource_type: switch
|
||||
metrics:
|
||||
switch:
|
||||
switch.ports:
|
||||
attributes:
|
||||
controller: resource_metadata.controller
|
||||
|
||||
- resource_type: switch_port
|
||||
metrics:
|
||||
switch.port:
|
||||
switch.port.uptime:
|
||||
switch.port.receive.packets:
|
||||
switch.port.transmit.packets:
|
||||
switch.port.receive.bytes:
|
||||
switch.port.transmit.bytes:
|
||||
attributes:
|
||||
switch: resource_metadata.switch
|
||||
port_number_on_switch: resource_metadata.port_number_on_switch
|
||||
neutron_port_id: resource_metadata.neutron_port_id
|
||||
controller: resource_metadata.controller
|
||||
|
||||
- resource_type: port
|
||||
metrics:
|
||||
port:
|
||||
port.uptime:
|
||||
port.receive.packets:
|
||||
port.transmit.packets:
|
||||
port.receive.bytes:
|
||||
port.transmit.bytes:
|
||||
port.receive.drops:
|
||||
port.receive.errors:
|
||||
attributes:
|
||||
controller: resource_metadata.controller
|
||||
|
@ -1,33 +0,0 @@
|
||||
#
|
||||
# Copyright 2014 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslotest import base
|
||||
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
class _PollsterTestBase(base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(_PollsterTestBase, self).setUp()
|
||||
self.CONF = service.prepare_service([], [])
|
||||
|
||||
def _test_pollster(self, pollster_class, meter_name,
|
||||
meter_type, meter_unit):
|
||||
|
||||
pollster = pollster_class(self.CONF)
|
||||
|
||||
self.assertEqual(pollster.meter_name, meter_name)
|
||||
self.assertEqual(pollster.meter_type, meter_type)
|
||||
self.assertEqual(pollster.meter_unit, meter_unit)
|
@ -1,73 +0,0 @@
|
||||
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# 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 oslo_config import fixture as config_fixture
|
||||
from oslotest import base
|
||||
|
||||
from ceilometer.network.statistics.opencontrail import client
|
||||
from ceilometer import service as ceilometer_service
|
||||
|
||||
|
||||
class TestOpencontrailClient(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestOpencontrailClient, self).setUp()
|
||||
conf = ceilometer_service.prepare_service(argv=[], config_files=[])
|
||||
self.CONF = self.useFixture(config_fixture.Config(conf)).conf
|
||||
self.client = client.Client(self.CONF, 'http://127.0.0.1:8081',
|
||||
{'arg1': 'aaa'})
|
||||
|
||||
self.get_resp = mock.MagicMock()
|
||||
self.get = mock.patch('requests.get',
|
||||
return_value=self.get_resp).start()
|
||||
self.get_resp.raw.version = 1.1
|
||||
self.get_resp.status_code = 200
|
||||
self.get_resp.reason = 'OK'
|
||||
self.get_resp.content = ''
|
||||
|
||||
def test_vm_statistics(self):
|
||||
self.client.networks.get_vm_statistics('bbb')
|
||||
|
||||
call_args = self.get.call_args_list[0][0]
|
||||
call_kwargs = self.get.call_args_list[0][1]
|
||||
|
||||
expected_url = ('http://127.0.0.1:8081/analytics/'
|
||||
'uves/virtual-machine/bbb')
|
||||
self.assertEqual(expected_url, call_args[0])
|
||||
|
||||
data = call_kwargs.get('data')
|
||||
|
||||
expected_data = {'arg1': 'aaa'}
|
||||
self.assertEqual(expected_data, data)
|
||||
|
||||
def test_vm_statistics_params(self):
|
||||
self.client.networks.get_vm_statistics('bbb',
|
||||
{'resource': 'fip_stats_list',
|
||||
'virtual_network': 'ccc'})
|
||||
|
||||
call_args = self.get.call_args_list[0][0]
|
||||
call_kwargs = self.get.call_args_list[0][1]
|
||||
|
||||
expected_url = ('http://127.0.0.1:8081/analytics/'
|
||||
'uves/virtual-machine/bbb')
|
||||
self.assertEqual(expected_url, call_args[0])
|
||||
|
||||
data = call_kwargs.get('data')
|
||||
|
||||
expected_data = {'arg1': 'aaa',
|
||||
'resource': 'fip_stats_list',
|
||||
'virtual_network': 'ccc'}
|
||||
self.assertEqual(expected_data, data)
|
@ -1,267 +0,0 @@
|
||||
# Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# 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 oslotest import base
|
||||
from urllib import parse as urlparse
|
||||
|
||||
from ceilometer.network.statistics.opencontrail import driver
|
||||
from ceilometer import service
|
||||
|
||||
|
||||
class TestOpencontrailDriver(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestOpencontrailDriver, self).setUp()
|
||||
|
||||
self.nc_ports = mock.patch('ceilometer.neutron_client'
|
||||
'.Client.port_get_all',
|
||||
return_value=self.fake_ports())
|
||||
self.nc_ports.start()
|
||||
|
||||
self.CONF = service.prepare_service([], [])
|
||||
self.driver = driver.OpencontrailDriver(self.CONF)
|
||||
self.parse_url = urlparse.ParseResult('opencontrail',
|
||||
'127.0.0.1:8143',
|
||||
'/', None, None, None)
|
||||
self.params = {'password': ['admin'],
|
||||
'scheme': ['http'],
|
||||
'username': ['admin'],
|
||||
'verify_ssl': ['false'],
|
||||
'resource': ['if_stats_list']}
|
||||
|
||||
@staticmethod
|
||||
def fake_ports():
|
||||
return [{'admin_state_up': True,
|
||||
'device_owner': 'compute:None',
|
||||
'device_id': '674e553b-8df9-4321-87d9-93ba05b93558',
|
||||
'extra_dhcp_opts': [],
|
||||
'id': '96d49cc3-4e01-40ce-9cac-c0e32642a442',
|
||||
'mac_address': 'fa:16:3e:c5:35:93',
|
||||
'name': '',
|
||||
'network_id': '298a3088-a446-4d5a-bad8-f92ecacd786b',
|
||||
'status': 'ACTIVE',
|
||||
'tenant_id': '89271fa581ab4380bf172f868c3615f9'}]
|
||||
|
||||
@staticmethod
|
||||
def fake_port_stats():
|
||||
return {"value": [{
|
||||
"name": "c588ebb7-ae52-485a-9f0c-b2791c5da196",
|
||||
"value": {
|
||||
"UveVirtualMachineAgent": {
|
||||
"if_stats_list": [{
|
||||
"out_bytes": 22,
|
||||
"in_bandwidth_usage": 0,
|
||||
"in_bytes": 23,
|
||||
"out_bandwidth_usage": 0,
|
||||
"out_pkts": 5,
|
||||
"in_pkts": 6,
|
||||
"name": ("default-domain:demo:"
|
||||
"96d49cc3-4e01-40ce-9cac-c0e32642a442")
|
||||
}],
|
||||
"fip_stats_list": [{
|
||||
"in_bytes": 33,
|
||||
"iface_name": ("default-domain:demo:"
|
||||
"96d49cc3-4e01-40ce-9cac-c0e32642a442"),
|
||||
"out_bytes": 44,
|
||||
"out_pkts": 10,
|
||||
"virtual_network": "default-domain:openstack:public",
|
||||
"in_pkts": 11,
|
||||
"ip_address": "1.1.1.1"
|
||||
}]
|
||||
}}}]}
|
||||
|
||||
@staticmethod
|
||||
def fake_port_stats_with_node():
|
||||
return {"value": [{
|
||||
"name": "c588ebb7-ae52-485a-9f0c-b2791c5da196",
|
||||
"value": {
|
||||
"UveVirtualMachineAgent": {
|
||||
"if_stats_list": [
|
||||
[[{
|
||||
"out_bytes": 22,
|
||||
"in_bandwidth_usage": 0,
|
||||
"in_bytes": 23,
|
||||
"out_bandwidth_usage": 0,
|
||||
"out_pkts": 5,
|
||||
"in_pkts": 6,
|
||||
"name": ("default-domain:demo:"
|
||||
"96d49cc3-4e01-40ce-9cac-c0e32642a442")
|
||||
}], 'node1'],
|
||||
[[{
|
||||
"out_bytes": 22,
|
||||
"in_bandwidth_usage": 0,
|
||||
"in_bytes": 23,
|
||||
"out_bandwidth_usage": 0,
|
||||
"out_pkts": 4,
|
||||
"in_pkts": 13,
|
||||
"name": ("default-domain:demo:"
|
||||
"96d49cc3-4e01-40ce-9cac-c0e32642a442")}],
|
||||
'node2']
|
||||
]
|
||||
}}}]}
|
||||
|
||||
def _test_meter(self, meter_name, expected, fake_port_stats=None):
|
||||
if not fake_port_stats:
|
||||
fake_port_stats = self.fake_port_stats()
|
||||
with mock.patch('ceilometer.network.'
|
||||
'statistics.opencontrail.'
|
||||
'client.NetworksAPIClient.'
|
||||
'get_vm_statistics',
|
||||
return_value=fake_port_stats) as port_stats:
|
||||
|
||||
samples = self.driver.get_sample_data(meter_name, self.parse_url,
|
||||
self.params, {})
|
||||
|
||||
self.assertEqual(expected, [s for s in samples])
|
||||
|
||||
port_stats.assert_called_with('*')
|
||||
|
||||
def test_switch_port_receive_packets_with_node(self):
|
||||
expected = [(6,
|
||||
'96d49cc3-4e01-40ce-9cac-c0e32642a442',
|
||||
{'device_owner_id':
|
||||
'674e553b-8df9-4321-87d9-93ba05b93558',
|
||||
'domain': 'default-domain',
|
||||
'network_id': '298a3088-a446-4d5a-bad8-f92ecacd786b',
|
||||
'project': 'demo',
|
||||
'project_id': '89271fa581ab4380bf172f868c3615f9',
|
||||
'resource': 'if_stats_list'},
|
||||
None),
|
||||
(13,
|
||||
'96d49cc3-4e01-40ce-9cac-c0e32642a442',
|
||||
{'device_owner_id':
|
||||
'674e553b-8df9-4321-87d9-93ba05b93558',
|
||||
'domain': 'default-domain',
|
||||
'network_id': '298a3088-a446-4d5a-bad8-f92ecacd786b',
|
||||
'project': 'demo',
|
||||
'project_id': '89271fa581ab4380bf172f868c3615f9',
|
||||
'resource': 'if_stats_list'},
|
||||
None)]
|
||||
self._test_meter('switch.port.receive.packets', expected,
|
||||
self.fake_port_stats_with_node())
|
||||
|
||||
def test_switch_port_receive_packets(self):
|
||||
expected = [(6,
|
||||
'96d49cc3-4e01-40ce-9cac-c0e32642a442',
|
||||
{'device_owner_id':
|
||||
'674e553b-8df9-4321-87d9-93ba05b93558',
|
||||
'domain': 'default-domain',
|
||||
'network_id': '298a3088-a446-4d5a-bad8-f92ecacd786b',
|
||||
'project': 'demo',
|
||||
'project_id': '89271fa581ab4380bf172f868c3615f9',
|
||||
'resource': 'if_stats_list'},
|
||||
None)]
|
||||
self._test_meter('switch.port.receive.packets', expected)
|
||||
|
||||
def test_switch_port_transmit_packets(self):
|
||||
expected = [(5,
|
||||
'96d49cc3-4e01-40ce-9cac-c0e32642a442',
|
||||
{'device_owner_id':
|
||||
'674e553b-8df9-4321-87d9-93ba05b93558',
|
||||
'domain': 'default-domain',
|
||||
'network_id': '298a3088-a446-4d5a-bad8-f92ecacd786b',
|
||||
'project': 'demo',
|
||||
'project_id': '89271fa581ab4380bf172f868c3615f9',
|
||||
'resource': 'if_stats_list'},
|
||||
None)]
|
||||
self._test_meter('switch.port.transmit.packets', expected)
|
||||
|
||||
def test_switch_port_receive_bytes(self):
|
||||
expected = [(23,
|
||||
'96d49cc3-4e01-40ce-9cac-c0e32642a442',
|
||||
{'device_owner_id':
|
||||
'674e553b-8df9-4321-87d9-93ba05b93558',
|
||||
'domain': 'default-domain',
|
||||
'network_id': '298a3088-a446-4d5a-bad8-f92ecacd786b',
|
||||
'project': 'demo',
|
||||
'project_id': '89271fa581ab4380bf172f868c3615f9',
|
||||
'resource': 'if_stats_list'},
|
||||
None)]
|
||||
self._test_meter('switch.port.receive.bytes', expected)
|
||||
|
||||
def test_switch_port_transmit_bytes(self):
|
||||
expected = [(22,
|
||||
'96d49cc3-4e01-40ce-9cac-c0e32642a442',
|
||||
{'device_owner_id':
|
||||
'674e553b-8df9-4321-87d9-93ba05b93558',
|
||||
'domain': 'default-domain',
|
||||
'network_id': '298a3088-a446-4d5a-bad8-f92ecacd786b',
|
||||
'project': 'demo',
|
||||
'project_id': '89271fa581ab4380bf172f868c3615f9',
|
||||
'resource': 'if_stats_list'},
|
||||
None)]
|
||||
self._test_meter('switch.port.transmit.bytes', expected)
|
||||
|
||||
def test_switch_port_receive_packets_fip(self):
|
||||
self.params['resource'] = ['fip_stats_list']
|
||||
expected = [(11,
|
||||
'96d49cc3-4e01-40ce-9cac-c0e32642a442',
|
||||
{'device_owner_id':
|
||||
'674e553b-8df9-4321-87d9-93ba05b93558',
|
||||
'domain': 'default-domain',
|
||||
'network_id': '298a3088-a446-4d5a-bad8-f92ecacd786b',
|
||||
'project': 'demo',
|
||||
'project_id': '89271fa581ab4380bf172f868c3615f9',
|
||||
'resource': 'fip_stats_list'},
|
||||
None)]
|
||||
self._test_meter('switch.port.receive.packets', expected)
|
||||
|
||||
def test_switch_port_transmit_packets_fip(self):
|
||||
self.params['resource'] = ['fip_stats_list']
|
||||
expected = [(10,
|
||||
'96d49cc3-4e01-40ce-9cac-c0e32642a442',
|
||||
{'device_owner_id':
|
||||
'674e553b-8df9-4321-87d9-93ba05b93558',
|
||||
'domain': 'default-domain',
|
||||
'network_id': '298a3088-a446-4d5a-bad8-f92ecacd786b',
|
||||
'project': 'demo',
|
||||
'project_id': '89271fa581ab4380bf172f868c3615f9',
|
||||
'resource': 'fip_stats_list'},
|
||||
None)]
|
||||
self._test_meter('switch.port.transmit.packets', expected)
|
||||
|
||||
def test_switch_port_receive_bytes_fip(self):
|
||||
self.params['resource'] = ['fip_stats_list']
|
||||
expected = [(33,
|
||||
'96d49cc3-4e01-40ce-9cac-c0e32642a442',
|
||||
{'device_owner_id':
|
||||
'674e553b-8df9-4321-87d9-93ba05b93558',
|
||||
'domain': 'default-domain',
|
||||
'network_id': '298a3088-a446-4d5a-bad8-f92ecacd786b',
|
||||
'project': 'demo',
|
||||
'project_id': '89271fa581ab4380bf172f868c3615f9',
|
||||
'resource': 'fip_stats_list'},
|
||||
None)]
|
||||
self._test_meter('switch.port.receive.bytes', expected)
|
||||
|
||||
def test_switch_port_transmit_bytes_fip(self):
|
||||
self.params['resource'] = ['fip_stats_list']
|
||||
expected = [(44,
|
||||
'96d49cc3-4e01-40ce-9cac-c0e32642a442',
|
||||
{'device_owner_id':
|
||||
'674e553b-8df9-4321-87d9-93ba05b93558',
|
||||
'domain': 'default-domain',
|
||||
'network_id': '298a3088-a446-4d5a-bad8-f92ecacd786b',
|
||||
'project': 'demo',
|
||||
'project_id': '89271fa581ab4380bf172f868c3615f9',
|
||||
'resource': 'fip_stats_list'},
|
||||
None)]
|
||||
self._test_meter('switch.port.transmit.bytes', expected)
|
||||
|
||||
def test_switch_port_transmit_bytes_non_existing_network(self):
|
||||
self.params['virtual_network'] = ['aaa']
|
||||
self.params['resource'] = ['fip_stats_list']
|
||||
self._test_meter('switch.port.transmit.bytes', [])
|
@ -1,63 +0,0 @@
|
||||
#
|
||||
# Copyright 2014 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from ceilometer.network.statistics import port
|
||||
from ceilometer import sample
|
||||
from ceilometer.tests.unit.network import statistics
|
||||
|
||||
|
||||
class TestPortPollsters(statistics._PollsterTestBase):
|
||||
|
||||
def test_port_pollster(self):
|
||||
self._test_pollster(
|
||||
port.PortPollster,
|
||||
'switch.port',
|
||||
sample.TYPE_GAUGE,
|
||||
'port')
|
||||
|
||||
def test_port_pollster_uptime(self):
|
||||
self._test_pollster(
|
||||
port.PortPollsterUptime,
|
||||
'switch.port.uptime',
|
||||
sample.TYPE_GAUGE,
|
||||
's')
|
||||
|
||||
def test_port_pollster_receive_packets(self):
|
||||
self._test_pollster(
|
||||
port.PortPollsterReceivePackets,
|
||||
'switch.port.receive.packets',
|
||||
sample.TYPE_CUMULATIVE,
|
||||
'packet')
|
||||
|
||||
def test_port_pollster_transmit_packets(self):
|
||||
self._test_pollster(
|
||||
port.PortPollsterTransmitPackets,
|
||||
'switch.port.transmit.packets',
|
||||
sample.TYPE_CUMULATIVE,
|
||||
'packet')
|
||||
|
||||
def test_port_pollster_receive_bytes(self):
|
||||
self._test_pollster(
|
||||
port.PortPollsterReceiveBytes,
|
||||
'switch.port.receive.bytes',
|
||||
sample.TYPE_CUMULATIVE,
|
||||
'B')
|
||||
|
||||
def test_port_pollster_transmit_bytes(self):
|
||||
self._test_pollster(
|
||||
port.PortPollsterTransmitBytes,
|
||||
'switch.port.transmit.bytes',
|
||||
sample.TYPE_CUMULATIVE,
|
||||
'B')
|
@ -1,77 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2017 Ericsson India Global Services Pvt Ltd.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from ceilometer.network.statistics import port_v2
|
||||
from ceilometer import sample
|
||||
from ceilometer.tests.unit.network import statistics
|
||||
|
||||
|
||||
class TestPortPollsters(statistics._PollsterTestBase):
|
||||
|
||||
def test_port_pollster(self):
|
||||
self._test_pollster(
|
||||
port_v2.PortPollster,
|
||||
'port',
|
||||
sample.TYPE_GAUGE,
|
||||
'port')
|
||||
|
||||
def test_port_pollster_uptime(self):
|
||||
self._test_pollster(
|
||||
port_v2.PortPollsterUptime,
|
||||
'port.uptime',
|
||||
sample.TYPE_GAUGE,
|
||||
's')
|
||||
|
||||
def test_port_pollster_receive_packets(self):
|
||||
self._test_pollster(
|
||||
port_v2.PortPollsterReceivePackets,
|
||||
'port.receive.packets',
|
||||
sample.TYPE_CUMULATIVE,
|
||||
'packet')
|
||||
|
||||
def test_port_pollster_transmit_packets(self):
|
||||
self._test_pollster(
|
||||
port_v2.PortPollsterTransmitPackets,
|
||||
'port.transmit.packets',
|
||||
sample.TYPE_CUMULATIVE,
|
||||
'packet')
|
||||
|
||||
def test_port_pollster_receive_bytes(self):
|
||||
self._test_pollster(
|
||||
port_v2.PortPollsterReceiveBytes,
|
||||
'port.receive.bytes',
|
||||
sample.TYPE_CUMULATIVE,
|
||||
'B')
|
||||
|
||||
def test_port_pollster_transmit_bytes(self):
|
||||
self._test_pollster(
|
||||
port_v2.PortPollsterTransmitBytes,
|
||||
'port.transmit.bytes',
|
||||
sample.TYPE_CUMULATIVE,
|
||||
'B')
|
||||
|
||||
def test_port_pollster_receive_drops(self):
|
||||
self._test_pollster(
|
||||
port_v2.PortPollsterReceiveDrops,
|
||||
'port.receive.drops',
|
||||
sample.TYPE_CUMULATIVE,
|
||||
'packet')
|
||||
|
||||
def test_port_pollster_receive_errors(self):
|
||||
self._test_pollster(
|
||||
port_v2.PortPollsterReceiveErrors,
|
||||
'port.receive.errors',
|
||||
sample.TYPE_CUMULATIVE,
|
||||
'packet')
|
@ -1,200 +0,0 @@
|
||||
#
|
||||
# Copyright 2014 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import datetime
|
||||
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from oslotest import base
|
||||
|
||||
from ceilometer.network import statistics
|
||||
from ceilometer.network.statistics import driver
|
||||
from ceilometer import sample
|
||||
from ceilometer import service
|
||||
|
||||
PROJECT_ID = uuidutils.generate_uuid()
|
||||
|
||||
|
||||
class TestBase(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestBase, self).setUp()
|
||||
self.CONF = service.prepare_service([], [])
|
||||
|
||||
def test_subclass_ok(self):
|
||||
|
||||
class OkSubclass(statistics._Base):
|
||||
|
||||
meter_name = 'foo'
|
||||
meter_type = sample.TYPE_GAUGE
|
||||
meter_unit = 'B'
|
||||
|
||||
OkSubclass(self.CONF)
|
||||
|
||||
def test_subclass_ng(self):
|
||||
|
||||
class NgSubclass1(statistics._Base):
|
||||
"""meter_name is lost."""
|
||||
|
||||
meter_type = sample.TYPE_GAUGE
|
||||
meter_unit = 'B'
|
||||
|
||||
class NgSubclass2(statistics._Base):
|
||||
"""meter_type is lost."""
|
||||
|
||||
meter_name = 'foo'
|
||||
meter_unit = 'B'
|
||||
|
||||
class NgSubclass3(statistics._Base):
|
||||
"""meter_unit is lost."""
|
||||
|
||||
meter_name = 'foo'
|
||||
meter_type = sample.TYPE_GAUGE
|
||||
|
||||
self.assertRaises(TypeError, NgSubclass1, self.CONF)
|
||||
self.assertRaises(TypeError, NgSubclass2, self.CONF)
|
||||
self.assertRaises(TypeError, NgSubclass3, self.CONF)
|
||||
|
||||
|
||||
class TestBaseGetSamples(base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestBaseGetSamples, self).setUp()
|
||||
self.CONF = service.prepare_service([], [])
|
||||
|
||||
class FakePollster(statistics._Base):
|
||||
meter_name = 'foo'
|
||||
meter_type = sample.TYPE_CUMULATIVE
|
||||
meter_unit = 'bar'
|
||||
|
||||
self.pollster = FakePollster(self.CONF)
|
||||
|
||||
def tearDown(self):
|
||||
statistics._Base.drivers = {}
|
||||
super(TestBaseGetSamples, self).tearDown()
|
||||
|
||||
@staticmethod
|
||||
def _setup_ext_mgr(**drivers):
|
||||
statistics._Base.drivers = drivers
|
||||
|
||||
def _make_fake_driver(self, *return_values):
|
||||
class FakeDriver(driver.Driver):
|
||||
|
||||
def __init__(self, conf):
|
||||
super(FakeDriver, self).__init__(conf)
|
||||
self.index = 0
|
||||
|
||||
def get_sample_data(self, meter_name, parse_url, params, cache):
|
||||
if self.index >= len(return_values):
|
||||
yield None
|
||||
retval = return_values[self.index]
|
||||
self.index += 1
|
||||
yield retval
|
||||
return FakeDriver
|
||||
|
||||
@staticmethod
|
||||
def _make_timestamps(count):
|
||||
now = timeutils.utcnow()
|
||||
return [(now + datetime.timedelta(seconds=i)).isoformat()
|
||||
for i in range(count)]
|
||||
|
||||
def _get_samples(self, *resources):
|
||||
|
||||
return [v for v in self.pollster.get_samples(self, {}, resources)]
|
||||
|
||||
def _assert_sample(self, s, volume, resource_id, resource_metadata,
|
||||
project_id):
|
||||
self.assertEqual('foo', s.name)
|
||||
self.assertEqual(sample.TYPE_CUMULATIVE, s.type)
|
||||
self.assertEqual('bar', s.unit)
|
||||
self.assertEqual(volume, s.volume)
|
||||
self.assertIsNone(s.user_id)
|
||||
self.assertEqual(project_id, s.project_id)
|
||||
self.assertEqual(resource_id, s.resource_id)
|
||||
self.assertEqual(resource_metadata, s.resource_metadata)
|
||||
|
||||
def test_get_samples_one_driver_one_resource(self):
|
||||
fake_driver = self._make_fake_driver((1, 'a', {'spam': 'egg'},
|
||||
PROJECT_ID),
|
||||
(2, 'b', None, None))
|
||||
|
||||
self._setup_ext_mgr(http=fake_driver(self.CONF))
|
||||
|
||||
samples = self._get_samples('http://foo')
|
||||
|
||||
self.assertEqual(1, len(samples))
|
||||
self._assert_sample(samples[0], 1, 'a', {'spam': 'egg'}, PROJECT_ID)
|
||||
|
||||
def test_get_samples_one_driver_two_resource(self):
|
||||
fake_driver = self._make_fake_driver((1, 'a', {'spam': 'egg'},
|
||||
None),
|
||||
(2, 'b', None, None),
|
||||
(3, 'c', None, None))
|
||||
|
||||
self._setup_ext_mgr(http=fake_driver(self.CONF))
|
||||
|
||||
samples = self._get_samples('http://foo', 'http://bar')
|
||||
|
||||
self.assertEqual(2, len(samples))
|
||||
self._assert_sample(samples[0], 1, 'a', {'spam': 'egg'}, None)
|
||||
self._assert_sample(samples[1], 2, 'b', {}, None)
|
||||
|
||||
def test_get_samples_two_driver_one_resource(self):
|
||||
fake_driver1 = self._make_fake_driver((1, 'a', {'spam': 'egg'},
|
||||
None),
|
||||
(2, 'b', None, None))
|
||||
|
||||
fake_driver2 = self._make_fake_driver((11, 'A', None, None),
|
||||
(12, 'B', None, None))
|
||||
|
||||
self._setup_ext_mgr(http=fake_driver1(self.CONF),
|
||||
https=fake_driver2(self.CONF))
|
||||
|
||||
samples = self._get_samples('http://foo')
|
||||
|
||||
self.assertEqual(1, len(samples))
|
||||
self._assert_sample(samples[0], 1, 'a', {'spam': 'egg'}, None)
|
||||
|
||||
def test_get_samples_multi_samples(self):
|
||||
fake_driver = self._make_fake_driver([(1, 'a', {'spam': 'egg'},
|
||||
None),
|
||||
(2, 'b', None, None)])
|
||||
|
||||
self._setup_ext_mgr(http=fake_driver(self.CONF))
|
||||
|
||||
samples = self._get_samples('http://foo')
|
||||
|
||||
self.assertEqual(2, len(samples))
|
||||
self._assert_sample(samples[0], 1, 'a', {'spam': 'egg'}, None)
|
||||
self._assert_sample(samples[1], 2, 'b', {}, None)
|
||||
|
||||
def test_get_samples_return_none(self):
|
||||
fake_driver = self._make_fake_driver(None)
|
||||
|
||||
self._setup_ext_mgr(http=fake_driver(self.CONF))
|
||||
|
||||
samples = self._get_samples('http://foo')
|
||||
|
||||
self.assertEqual(0, len(samples))
|
||||
|
||||
def test_get_samples_return_no_generator(self):
|
||||
class NoneFakeDriver(driver.Driver):
|
||||
|
||||
def get_sample_data(self, meter_name, parse_url, params, cache):
|
||||
return None
|
||||
|
||||
self._setup_ext_mgr(http=NoneFakeDriver(self.CONF))
|
||||
samples = self._get_samples('http://foo')
|
||||
self.assertFalse(samples)
|
@ -1,35 +0,0 @@
|
||||
#
|
||||
# Copyright 2014 NEC Corporation. All rights reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from ceilometer.network.statistics import switch
|
||||
from ceilometer import sample
|
||||
from ceilometer.tests.unit.network import statistics
|
||||
|
||||
|
||||
class TestSwitchPollster(statistics._PollsterTestBase):
|
||||
|
||||
def test_switch_pollster(self):
|
||||
self._test_pollster(
|
||||
switch.SWPollster,
|
||||
'switch',
|
||||
sample.TYPE_GAUGE,
|
||||
'switch')
|
||||
|
||||
def test_switch_pollster_ports(self):
|
||||
self._test_pollster(
|
||||
switch.SwitchPollsterPorts,
|
||||
'switch.ports',
|
||||
sample.TYPE_GAUGE,
|
||||
'ports')
|
@ -606,70 +606,6 @@ The following meters are collected for OpenStack Networking:
|
||||
| | | | | | label |
|
||||
+-----------------+-------+--------+-----------+-----------+------------------+
|
||||
|
||||
SDN controllers
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
The following meters are collected for SDN:
|
||||
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| Name | Type | Unit | Resource | Origin | Note |
|
||||
+=================+=========+========+===========+==========+=================+
|
||||
| **Meters added in the Mitaka release or earlier** |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| switch | Gauge | switch | switch ID | Pollster | Existence of sw\|
|
||||
| | | | | | itch |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| switch.port | Gauge | port | switch ID | Pollster | Existence of po\|
|
||||
| | | | | | rt |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| switch.port.re\ | Cumula\ | packet | switch ID | Pollster | Packets receive\|
|
||||
| ceive.packets | tive | | | | d on port |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| switch.port.tr\ | Cumula\ | packet | switch ID | Pollster | Packets transmi\|
|
||||
| ansmit.packets | tive | | | | tted on port |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| switch.port.re\ | Cumula\ | B | switch ID | Pollster | Bytes received |
|
||||
| ceive.bytes | tive | | | | on port |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| switch.port.tr\ | Cumula\ | B | switch ID | Pollster | Bytes transmitt\|
|
||||
| ansmit.bytes | tive | | | | ed on port |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| **Meters added in the Pike release** |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| port | Gauge | port | port ID | Pollster | Existence of po\|
|
||||
| | | | | | rt |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| port.uptime | Gauge | s | port ID | Pollster | Uptime of port |
|
||||
| | | | | | |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| port.receive.pa\| Cumula\ | packet | port ID | Pollster | Packets trasmit\|
|
||||
| ckets | tive | | | | ted on port |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| port.transmit.\ | Cumula\ | packet | port ID | Pollster | Packets transmi\|
|
||||
| packets | tive | | | | tted on port |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| port.receive.\ | Cumula\ | B | port ID | Pollster | Bytes received |
|
||||
| bytes | tive | | | | on port |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| port.transmit.\ | Cumula\ | B | port ID | Pollster | Bytes transmitt\|
|
||||
| bytes | tive | | | | ed on port |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| port.receive.\ | Cumula\ | packet | port ID | Pollster | Drops received |
|
||||
| drops | tive | | | | on port |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| port.receive.\ | Cumula\ | packet | port ID | Pollster | Errors received |
|
||||
| errors | tive | | | | on port |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| switch.ports | Gauge | ports | switch ID | Pollster | Number of ports\|
|
||||
| | | | | | on switch |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
| switch.port.upt\| Gauge | s | switch ID | Pollster | Uptime of switch|
|
||||
| ime | | | | | |
|
||||
+-----------------+---------+--------+-----------+----------+-----------------+
|
||||
|
||||
These meters are available for OpenFlow based switches. In order to
|
||||
enable these meters, each driver needs to be properly configured.
|
||||
|
||||
VPN-as-a-Service (VPNaaS)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
@ -84,13 +84,3 @@ The following is a list of supported hypervisors.
|
||||
|
||||
For details about hypervisor support in libvirt please see the
|
||||
`Libvirt API support matrix <http://libvirt.org/hvsupport.html>`__.
|
||||
|
||||
|
||||
Supported networking services
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Telemetry is able to retrieve information from external networking services:
|
||||
|
||||
- SDN controller meters:
|
||||
|
||||
- `OpenContrail <http://www.opencontrail.org/>`__
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
Support for Open Contrail has been removed. Because no SDN is supported
|
||||
after the removal, the mechanism to pull metrics from SDN is also removed.
|
19
setup.cfg
19
setup.cfg
@ -121,14 +121,6 @@ ceilometer.poll.ipmi =
|
||||
ceilometer.poll.central =
|
||||
ip.floating = ceilometer.network.floatingip:FloatingIPPollster
|
||||
image.size = ceilometer.image.glance:ImageSizePollster
|
||||
port = ceilometer.network.statistics.port_v2:PortPollster
|
||||
port.uptime = ceilometer.network.statistics.port_v2:PortPollsterUptime
|
||||
port.receive.packets = ceilometer.network.statistics.port_v2:PortPollsterReceivePackets
|
||||
port.transmit.packets = ceilometer.network.statistics.port_v2:PortPollsterTransmitPackets
|
||||
port.receive.bytes = ceilometer.network.statistics.port_v2:PortPollsterReceiveBytes
|
||||
port.transmit.bytes = ceilometer.network.statistics.port_v2:PortPollsterTransmitBytes
|
||||
port.receive.drops = ceilometer.network.statistics.port_v2:PortPollsterReceiveDrops
|
||||
port.receive.errors = ceilometer.network.statistics.port_v2:PortPollsterReceiveErrors
|
||||
radosgw.containers.objects = ceilometer.objectstore.rgw:ContainersObjectsPollster
|
||||
radosgw.containers.objects.size = ceilometer.objectstore.rgw:ContainersSizePollster
|
||||
radosgw.objects = ceilometer.objectstore.rgw:ObjectsPollster
|
||||
@ -140,14 +132,6 @@ ceilometer.poll.central =
|
||||
storage.objects = ceilometer.objectstore.swift:ObjectsPollster
|
||||
storage.objects.size = ceilometer.objectstore.swift:ObjectsSizePollster
|
||||
storage.objects.containers = ceilometer.objectstore.swift:ObjectsContainersPollster
|
||||
switch.port = ceilometer.network.statistics.port:PortPollster
|
||||
switch.port.uptime = ceilometer.network.statistics.port:PortPollsterUptime
|
||||
switch.port.receive.packets = ceilometer.network.statistics.port:PortPollsterReceivePackets
|
||||
switch.port.transmit.packets = ceilometer.network.statistics.port:PortPollsterTransmitPackets
|
||||
switch.port.receive.bytes = ceilometer.network.statistics.port:PortPollsterReceiveBytes
|
||||
switch.port.transmit.bytes = ceilometer.network.statistics.port:PortPollsterTransmitBytes
|
||||
switch = ceilometer.network.statistics.switch:SWPollster
|
||||
switch.ports = ceilometer.network.statistics.switch:SwitchPollsterPorts
|
||||
network.services.vpn = ceilometer.network.services.vpnaas:VPNServicesPollster
|
||||
network.services.vpn.connections = ceilometer.network.services.vpnaas:IPSecConnectionsPollster
|
||||
network.services.firewall = ceilometer.network.services.fwaas:FirewallPollster
|
||||
@ -195,9 +179,6 @@ console_scripts =
|
||||
ceilometer-rootwrap = oslo_rootwrap.cmd:main
|
||||
ceilometer-status = ceilometer.cmd.status:main
|
||||
|
||||
network.statistics.drivers =
|
||||
opencontrail = ceilometer.network.statistics.opencontrail.driver:OpencontrailDriver
|
||||
|
||||
oslo.config.opts =
|
||||
ceilometer = ceilometer.opts:list_opts
|
||||
ceilometer-auth = ceilometer.opts:list_keystoneauth_opts
|
||||
|
Loading…
Reference in New Issue
Block a user