diff --git a/etc/ranger/ranger.conf b/etc/ranger/ranger.conf new file mode 100644 index 00000000..c221d270 --- /dev/null +++ b/etc/ranger/ranger.conf @@ -0,0 +1,53 @@ +[DEFAULT] +protocol = +orm_host = +ranger_base = +ssl_verify = +log_location = + +[keystone_authtoken] +username = +password = +project_name = +region = +project_domain_name = +user_domain_name = + +[database] +connection = +max_retries = + +[uuid] +port = +log = + +[cms] +port = +log = + +[fms] +port = +log = + +[audit] +port = +log = + +[ims] +port = +log = + +[rms] +port = +log = + +[rds] +port = +repo_local_location = +repo_remote_location = +repo_user = +repo_email = +log = + +[cli] +base_region = diff --git a/orm/base_config.py b/orm/base_config.py index bd6c4bc6..c4514b55 100644 --- a/orm/base_config.py +++ b/orm/base_config.py @@ -1,70 +1,285 @@ -orm_protocal = 'http' -orm_host = '127.0.0.1' -log_location = '{}' -ranger_base = '/opt/app/ranger' -log_location = '/var/log/ranger/{}' +# Copyright 2018 AT&T 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 oslo_config import cfg + +CONF = cfg.CONF + + +# Orm config options in DEFAULT block +OrmOpts = [ + cfg.StrOpt('protocol', + default='http', + help='Orm protocol used.'), + cfg.HostAddressOpt('orm_host', + default='127.0.0.1', + help='Orm server IP address.'), + cfg.StrOpt('ranger_base', + default='/opt/app/ranger', + help='Orm base directory.'), + cfg.BoolOpt('ssl_verify', + default=False, + help='Flag for SSL verfiy Enabled/Disabled.'), + cfg.StrOpt('log_location', + default='/var/log/ranger', + help='Orm log directory.') +] + +CONF.register_opts(OrmOpts) + +# Keystone config options in [keystone_autotoken] group +orm_token_group = cfg.OptGroup(name='token', + title='Orm Keystone Token Options') + +OrmAuthGroup = [ + cfg.StrOpt('username', + default='admin', + help='Token user name.'), + cfg.StrOpt('password', + default='devstack', + help='Token password.'), + cfg.StrOpt('project_name', + default='admin', + help='Project name.'), + cfg.StrOpt('region', + default='local', + help='Region.'), + cfg.StrOpt('project_domain_name', + default='default', + help='Project domain name.'), + cfg.StrOpt('user_domain_name', + default='default', + help='User domain name.') +] + +CONF.register_group(orm_token_group) +CONF.register_opts(OrmAuthGroup, orm_token_group) + +# Database config options in [database] group +orm_database_group = cfg.OptGroup(name='database', + title='Orm Database Options') + +OrmDatabaseGroup = [ + cfg.StrOpt('connection', + help='The SQLAlchemy connection string to use to connect to ' + 'the ORM database.', + secret=True), + cfg.IntOpt('max_retries', + default=-1, + help='The maximum number of retries for database connection.') +] + +CONF.register_group(orm_database_group) +CONF.register_opts(OrmDatabaseGroup, orm_database_group) + +# UUID config options in [uuid] group +orm_uuid_group = cfg.OptGroup(name='uuid', title='Orm UUID Options') + +OrmUuidGroup = [ + cfg.PortOpt('port', + default=7001, + help='UUID port.'), + cfg.StrOpt('log', + default='uuidgen.log', + help='UUID log name.') +] + +CONF.register_group(orm_uuid_group) +CONF.register_opts(OrmUuidGroup, orm_uuid_group) + + +# cms config options in [cms] group +orm_cms_group = cfg.OptGroup(name='cms', title='Orm Cms Options') + +OrmCmsGroup = [ + cfg.PortOpt('port', + default=7080, + help='Cms port.'), + cfg.StrOpt('log', + default='cms.log', + help='Cms log name.') +] + +CONF.register_group(orm_cms_group) +CONF.register_opts(OrmCmsGroup, orm_cms_group) + + +# fms config options in [fms] group +orm_fms_group = cfg.OptGroup(name='fms', title='Orm Fms Options') + +OrmFmsGroup = [ + cfg.PortOpt('port', + default=8082, + help='Fms port.'), + cfg.StrOpt('log', + default='fms.log', + help='Fms log name.') +] + +CONF.register_group(orm_fms_group) +CONF.register_opts(OrmFmsGroup, orm_fms_group) + + +# audit config options in [audit] group +orm_audit_group = cfg.OptGroup(name='audit', title='Orm Audit Options') + +OrmAuditGroup = [ + cfg.PortOpt('port', + default=7002, + help='Audit port.'), + cfg.StrOpt('log', + default='audit_server.log', + help='Audit log name.') +] + +CONF.register_group(orm_audit_group) +CONF.register_opts(OrmAuditGroup, orm_audit_group) + + +# ims config options in [ims] group +orm_ims_group = cfg.OptGroup(name='ims', title='Orm Ims Options') + +OrmImsGroup = [ + cfg.PortOpt('port', + default=8084, + help='Ims port.'), + cfg.StrOpt('log', + default='ims.log', + help='Ims log name.') +] + +CONF.register_group(orm_ims_group) +CONF.register_opts(OrmImsGroup, orm_ims_group) + + +# rms config options in [rms] group +orm_rms_group = cfg.OptGroup(name='rms', title='Orm Rms Options') + +OrmRmsGroup = [ + cfg.PortOpt('port', + default=7003, + help='Rms port.'), + cfg.StrOpt('log', + default='rms.log', + help='Rms log name.') +] + +CONF.register_group(orm_rms_group) +CONF.register_opts(OrmRmsGroup, orm_rms_group) + + +# rds config options in [rds] group +orm_rds_group = cfg.OptGroup(name='rds', title='Orm Rds Options') + +OrmRdsGroup = [ + cfg.PortOpt('port', + default=8777, + help='Rds port.'), + cfg.StrOpt('repo_local_location', + default='/opt/app/git_repo', + help='Path to repo location.'), + cfg.StrOpt('repo_remote_location', + default='git@127.0.0.1:/home/repo/ORM.git', + help='Repo remote location.'), + cfg.StrOpt('repo_user', + default='orm', + help='Repo user name.'), + cfg.StrOpt('repo_email', + default='orm@test.com', + help='Repo email address.'), + cfg.StrOpt('log', + default='rds.log', + help='Rds log name.') +] + +CONF.register_group(orm_rds_group) +CONF.register_opts(OrmRdsGroup, orm_rds_group) + + +# cli config options in [cli] group +orm_cli_group = cfg.OptGroup(name='cli', title='Orm CLI Options') + +OrmCliGroup = [ + cfg.StrOpt('base_region', + default='local', + help='Base region.') +] + +CONF.register_group(orm_cli_group) +CONF.register_opts(OrmCliGroup, orm_cli_group) + +################################################################ +# The following global variables are kept in here for +# backward compatiblitiy as other modules still +# referenced to them. +################################################################ + +protocol = CONF.protocol +orm_host = CONF.orm_host +ranger_base = CONF.ranger_base db_user = 'root' db_pass = 'devstack' db_host = '127.0.0.1' -ssl_verify = False +ssl_verify = CONF.ssl_verify token_auth_enabled = False -token_auth_user = 'admin' -token_auth_pass = 'devstack' -token_auth_tenant = 'admin' +token_auth_user = CONF.token.username +token_auth_pass = CONF.token.password +token_auth_tenant = CONF.token.project_name token_auth_user_role = 'admin' -uuid_port = 7001 -audit_port = 7002 -rms_port = 7003 -rds_port = 8777 -cms_port = 7080 -fms_port = 8082 -ims_port = 8084 -db_url = 'mysql://' + db_user + ':' + db_pass + '@' + db_host + ':3306/' +db_url = 'mysql://{}:{}@{}:3306/'.format(db_user, db_pass, db_host) -uuid = { - 'port': uuid_port, - 'base_url': '{}://{}:{}/'.format(orm_protocal, orm_host, uuid_port), - 'log': log_location.format('uuidgen.log') -} -cms = { - 'port': cms_port, - 'base_url': '{}://{}:{}/'.format(orm_protocal, orm_host, cms_port), - 'policy_file': ranger_base + '/orm/services/customer_manager/cms_rest/etc/policy.json', - 'log': log_location.format('cms.log') -} -fms = { - 'port': fms_port, - 'base_url': '{}://{}:{}/'.format(orm_protocal, orm_host, fms_port), - 'policy_file': ranger_base + '/orm/services/flavor_manager/fms_rest/etc/policy.json', - 'log': log_location.format('fms.log') -} -audit_server = { - 'port': audit_port, - 'base_url': '{}://{}:{}/'.format(orm_protocal, orm_host, audit_port), - 'log': log_location.format('audit_server.log') -} -ims = { - 'port': ims_port, - 'base_url': '{}://{}:{}/'.format(orm_protocal, orm_host, ims_port), - 'policy_file': ranger_base + '/orm/services/image_manager/ims/etc/policy.json', - 'log': log_location.format('ims.log') -} -rms = { - 'port': rms_port, - 'base_url': '{}://{}:{}/'.format(orm_protocal, orm_host, rms_port), - 'policy_file': ranger_base + '/orm/services/region_manager/rms/etc/policy.json', - 'log': log_location.format('rms.log') -} -rds = { - 'port': rds_port, - 'repo_local_location': '/opt/app/git_repo', - 'repo_user': 'orm', - 'repo_email': 'orm@test.com', - 'repo_remote_location': 'git@127.0.0.1:/home/repo/ORM.git', - 'base_url': '{}://{}:{}/'.format(orm_protocal, orm_host, rds_port), - 'log': log_location.format('rds.log') -} -cli = { - 'base_region': 'local' -} +uuid = {'port': CONF.uuid.port, + 'base_url': '{}://{}:{}/'. + format(protocol, orm_host, CONF.uuid.port), + 'log': '{}/{}'.format(CONF.log_location, CONF.uuid.log)} + +cms = {'port': CONF.cms.port, + 'base_url': '{}://{}:{}/'.format(protocol, orm_host, CONF.cms.port), + 'policy_file': CONF.ranger_base + + '/orm/services/customer_manager/cms_rest/etc/policy.json', + 'log': '{}/{}'.format(CONF.log_location, CONF.cms.log)} + +fms = {'port': CONF.fms.port, + 'base_url': '{}://{}:{}/'.format(protocol, orm_host, CONF.fms.port), + 'policy_file': CONF.ranger_base + + '/orm/services/flavor_manager/fms_rest/etc/policy.json', + 'log': '{}/{}'.format(CONF.log_location, CONF.fms.log)} + +audit_server = {'port': CONF.audit.port, + 'base_url': '{}://{}:{}/' + .format(protocol, orm_host, CONF.audit.port), + 'log': '{}/{}'.format(CONF.log_location, CONF.audit.log)} + +ims = {'port': CONF.ims.port, + 'base_url': '{}://{}:{}/'.format(protocol, orm_host, CONF.ims.port), + 'policy_file': CONF.ranger_base + + '/orm/services/image_manager/ims/etc/policy.json', + 'log': '{}/{}'.format(CONF.log_location, CONF.ims.log)} + +rms = {'port': CONF.rms.port, + 'base_url': '{}://{}:{}/'.format(protocol, orm_host, CONF.rms.port), + 'policy_file': CONF.ranger_base + + '/orm/services/region_manager/rms/etc/policy.json', + 'log': '{}/{}'.format(CONF.log_location, CONF.rms.log)} + +rds = {'port': CONF.rds.port, + 'repo_local_location': CONF.rds.repo_local_location, + 'repo_remote_location': CONF.rds.repo_remote_location, + 'repo_user': CONF.rds.repo_user, + 'repo_email': CONF.rds.repo_email, + 'base_url': '{}://{}:{}/'.format(protocol, orm_host, CONF.rds.port), + 'log': '{}/{}'.format(CONF.log_location, CONF.rds.log)} + +cli = {'base_region': CONF.cli.base_region} diff --git a/orm/cmd/uuidgen.py b/orm/cmd/uuidgen.py index 99fa99f9..dbf8844f 100644 --- a/orm/cmd/uuidgen.py +++ b/orm/cmd/uuidgen.py @@ -12,15 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_config import cfg - -from orm.common import config from orm.services.id_generator.uuidgen import app -CONF = cfg.CONF - - def main(): - config.parse_args() app.main() diff --git a/orm/orm_client/ormcli/config.py b/orm/orm_client/ormcli/config.py index 01ec7fd2..e69883f2 100755 --- a/orm/orm_client/ormcli/config.py +++ b/orm/orm_client/ormcli/config.py @@ -6,5 +6,5 @@ tenant_name = config.token_auth_tenant username = config.token_auth_user password = config.token_auth_pass auth_region = config.cli['base_region'] -orm_base_url = '{}://{}'.format(config.orm_protocal, config.orm_host) +orm_base_url = '{}://{}'.format(config.protocol, config.orm_host) verify = config.ssl_verify diff --git a/orm/services/audit_trail_manager/audit_server/app.py b/orm/services/audit_trail_manager/audit_server/app.py index 82f9e692..414d3fc1 100644 --- a/orm/services/audit_trail_manager/audit_server/app.py +++ b/orm/services/audit_trail_manager/audit_server/app.py @@ -1,10 +1,13 @@ """app module.""" import logging import os +import sys from orm.services.audit_trail_manager.audit_server import model from orm.services.audit_trail_manager.audit_server.storage import factory +from oslo_config import cfg + from pecan.commands import CommandRunner from pecan import make_app @@ -28,7 +31,11 @@ def setup_app(config): return app -def main(): +def main(argv=None): + if argv is None: + argv = sys.argv + cfg.CONF(argv[1:], project='ranger', validate_default_values=True) + dir_name = os.path.dirname(__file__) drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file) diff --git a/orm/services/customer_manager/cms_rest/app.py b/orm/services/customer_manager/cms_rest/app.py index 12d1b370..b0b3b1df 100755 --- a/orm/services/customer_manager/cms_rest/app.py +++ b/orm/services/customer_manager/cms_rest/app.py @@ -1,6 +1,7 @@ import os from pecan.commands import CommandRunner from pecan import make_app +import sys from orm.common.orm_common.policy import policy from orm.common.orm_common.utils import utils @@ -8,6 +9,8 @@ from orm.services.customer_manager.cms_rest.logger import get_logger from orm.services.customer_manager.cms_rest import model from orm.services.customer_manager.cms_rest.utils import authentication +from oslo_config import cfg + logger = get_logger(__name__) @@ -29,7 +32,11 @@ def setup_app(config): return app -def main(): +def main(argv=None): + if argv is None: + argv = sys.argv + cfg.CONF(argv[1:], project='ranger', validate_default_values=True) + dir_name = os.path.dirname(__file__) drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file) diff --git a/orm/services/flavor_manager/fms_rest/app.py b/orm/services/flavor_manager/fms_rest/app.py index 799285fb..c1202d06 100644 --- a/orm/services/flavor_manager/fms_rest/app.py +++ b/orm/services/flavor_manager/fms_rest/app.py @@ -1,10 +1,13 @@ import os +import sys from orm.common.orm_common.policy import policy from orm.services.flavor_manager.fms_rest.data import wsme from orm.services.flavor_manager.fms_rest.logger import get_logger from orm.services.flavor_manager.fms_rest.utils import authentication +from oslo_config import cfg + from pecan.commands import CommandRunner from pecan import make_app @@ -26,7 +29,11 @@ def setup_app(config): return app -def main(): +def main(argv=None): + if argv is None: + argv = sys.argv + cfg.CONF(argv[1:], project='ranger', validate_default_values=True) + dir_name = os.path.dirname(__file__) drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file) diff --git a/orm/services/id_generator/uuidgen/app.py b/orm/services/id_generator/uuidgen/app.py index 2bde154d..40492e0c 100755 --- a/orm/services/id_generator/uuidgen/app.py +++ b/orm/services/id_generator/uuidgen/app.py @@ -1,5 +1,7 @@ import os +import sys +from oslo_config import cfg from oslo_log import log as logging from pecan.commands import CommandRunner @@ -18,7 +20,11 @@ def setup_app(config): return app -def main(): +def main(argv=None): + if argv is None: + argv = sys.argv + cfg.CONF(argv[1:], project='ranger', validate_default_values=True) + dir_name = os.path.dirname(__file__) drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file) diff --git a/orm/services/image_manager/ims/app.py b/orm/services/image_manager/ims/app.py index 2b13ffbe..934b7c90 100755 --- a/orm/services/image_manager/ims/app.py +++ b/orm/services/image_manager/ims/app.py @@ -1,10 +1,13 @@ import os +import sys from orm.common.orm_common.policy import policy from orm.common.orm_common.utils.utils import set_utils_conf from orm.services.image_manager.ims.logger import get_logger from orm.services.image_manager.ims.utils import authentication as auth +from oslo_config import cfg + from pecan import conf, make_app from pecan.commands import CommandRunner @@ -28,7 +31,11 @@ def setup_app(config): return app -def main(): +def main(argv=None): + if argv is None: + argv = sys.argv + cfg.CONF(argv[1:], project='ranger', validate_default_values=True) + dir_name = os.path.dirname(__file__) drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file) diff --git a/orm/services/region_manager/rms/app.py b/orm/services/region_manager/rms/app.py index e987f2a2..cfe3d3db 100755 --- a/orm/services/region_manager/rms/app.py +++ b/orm/services/region_manager/rms/app.py @@ -1,11 +1,14 @@ import logging import os +import sys from orm.common.orm_common.policy import policy from orm.common.orm_common.utils import utils from orm.services.region_manager.rms import model from orm.services.region_manager.rms.utils import authentication +from oslo_config import cfg + from pecan.commands import CommandRunner from pecan import make_app @@ -30,7 +33,11 @@ def setup_app(config): return app -def main(): +def main(argv=None): + if argv is None: + argv = sys.argv + cfg.CONF(argv[1:], project='ranger', validate_default_values=True) + dir_name = os.path.dirname(__file__) drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file) diff --git a/orm/services/resource_distributor/rds/app.py b/orm/services/resource_distributor/rds/app.py index 3294ac6c..ac480335 100755 --- a/orm/services/resource_distributor/rds/app.py +++ b/orm/services/resource_distributor/rds/app.py @@ -1,5 +1,8 @@ import logging import os +import sys + +from oslo_config import cfg from orm.common.client.audit.audit_client.api import audit from pecan import conf, make_app @@ -62,7 +65,11 @@ def validate_sot(): sot_factory.get_sot().validate_sot_state() -def main(): +def main(argv=None): + if argv is None: + argv = sys.argv + cfg.CONF(argv[1:], project='ranger', validate_default_values=True) + dir_name = os.path.dirname(__file__) drive, path_and_file = os.path.splitdrive(dir_name) path, filename = os.path.split(path_and_file)