From b47c5947e4d47027d7132e4554001b4e28248e2c Mon Sep 17 00:00:00 2001 From: jiasirui Date: Wed, 23 Dec 2020 14:43:23 +0800 Subject: [PATCH] change the globale CONF Change-Id: If9999cdba5fd58a55762e20ab71736abed3b333b --- venus/conf/common.py | 57 ++++++++++++++++++++++++++++++ venus/context.py | 16 +-------- venus/db/base.py | 10 +----- venus/exception.py | 11 +----- venus/modules/search/action.py | 25 +------------ venus/modules/search/search_lib.py | 26 ++------------ venus/wsgi/eventlet_server.py | 55 +--------------------------- 7 files changed, 64 insertions(+), 136 deletions(-) diff --git a/venus/conf/common.py b/venus/conf/common.py index feadb09..c468a87 100644 --- a/venus/conf/common.py +++ b/venus/conf/common.py @@ -93,6 +93,63 @@ global_opts = [ cfg.StrOpt('os_region_name', default='RegionOne', help='os region name'), + cfg.BoolOpt('tcp_keepalive', + default=True, + help="Sets the value of TCP_KEEPALIVE (True/False) for each " + "server socket."), + cfg.IntOpt('tcp_keepidle', + default=600, + help="Sets the value of TCP_KEEPIDLE in seconds for each " + "server socket. Not supported on OS X."), + cfg.IntOpt('tcp_keepalive_interval', + help="Sets the value of TCP_KEEPINTVL in seconds for each " + "server socket. Not supported on OS X."), + cfg.IntOpt('tcp_keepalive_count', + help="Sets the value of TCP_KEEPCNT for each " + "server socket. Not supported on OS X."), + cfg.StrOpt('ssl_ca_file', + default=None, + help="CA certificate file to use to verify " + "connecting clients"), + cfg.StrOpt('ssl_cert_file', + default=None, + help="Certificate file to use when starting " + "the server securely"), + cfg.StrOpt('ssl_key_file', + default=None, + help="Private key file to use when starting " + "the server securely"), + cfg.IntOpt('max_header_line', + default=16384, + help="Maximum line size of message headers to be accepted. " + "max_header_line may need to be increased when using " + "large tokens (typically those generated by the " + "Keystone v3 API with big service catalogs)."), + cfg.IntOpt('client_socket_timeout', default=900, + help="Timeout for client connections\' socket operations. " + "If an incoming connection is idle for this number of " + "seconds it will be closed. A value of \'0\' means " + "wait forever."), + cfg.BoolOpt('wsgi_keep_alive', + default=True, + help='If False, closes the client socket connection ' + 'explicitly. Setting it to True to maintain backward ' + 'compatibility. Recommended setting is set it to False.'), + cfg.BoolOpt('fatal_exception_format_errors', + default=False, + help='Make exception message format errors fatal.'), + cfg.StrOpt('venus_internal_tenant_project_id', + default=None, + help='ID of the project which will be used as the Venus ' + 'internal tenant.'), + cfg.StrOpt('venus_internal_tenant_user_id', + default=None, + help='ID of the user to be used' + ' in venusmanager operations as the ' + 'Venus internal tenant.'), + cfg.StrOpt('db_driver', + default='venus.db', + help='Driver to use for database access') ] diff --git a/venus/context.py b/venus/context.py index 308d13c..accc145 100644 --- a/venus/context.py +++ b/venus/context.py @@ -17,27 +17,13 @@ import copy import six -from oslo_config import cfg from oslo_context import context from oslo_log import log as logging from oslo_utils import timeutils +from venus.conf import CONF from venus.i18n import _, _LW -context_opts = [ - cfg.StrOpt('venus_internal_tenant_project_id', - default=None, - help='ID of the project which will be used as the Venus ' - 'internal tenant.'), - cfg.StrOpt('venus_internal_tenant_user_id', - default=None, - help='ID of the user to be used' - ' in venusmanager operations as the ' - 'Venus internal tenant.'), -] - -CONF = cfg.CONF -CONF.register_opts(context_opts) LOG = logging.getLogger(__name__) diff --git a/venus/db/base.py b/venus/db/base.py index d4d288c..2cfa2de 100644 --- a/venus/db/base.py +++ b/venus/db/base.py @@ -14,16 +14,8 @@ """Base class for classes that need modular database access.""" -from oslo_config import cfg from oslo_utils import importutils - - -db_driver_opt = cfg.StrOpt('db_driver', - default='venus.db', - help='Driver to use for database access') - -CONF = cfg.CONF -CONF.register_opt(db_driver_opt) +from venus.conf import CONF class Base(object): diff --git a/venus/exception.py b/venus/exception.py index 4d97b7e..94b98de 100644 --- a/venus/exception.py +++ b/venus/exception.py @@ -22,26 +22,17 @@ SHOULD include dedicated exception logging. import sys -from oslo_config import cfg from oslo_log import log as logging from oslo_versionedobjects import exception as obj_exc import six import webob.exc +from venus.conf import CONF from venus.i18n import _, _LE LOG = logging.getLogger(__name__) -exc_log_opts = [ - cfg.BoolOpt('fatal_exception_format_errors', - default=False, - help='Make exception message format errors fatal.'), -] - -CONF = cfg.CONF -CONF.register_opts(exc_log_opts) - class ConvertedException(webob.exc.WSGIHTTPException): def __init__(self, code=500, title="", explanation=""): diff --git a/venus/modules/search/action.py b/venus/modules/search/action.py index f082460..8c39a13 100644 --- a/venus/modules/search/action.py +++ b/venus/modules/search/action.py @@ -16,38 +16,15 @@ import datetime import json import time -from oslo_config import cfg from oslo_log import log as logging from oslo_utils import timeutils from venus.common import utils +from venus.conf import CONF from venus.modules.search import es_template -CONF = cfg.CONF LOG = logging.getLogger(__name__) -""" -config the elasticsearch info -from /etc/venus/venus.conf -if not exists ,default -""" -elasticsearch_group = cfg.OptGroup(name='elasticsearch', - title='elasticsearch') - -elasticsearch_opts = [ - cfg.StrOpt('url', - default='', - help='the es url'), - cfg.StrOpt('username', - default='', - help='the es username'), - cfg.StrOpt('password', - default='', - help='the es password') -] -CONF.register_group(elasticsearch_group) -CONF.register_opts(elasticsearch_opts, elasticsearch_group) - class SearchCore(object): def __init__(self): diff --git a/venus/modules/search/search_lib.py b/venus/modules/search/search_lib.py index 3494767..7d3f491 100644 --- a/venus/modules/search/search_lib.py +++ b/venus/modules/search/search_lib.py @@ -18,34 +18,12 @@ from elasticsearch import Elasticsearch import re from urllib.parse import urlparse -from oslo_config import cfg from oslo_log import log as logging -CONF = cfg.CONF +from venus.conf import CONF + LOG = logging.getLogger(__name__) -""" -config the elasticsearch info -from /etc/venus/venus.conf -if not exists ,default -""" -elasticsearch_group = cfg.OptGroup(name='elasticsearch', - title='elasticsearch') - -elasticsearch_opts = [ - cfg.StrOpt('url', - default='', - help='the es url'), - cfg.StrOpt('username', - default='', - help='the es username'), - cfg.StrOpt('password', - default='', - help='the es password') -] -CONF.register_group(elasticsearch_group) -CONF.register_opts(elasticsearch_opts, elasticsearch_group) - class ESSearchObj(object): diff --git a/venus/wsgi/eventlet_server.py b/venus/wsgi/eventlet_server.py index 757afed..6e651b0 100644 --- a/venus/wsgi/eventlet_server.py +++ b/venus/wsgi/eventlet_server.py @@ -25,69 +25,16 @@ import time import eventlet import eventlet.wsgi import greenlet -from oslo_config import cfg from oslo_log import log as logging from oslo_service import service from oslo_utils import excutils from oslo_utils import netutils - +from venus.conf import CONF from venus import exception from venus.i18n import _, _LE, _LI -socket_opts = [ - cfg.BoolOpt('tcp_keepalive', - default=True, - help="Sets the value of TCP_KEEPALIVE (True/False) for each " - "server socket."), - cfg.IntOpt('tcp_keepidle', - default=600, - help="Sets the value of TCP_KEEPIDLE in seconds for each " - "server socket. Not supported on OS X."), - cfg.IntOpt('tcp_keepalive_interval', - help="Sets the value of TCP_KEEPINTVL in seconds for each " - "server socket. Not supported on OS X."), - cfg.IntOpt('tcp_keepalive_count', - help="Sets the value of TCP_KEEPCNT for each " - "server socket. Not supported on OS X."), - cfg.StrOpt('ssl_ca_file', - default=None, - help="CA certificate file to use to verify " - "connecting clients"), - cfg.StrOpt('ssl_cert_file', - default=None, - help="Certificate file to use when starting " - "the server securely"), - cfg.StrOpt('ssl_key_file', - default=None, - help="Private key file to use when starting " - "the server securely"), -] - -eventlet_opts = [ - cfg.IntOpt('max_header_line', - default=16384, - help="Maximum line size of message headers to be accepted. " - "max_header_line may need to be increased when using " - "large tokens (typically those generated by the " - "Keystone v3 API with big service catalogs)."), - cfg.IntOpt('client_socket_timeout', default=900, - help="Timeout for client connections\' socket operations. " - "If an incoming connection is idle for this number of " - "seconds it will be closed. A value of \'0\' means " - "wait forever."), - cfg.BoolOpt('wsgi_keep_alive', - default=True, - help='If False, closes the client socket connection ' - 'explicitly. Setting it to True to maintain backward ' - 'compatibility. Recommended setting is set it to False.'), -] - -CONF = cfg.CONF -CONF.register_opts(socket_opts) -CONF.register_opts(eventlet_opts) - LOG = logging.getLogger(__name__)