Merge "Enable to get service types from configuration file"
This commit is contained in:
commit
33bb032e32
@ -17,6 +17,7 @@
|
||||
import datetime
|
||||
|
||||
from keystoneclient import exceptions
|
||||
from oslo.config import cfg
|
||||
import requests
|
||||
import six
|
||||
|
||||
@ -25,8 +26,17 @@ from ceilometer.openstack.common.gettextutils import _
|
||||
from ceilometer.openstack.common import log
|
||||
from ceilometer import sample
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
service_types_opts = [
|
||||
cfg.StrOpt('kwapi',
|
||||
default='energy',
|
||||
help='Kwapi service type.'),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(service_types_opts, group='service_types')
|
||||
|
||||
|
||||
class KwapiClient(object):
|
||||
"""Kwapi API client."""
|
||||
@ -56,7 +66,7 @@ class _Base(plugin.CentralPollster):
|
||||
|
||||
@property
|
||||
def default_discovery(self):
|
||||
return 'endpoint:energy'
|
||||
return 'endpoint:%s' % cfg.CONF.service_types.kwapi
|
||||
|
||||
@staticmethod
|
||||
def get_kwapi_client(ksclient, endpoint):
|
||||
|
@ -39,14 +39,21 @@ OPTS = [
|
||||
"(default value in glanceclient is used)."),
|
||||
]
|
||||
|
||||
service_types_opts = [
|
||||
cfg.StrOpt('glance',
|
||||
default='image',
|
||||
help='Glance service type.'),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(OPTS)
|
||||
cfg.CONF.register_opts(service_types_opts, group='service_types')
|
||||
|
||||
|
||||
class _Base(plugin.CentralPollster):
|
||||
|
||||
@property
|
||||
def default_discovery(self):
|
||||
return 'endpoint:image'
|
||||
return 'endpoint:%s' % cfg.CONF.service_types.glance
|
||||
|
||||
@staticmethod
|
||||
def get_glance_client(ksclient, endpoint):
|
||||
|
@ -17,6 +17,8 @@
|
||||
# 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 oslo.config import cfg
|
||||
from oslo.utils import timeutils
|
||||
|
||||
from ceilometer.central import plugin
|
||||
@ -25,8 +27,11 @@ from ceilometer.openstack.common.gettextutils import _
|
||||
from ceilometer.openstack.common import log
|
||||
from ceilometer import sample
|
||||
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
cfg.CONF.import_group('service_types', 'ceilometer.nova_client')
|
||||
|
||||
|
||||
class FloatingIPPollster(plugin.CentralPollster):
|
||||
|
||||
@ -43,7 +48,7 @@ class FloatingIPPollster(plugin.CentralPollster):
|
||||
|
||||
@property
|
||||
def default_discovery(self):
|
||||
return 'endpoint:compute'
|
||||
return 'endpoint:%s' % cfg.CONF.service_types.nova
|
||||
|
||||
def get_samples(self, manager, cache, resources):
|
||||
for endpoint in resources:
|
||||
|
@ -15,11 +15,16 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo.config import cfg
|
||||
|
||||
from ceilometer.central import plugin
|
||||
from ceilometer import neutron_client
|
||||
from ceilometer import plugin as base_plugin
|
||||
|
||||
|
||||
cfg.CONF.import_group('service_types', 'ceilometer.neutron_client')
|
||||
|
||||
|
||||
class _BaseServicesDiscovery(base_plugin.DiscoveryBase):
|
||||
|
||||
def __init__(self):
|
||||
@ -28,7 +33,7 @@ class _BaseServicesDiscovery(base_plugin.DiscoveryBase):
|
||||
|
||||
|
||||
class LBPoolsDiscovery(_BaseServicesDiscovery):
|
||||
@plugin.check_keystone('network')
|
||||
@plugin.check_keystone(cfg.CONF.service_types.neutron)
|
||||
def discover(self, manager, param=None):
|
||||
"""Discover resources to monitor."""
|
||||
|
||||
@ -38,7 +43,7 @@ class LBPoolsDiscovery(_BaseServicesDiscovery):
|
||||
|
||||
|
||||
class LBVipsDiscovery(_BaseServicesDiscovery):
|
||||
@plugin.check_keystone('network')
|
||||
@plugin.check_keystone(cfg.CONF.service_types.neutron)
|
||||
def discover(self, manager, param=None):
|
||||
"""Discover resources to monitor."""
|
||||
|
||||
@ -48,7 +53,7 @@ class LBVipsDiscovery(_BaseServicesDiscovery):
|
||||
|
||||
|
||||
class LBMembersDiscovery(_BaseServicesDiscovery):
|
||||
@plugin.check_keystone('network')
|
||||
@plugin.check_keystone(cfg.CONF.service_types.neutron)
|
||||
def discover(self, manager, param=None):
|
||||
"""Discover resources to monitor."""
|
||||
|
||||
@ -58,7 +63,7 @@ class LBMembersDiscovery(_BaseServicesDiscovery):
|
||||
|
||||
|
||||
class LBHealthMonitorsDiscovery(_BaseServicesDiscovery):
|
||||
@plugin.check_keystone('network')
|
||||
@plugin.check_keystone(cfg.CONF.service_types.neutron)
|
||||
def discover(self, manager, param=None):
|
||||
"""Discover resources to monitor."""
|
||||
|
||||
@ -67,7 +72,7 @@ class LBHealthMonitorsDiscovery(_BaseServicesDiscovery):
|
||||
|
||||
|
||||
class VPNServicesDiscovery(_BaseServicesDiscovery):
|
||||
@plugin.check_keystone('network')
|
||||
@plugin.check_keystone(cfg.CONF.service_types.neutron)
|
||||
def discover(self, manager, param=None):
|
||||
"""Discover resources to monitor."""
|
||||
|
||||
@ -77,7 +82,7 @@ class VPNServicesDiscovery(_BaseServicesDiscovery):
|
||||
|
||||
|
||||
class IPSecConnectionsDiscovery(_BaseServicesDiscovery):
|
||||
@plugin.check_keystone('network')
|
||||
@plugin.check_keystone(cfg.CONF.service_types.neutron)
|
||||
def discover(self, manager, param=None):
|
||||
"""Discover resources to monitor."""
|
||||
|
||||
@ -86,7 +91,7 @@ class IPSecConnectionsDiscovery(_BaseServicesDiscovery):
|
||||
|
||||
|
||||
class FirewallDiscovery(_BaseServicesDiscovery):
|
||||
@plugin.check_keystone('network')
|
||||
@plugin.check_keystone(cfg.CONF.service_types.neutron)
|
||||
def discover(self, manager, param=None):
|
||||
"""Discover resources to monitor."""
|
||||
|
||||
@ -96,7 +101,7 @@ class FirewallDiscovery(_BaseServicesDiscovery):
|
||||
|
||||
|
||||
class FirewallPolicyDiscovery(_BaseServicesDiscovery):
|
||||
@plugin.check_keystone('network')
|
||||
@plugin.check_keystone(cfg.CONF.service_types.neutron)
|
||||
def discover(self, manager, param=None):
|
||||
"""Discover resources to monitor."""
|
||||
|
||||
|
@ -21,6 +21,14 @@ from oslo.config import cfg
|
||||
|
||||
from ceilometer.openstack.common import log
|
||||
|
||||
|
||||
service_types_opts = [
|
||||
cfg.StrOpt('neutron',
|
||||
default='network',
|
||||
help='Neutron service type.'),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(service_types_opts, group='service_types')
|
||||
cfg.CONF.import_group('service_credentials', 'ceilometer.service')
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
@ -51,7 +59,8 @@ class Client(object):
|
||||
'password': conf.os_password,
|
||||
'auth_url': conf.os_auth_url,
|
||||
'region_name': conf.os_region_name,
|
||||
'endpoint_type': conf.os_endpoint_type
|
||||
'endpoint_type': conf.os_endpoint_type,
|
||||
'service_type': cfg.CONF.service_types.neutron
|
||||
}
|
||||
|
||||
if conf.os_tenant_id:
|
||||
|
@ -21,12 +21,22 @@ from oslo.config import cfg
|
||||
|
||||
from ceilometer.openstack.common import log
|
||||
|
||||
|
||||
nova_opts = [
|
||||
cfg.BoolOpt('nova_http_log_debug',
|
||||
default=False,
|
||||
help='Allow novaclient\'s debug log output.'),
|
||||
]
|
||||
|
||||
service_types_opts = [
|
||||
cfg.StrOpt('nova',
|
||||
default='compute',
|
||||
help='Nova service type.'),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(nova_opts)
|
||||
cfg.CONF.register_opts(service_types_opts, group='service_types')
|
||||
|
||||
cfg.CONF.import_group('service_credentials', 'ceilometer.service')
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
@ -60,6 +70,7 @@ class Client(object):
|
||||
auth_token=auth_token,
|
||||
region_name=conf.os_region_name,
|
||||
endpoint_type=conf.os_endpoint_type,
|
||||
service_type=cfg.CONF.service_types.nova,
|
||||
bypass_url=bypass_url,
|
||||
cacert=conf.os_cacert,
|
||||
insecure=conf.insecure,
|
||||
|
@ -40,7 +40,14 @@ OPTS = [
|
||||
"reseller_prefix in proxy-server.conf."),
|
||||
]
|
||||
|
||||
service_types_opts = [
|
||||
cfg.StrOpt('swift',
|
||||
default='object-store',
|
||||
help='Swift service type.'),
|
||||
]
|
||||
|
||||
cfg.CONF.register_opts(OPTS)
|
||||
cfg.CONF.register_opts(service_types_opts, group='service_types')
|
||||
|
||||
|
||||
class _Base(plugin.CentralPollster):
|
||||
@ -62,11 +69,10 @@ class _Base(plugin.CentralPollster):
|
||||
# only ever called once
|
||||
if _Base._ENDPOINT is None:
|
||||
try:
|
||||
endpoint_type = cfg.CONF.service_credentials.os_endpoint_type
|
||||
endpoint = ksclient.service_catalog.url_for(
|
||||
service_type='object-store',
|
||||
endpoint_type=endpoint_type)
|
||||
_Base._ENDPOINT = endpoint
|
||||
conf = cfg.CONF.service_credentials
|
||||
_Base._ENDPOINT = ksclient.service_catalog.url_for(
|
||||
service_type=cfg.CONF.service_types.swift,
|
||||
endpoint_type=conf.os_endpoint_type)
|
||||
except exceptions.EndpointNotFound:
|
||||
LOG.debug(_("Swift endpoint not found"))
|
||||
return _Base._ENDPOINT
|
||||
|
@ -98,6 +98,10 @@ class TestEnergyPollster(base.BaseTestCase):
|
||||
probe_dict['id'] = key
|
||||
yield probe_dict
|
||||
|
||||
def test_default_discovery(self):
|
||||
pollster = kwapi.EnergyPollster()
|
||||
self.assertEqual('endpoint:energy', pollster.default_discovery)
|
||||
|
||||
def test_sample(self):
|
||||
cache = {}
|
||||
samples = list(kwapi.EnergyPollster().get_samples(
|
||||
@ -161,6 +165,10 @@ class TestPowerPollster(base.BaseTestCase):
|
||||
probe_dict['id'] = key
|
||||
yield probe_dict
|
||||
|
||||
def test_default_discovery(self):
|
||||
pollster = kwapi.PowerPollster()
|
||||
self.assertEqual('endpoint:energy', pollster.default_discovery)
|
||||
|
||||
def test_sample(self):
|
||||
cache = {}
|
||||
samples = list(kwapi.PowerPollster().get_samples(
|
||||
|
@ -181,6 +181,10 @@ class TestImagePollster(base.BaseTestCase):
|
||||
glance._Base, 'get_glance_client',
|
||||
side_effect=self.fake_get_glance_client))
|
||||
|
||||
def test_default_discovery(self):
|
||||
pollster = glance.ImagePollster()
|
||||
self.assertEqual('endpoint:image', pollster.default_discovery)
|
||||
|
||||
def test_iter_images(self):
|
||||
# Tests whether the iter_images method returns a unique image
|
||||
# list when there is nothing in the cache
|
||||
|
@ -56,6 +56,9 @@ class TestFloatingIPPollster(base.BaseTestCase):
|
||||
ips.append(ip)
|
||||
return ips
|
||||
|
||||
def test_default_discovery(self):
|
||||
self.assertEqual('endpoint:compute', self.pollster.default_discovery)
|
||||
|
||||
# FIXME(dhellmann): Is there a useful way to define this
|
||||
# test without a database?
|
||||
#
|
||||
|
@ -67,6 +67,23 @@ pecan_debug The value of DEFAULT.debug Toggle Pe
|
||||
processes with mod_wsgi.
|
||||
=============================== ==================================== ===============================================================
|
||||
|
||||
Service polling configuration
|
||||
==============================
|
||||
|
||||
The following options must be placed under a [service_types] section
|
||||
and will be used by Ceilometer to retrieve information from OpenStack
|
||||
components.
|
||||
|
||||
=============================== ==================================== ==============================================================
|
||||
Parameter Default Note
|
||||
=============================== ==================================== ==============================================================
|
||||
nova compute The service type for nova
|
||||
neutron network The service type for neutron
|
||||
glance image The service type for glance
|
||||
swift object-store The service type for swift
|
||||
kwapi energy The service type for kwapi
|
||||
=============================== ==================================== ==============================================================
|
||||
|
||||
Service polling authentication
|
||||
==============================
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user