From 300309fac980d9a3378aaf5b91d8a150b2ef4130 Mon Sep 17 00:00:00 2001 From: vinod pandarinathan Date: Fri, 12 Jun 2015 15:13:28 -0700 Subject: [PATCH] Cloudpulse configuration options handler Implements: blueprint config-handler Change-Id: I726bb4b36775dda1e0773c381e832f28fea89355 --- cloudpulse/__init__.py | 8 +- .../common/cloudpulse_keystoneclient.py | 4 +- cloudpulse/config.py | 79 +++++++++++++++++++ cloudpulse/openstack/common/periodic_task.py | 6 +- cloudpulse/opts.py | 48 +++++++++++ cloudpulse/version.py | 21 +++++ 6 files changed, 157 insertions(+), 9 deletions(-) create mode 100644 cloudpulse/config.py create mode 100644 cloudpulse/opts.py create mode 100644 cloudpulse/version.py diff --git a/cloudpulse/__init__.py b/cloudpulse/__init__.py index 0cec0a1..87e7bbe 100644 --- a/cloudpulse/__init__.py +++ b/cloudpulse/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - # 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 @@ -13,7 +11,9 @@ # under the License. import pbr.version +import threading +__version__ = pbr.version.VersionInfo('cloudpulse').version_string() -__version__ = pbr.version.VersionInfo( - 'cloudpulse').version_string() +# Make a project global TLS trace storage repository +TLS = threading.local() diff --git a/cloudpulse/common/cloudpulse_keystoneclient.py b/cloudpulse/common/cloudpulse_keystoneclient.py index 3a40d5f..ca5729c 100644 --- a/cloudpulse/common/cloudpulse_keystoneclient.py +++ b/cloudpulse/common/cloudpulse_keystoneclient.py @@ -28,12 +28,12 @@ from cloudpulse.openstack.common import log as logging LOG = logging.getLogger(__name__) -trust_opts = [ +topts = [ cfg.ListOpt('trusts_delegated_roles', default=['cloudpulse_assembly_update'], help=_('Subset of roles to be delegated to cloudpulse.')), ] -cfg.CONF.register_opts(trust_opts) +cfg.CONF.register_opts(topts) cfg.CONF.import_opt('auth_uri', 'keystonemiddleware.auth_token', group='keystone_authtoken') diff --git a/cloudpulse/config.py b/cloudpulse/config.py new file mode 100644 index 0000000..3d48e5d --- /dev/null +++ b/cloudpulse/config.py @@ -0,0 +1,79 @@ +# Copyright 2013 - Red Hat, 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. + +"""Cloudpulse specific config handling.""" + +from oslo_config import cfg + +from cloudpulse import version + +# Server Specific Configurations +server = { + 'port': '8080', + 'host': '0.0.0.0' +} + +# Pecan Application Configurations +app = {'root': 'cloudpulse.api.controllers.root.RootController', + 'modules': ['cloudpulse.api'], + 'static_root': '%(confdir)s/public', + 'template_path': '%(confdir)s/api/templates', + 'debug': True, + 'errors': {404: '/error/404', + '__force_dict__': True + } + } + +logging = { + 'root': {'level': 'INFO', 'handlers': ['console']}, + 'loggers': { + 'cloudpulse': {'level': 'DEBUG', 'handlers': ['console']}, + 'pecan.commands.serve': {'level': 'DEBUG', 'handlers': ['console']}, + 'py.warnings': {'handlers': ['console']}, + '__force_dict__': True + }, + 'handlers': { + 'console': { + 'level': 'DEBUG', + 'class': 'logging.StreamHandler', + 'formatter': 'color' + } + }, + 'formatters': { + 'simple': { + 'format': ('%(asctime)s %(levelname)-5.5s [%(name)s]' + '[%(threadName)s] %(message)s') + }, + 'color': { + '()': 'pecan.log.ColorFormatter', + 'format': ('%(asctime)s [%(padded_color_levelname)s] [%(name)s]' + '[%(threadName)s] %(message)s'), + '__force_dict__': True + } + } +} + +# Custom Configurations must be in Python dictionary format:: +# +# foo = {'bar':'baz'} +# +# All configurations are accessible at:: +# pecan.conf + + +def parse_args(argv, default_config_files=None): + cfg.CONF(argv[1:], + project='cloudpulse', + version=version.version_string, + default_config_files=default_config_files) diff --git a/cloudpulse/openstack/common/periodic_task.py b/cloudpulse/openstack/common/periodic_task.py index e0219fb..87a08df 100644 --- a/cloudpulse/openstack/common/periodic_task.py +++ b/cloudpulse/openstack/common/periodic_task.py @@ -22,7 +22,7 @@ import six from cloudpulse.openstack.common._i18n import _, _LE, _LI -periodic_opts = [ +popts = [ cfg.BoolOpt('run_external_periodic_tasks', default=True, help='Some periodic tasks can be run in a separate process. ' @@ -30,7 +30,7 @@ periodic_opts = [ ] CONF = cfg.CONF -CONF.register_opts(periodic_opts) +CONF.register_opts(popts) LOG = logging.getLogger(__name__) @@ -39,7 +39,7 @@ DEFAULT_INTERVAL = 60.0 def list_opts(): """Entry point for oslo-config-generator.""" - return [(None, copy.deepcopy(periodic_opts))] + return [(None, copy.deepcopy(popts))] class InvalidPeriodicTaskArg(Exception): diff --git a/cloudpulse/opts.py b/cloudpulse/opts.py new file mode 100644 index 0000000..62affb3 --- /dev/null +++ b/cloudpulse/opts.py @@ -0,0 +1,48 @@ +# Copyright 2014 +# The Cloudscaling Group, 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 itertools + +import cloudpulse.api.app +import cloudpulse.api.auth +import cloudpulse.common.clients +import cloudpulse.common.cloudpulse_keystoneclient +import cloudpulse.common.exception +import cloudpulse.conductor.config +import cloudpulse.db.sqlalchemy.models +import cloudpulse.openstack.common.eventlet_backdoor +import cloudpulse.openstack.common.log +import cloudpulse.openstack.common.periodic_task + + +def list_opts(): + return [ + ('DEFAULT', + itertools.chain(cloudpulse.api.auth.AUTH_OPTS, + cloudpulse.common.cloudpulse_keystoneclient.topts, + cloudpulse.common.paths.PATH_OPTS, + cloudpulse.common.utils.UTILS_OPTS, + (cloudpulse.openstack.common.eventlet_backdoor + .eventlet_backdoor_opts), + cloudpulse.openstack.common.log.generic_log_opts, + cloudpulse.openstack.common.log.log_opts, + cloudpulse.openstack.common.log.common_cli_opts, + cloudpulse.openstack.common.log.logging_cli_opts, + cloudpulse.openstack.common.periodic_task.popts, + )), + ('api', cloudpulse.api.app.API_SERVICE_OPTS), + ('conductor', cloudpulse.conductor.config.SERVICE_OPTS), + ('database', cloudpulse.db.sqlalchemy.models.sql_opts), + ] diff --git a/cloudpulse/version.py b/cloudpulse/version.py new file mode 100644 index 0000000..8b7ea8d --- /dev/null +++ b/cloudpulse/version.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2013 - Noorul Islam K M +# +# 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 pbr.version + + +version_info = pbr.version.VersionInfo('cloudpulse') +version_string = version_info.version_string