Merge "Add oslo_config and oslo_log to Ranger"
This commit is contained in:
commit
30846ed3f9
31
etc/orm.conf
31
etc/orm.conf
@ -1,31 +0,0 @@
|
|||||||
[DEFAULT]
|
|
||||||
api_workers = 1
|
|
||||||
debug = True
|
|
||||||
verbose = True
|
|
||||||
pecan_debug = True
|
|
||||||
region = local
|
|
||||||
#Log files location
|
|
||||||
log_dir = /var/log/ranger
|
|
||||||
local_repo = ranger_repo
|
|
||||||
cms_log_file: /var/log/orm/cms_rest.log
|
|
||||||
fms_log_file: /var/log/orm/fms_rest.log
|
|
||||||
ims_log_file: /var/log/orm/ims.log
|
|
||||||
rds_log_file: /var/log/orm/rds.log
|
|
||||||
uuidgen_log_file: /var/log/orm/uuidgen.log
|
|
||||||
audit_log_file: /var/log/orm/audit_server.log
|
|
||||||
rms_log_file: /var/log/orm/rms.log
|
|
||||||
orm_base_url: https://127.0.0.1
|
|
||||||
cms_listen_port: 7080
|
|
||||||
rms_listen_port: 8080
|
|
||||||
rds_http_listen_port: 8777
|
|
||||||
rds_listen_port: 8778
|
|
||||||
fms_listen_port: 8082
|
|
||||||
ims_listen_port: 8084
|
|
||||||
uuidgen_listen_port: 8090
|
|
||||||
audit_server_listen_port: 8776
|
|
||||||
|
|
||||||
[api]
|
|
||||||
# Address to bind the API server to
|
|
||||||
host = 0.0.0.0
|
|
||||||
# Port the bind the API server to
|
|
||||||
port = 9010
|
|
24
orm/_i18n.py
Normal file
24
orm/_i18n.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
"""oslo.i18n integration module.
|
||||||
|
See https://docs.openstack.org/oslo.i18n/latest/user/usage.html
|
||||||
|
"""
|
||||||
|
|
||||||
|
import oslo_i18n
|
||||||
|
|
||||||
|
DOMAIN = 'ranger'
|
||||||
|
|
||||||
|
_translators = oslo_i18n.TranslatorFactory(domain=DOMAIN)
|
||||||
|
|
||||||
|
# The primary translation function using the well-known name "_"
|
||||||
|
_ = _translators.primary
|
@ -12,8 +12,15 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
from orm.common import config
|
||||||
from orm.services.id_generator.uuidgen import app
|
from orm.services.id_generator.uuidgen import app
|
||||||
|
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
config.parse_args()
|
||||||
app.main()
|
app.main()
|
||||||
|
69
orm/common/config.py
Normal file
69
orm/common/config.py
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
"""
|
||||||
|
Configuration options registration.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
from oslo_log import log as logging
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
|
api_opts = [
|
||||||
|
cfg.HostAddressOpt(
|
||||||
|
'host',
|
||||||
|
default='0.0.0.0',
|
||||||
|
help='Ranger API server host'
|
||||||
|
),
|
||||||
|
cfg.BoolOpt('ssl_verify', default=False, help='Enable HTTPS')
|
||||||
|
]
|
||||||
|
|
||||||
|
uuid_opts = [
|
||||||
|
cfg.PortOpt('port', default=7001, help='uuid server port'),
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
|
db_opts = [
|
||||||
|
cfg.StrOpt('connection', default='',
|
||||||
|
help='Ranger database connection string')
|
||||||
|
]
|
||||||
|
|
||||||
|
API_GROUP = 'api'
|
||||||
|
UUID_GROUP = 'uuid'
|
||||||
|
DB_GROUP = 'database'
|
||||||
|
|
||||||
|
|
||||||
|
CONF.register_opts(api_opts, group=API_GROUP)
|
||||||
|
CONF.register_opts(uuid_opts, group=UUID_GROUP)
|
||||||
|
CONF.register_opts(db_opts, group=DB_GROUP)
|
||||||
|
|
||||||
|
logging.register_options(CONF)
|
||||||
|
|
||||||
|
|
||||||
|
def list_opts():
|
||||||
|
return [
|
||||||
|
(API_GROUP, api_opts),
|
||||||
|
(UUID_GROUP, uuid_opts),
|
||||||
|
(DB_GROUP, db_opts)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args(args=None):
|
||||||
|
|
||||||
|
logging.setup(CONF, 'ranger')
|
||||||
|
|
||||||
|
CONF(
|
||||||
|
args=args,
|
||||||
|
project='ranger',
|
||||||
|
default_config_files=[]
|
||||||
|
)
|
@ -1,8 +1,12 @@
|
|||||||
import orm.base_config as config
|
from oslo_config import cfg
|
||||||
|
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
|
||||||
# Server Specific Configurations
|
# Server Specific Configurations
|
||||||
server = {
|
server = {
|
||||||
'port': config.uuid['port'],
|
'port': CONF.uuid.port,
|
||||||
'host': config.orm_host
|
'host': CONF.api.host
|
||||||
}
|
}
|
||||||
# Pecan Application Configurations
|
# Pecan Application Configurations
|
||||||
app = {
|
app = {
|
||||||
@ -11,49 +15,10 @@ app = {
|
|||||||
'debug': True,
|
'debug': True,
|
||||||
}
|
}
|
||||||
|
|
||||||
logging = {
|
verify = CONF.api.ssl_verify
|
||||||
'root': {'level': 'INFO', 'handlers': ['console']},
|
|
||||||
'loggers': {
|
|
||||||
'uuidgen': {'level': 'DEBUG', 'handlers': ['console', 'Logfile'],
|
|
||||||
'propagate': False},
|
|
||||||
'pecan': {'level': 'DEBUG', 'handlers': ['console'],
|
|
||||||
'propagate': False},
|
|
||||||
'py.warnings': {'handlers': ['console']},
|
|
||||||
'__force_dict__': True
|
|
||||||
},
|
|
||||||
'handlers': {
|
|
||||||
'console': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.StreamHandler',
|
|
||||||
'formatter': 'color'
|
|
||||||
},
|
|
||||||
'Logfile': {
|
|
||||||
'level': 'DEBUG',
|
|
||||||
'class': 'logging.handlers.RotatingFileHandler',
|
|
||||||
'maxBytes': 50000000,
|
|
||||||
'backupCount': 10,
|
|
||||||
'filename': config.uuid['log'],
|
|
||||||
'formatter': 'simple'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
verify = config.ssl_verify
|
|
||||||
|
|
||||||
database = {
|
database = {
|
||||||
'connection_string': config.db_url + 'orm'
|
'connection_string': CONF.database.connection + '/orm'
|
||||||
}
|
}
|
||||||
# Custom Configurations must be in Python dictionary format::
|
# Custom Configurations must be in Python dictionary format::
|
||||||
#
|
#
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
import logging
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from oslo_log import log as logging
|
||||||
|
|
||||||
from pecan.commands import CommandRunner
|
from pecan.commands import CommandRunner
|
||||||
from pecan import make_app
|
from pecan import make_app
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def setup_app(config):
|
def setup_app(config):
|
||||||
app_conf = dict(config.app)
|
app_conf = dict(config.app)
|
||||||
|
|
||||||
app = make_app(app_conf.pop('root'),
|
app = make_app(app_conf.pop('root'),
|
||||||
logging=getattr(config, 'logging', {}),
|
logging=getattr(config, 'logging', {}),
|
||||||
**app_conf)
|
**app_conf)
|
||||||
logger.info('Starting uuidgen...')
|
LOG.info('Starting uuidgen...')
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,5 +12,6 @@ MySQL-python==1.2.5
|
|||||||
requests==2.6.0
|
requests==2.6.0
|
||||||
oslo.db==1.7.2
|
oslo.db==1.7.2
|
||||||
oslo.serialization
|
oslo.serialization
|
||||||
oslo.config
|
oslo.config>=4.6.0 # Apache-2.0
|
||||||
oslo.policy
|
oslo.policy
|
||||||
|
oslo.log>=3.30.0 # Apache-2.0
|
||||||
|
@ -24,10 +24,6 @@ setup-hooks =
|
|||||||
|
|
||||||
[files]
|
[files]
|
||||||
packages = orm
|
packages = orm
|
||||||
data_files =
|
|
||||||
/etc/orm =
|
|
||||||
etc/orm.conf
|
|
||||||
|
|
||||||
|
|
||||||
[entry_points]
|
[entry_points]
|
||||||
console_scripts=
|
console_scripts=
|
||||||
@ -38,6 +34,8 @@ console_scripts=
|
|||||||
orm-ims = orm.cmd.ims:main
|
orm-ims = orm.cmd.ims:main
|
||||||
orm-audit = orm.cmd.audit:main
|
orm-audit = orm.cmd.audit:main
|
||||||
orm-uuidgen = orm.cmd.uuidgen:main
|
orm-uuidgen = orm.cmd.uuidgen:main
|
||||||
|
oslo.config.opts =
|
||||||
|
ranger = orm.common.config:list_opts
|
||||||
|
|
||||||
[build_sphinx]
|
[build_sphinx]
|
||||||
source-dir = doc/source
|
source-dir = doc/source
|
||||||
|
4
tools/config/ranger-config-generator.conf
Normal file
4
tools/config/ranger-config-generator.conf
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
[DEFAULT]
|
||||||
|
output_file=etc/ranger.conf
|
||||||
|
wrap_width=79
|
||||||
|
namespace=ranger
|
3
tox.ini
3
tox.ini
@ -39,6 +39,9 @@ commands =
|
|||||||
[testenv:debug]
|
[testenv:debug]
|
||||||
commands = oslo_debug_helper {posargs}
|
commands = oslo_debug_helper {posargs}
|
||||||
|
|
||||||
|
[testenv:genconfig]
|
||||||
|
commands = oslo-config-generator --config-file=tools/config/ranger-config-generator.conf
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
show-source = True
|
show-source = True
|
||||||
ignore = H301,F821,H202,H101,H104,H238,H401,H405,E501,F811,F403,H233,F841
|
ignore = H301,F821,H202,H101,H104,H238,H401,H405,E501,F811,F403,H233,F841
|
||||||
|
Loading…
x
Reference in New Issue
Block a user