diff --git a/orm/base_config.py b/orm/base_config.py index 81a7ca26..0c0cf561 100644 --- a/orm/base_config.py +++ b/orm/base_config.py @@ -26,7 +26,7 @@ OrmOpts = [ default='127.0.0.1', help='Orm server IP address.'), cfg.StrOpt('ranger_base', - default='/opt/app/ranger', + default='/opt/stack/ranger', help='Orm base directory.'), cfg.BoolOpt('ssl_verify', default=False, @@ -190,7 +190,7 @@ OrmRdsGroup = [ default=8777, help='Rds port.'), cfg.StrOpt('repo_local_location', - default='/opt/app/git_repo', + default='/opt/stack/git_repo', help='Path to repo location.'), cfg.StrOpt('repo_remote_location', default='git@127.0.0.1:/home/repo/ORM.git', diff --git a/orm/cmd/db_setup.py b/orm/cmd/db_setup.py new file mode 100644 index 00000000..67c080ce --- /dev/null +++ b/orm/cmd/db_setup.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python +# Copyright (c) 2012 OpenStack Foundation +# 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. + +import orm.base_config as config +from oslo_config import cfg +from sqlalchemy import * +import sys + + +def main(argv=None): + + if argv is None: + argv = sys.argv + cfg.CONF(argv[1:], project='ranger', validate_default_values=True) + + sql_queries = [] + + orm_dbs = [ + config.ranger_base + '/orm/services/audit_trail_manager/scripts/db_scripts/create_db.sql', + config.ranger_base + '/orm/services/id_generator/scripts/db_scripts/db_create.sql', + config.ranger_base + '/orm/services/resource_distributor/scripts/db_scripts/create_db.sql', + config.ranger_base + '/orm/services/region_manager/scripts/db_scripts/create_db.sql', + config.ranger_base + + '/orm/services/customer_manager/scripts/db_scripts/ranger_cms_create_db.sql', + config.ranger_base + + '/orm/services/customer_manager/scripts/db_scripts/ranger_cms_update_db.sql', + config.ranger_base + + '/orm/services/flavor_manager/scripts/db_scripts/ranger_fms_create_db.sql', + config.ranger_base + '/orm/services/image_manager/scripts/db_scripts/create_db.sql' + ] + + for item in range(len(orm_dbs)): + sql_file = open(orm_dbs[item], "r") + query = sql_file.read() + sql_queries.append(query) + sql_file.close() + + engine = create_engine(config.db_url, echo=False) + + for exec_item in range(len(sql_queries)): + conn = engine.connect() + exec_script = conn.execute(sql_queries[exec_item]) + conn.close() + + print 'Ranger databases setup complete' diff --git a/orm/cmd/db_sync.py b/orm/cmd/db_sync.py new file mode 100644 index 00000000..95d452d7 --- /dev/null +++ b/orm/cmd/db_sync.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +# Copyright (c) 2018 OpenStack Foundation +# 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. + +import db_setup + + +def main(): + db_setup.main() diff --git a/orm/services/audit_trail_manager/scripts/db_scripts/create_db.sql b/orm/services/audit_trail_manager/scripts/db_scripts/create_db.sql index e8299eb4..ec7fe639 100644 --- a/orm/services/audit_trail_manager/scripts/db_scripts/create_db.sql +++ b/orm/services/audit_trail_manager/scripts/db_scripts/create_db.sql @@ -1,3 +1,5 @@ +SET sql_notes=0; + create database if not exists orm_audit; use orm_audit; diff --git a/orm/services/customer_manager/scripts/db_scripts/ranger_cms_create_db.sql b/orm/services/customer_manager/scripts/db_scripts/ranger_cms_create_db.sql index f16d1fe2..fc613f02 100755 --- a/orm/services/customer_manager/scripts/db_scripts/ranger_cms_create_db.sql +++ b/orm/services/customer_manager/scripts/db_scripts/ranger_cms_create_db.sql @@ -1,3 +1,5 @@ +SET sql_notes=0; + create database if not exists orm_cms_db DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; use orm_cms_db; diff --git a/orm/services/customer_manager/scripts/db_scripts/ranger_cms_update_db.sql b/orm/services/customer_manager/scripts/db_scripts/ranger_cms_update_db.sql index 694f3d14..52888c55 100644 --- a/orm/services/customer_manager/scripts/db_scripts/ranger_cms_update_db.sql +++ b/orm/services/customer_manager/scripts/db_scripts/ranger_cms_update_db.sql @@ -1,3 +1,5 @@ +SET sql_notes=0; + USE orm_cms_db; DROP PROCEDURE IF EXISTS MoveKeyToQuota; DELIMITER ;; @@ -74,7 +76,7 @@ CALL MoveKeyToQuota('security_group_rules', 'network'); SELECT "LIST OF ALL Security Items" as ""; SELECT "==========================" as ""; SELECT q.*, qfd.* FROM quota_field_detail qfd - left join quota q on (q.id = qfd.quota_id) where qfd.field_key like "security%"; + left join quota q on (q.id = qfd.quota_id) where qfd.field_key like "security%%"; DELIMITER ;; diff --git a/orm/services/flavor_manager/scripts/db_scripts/ranger_fms_create_db.sql b/orm/services/flavor_manager/scripts/db_scripts/ranger_fms_create_db.sql index ac115f5f..c9152c1a 100755 --- a/orm/services/flavor_manager/scripts/db_scripts/ranger_fms_create_db.sql +++ b/orm/services/flavor_manager/scripts/db_scripts/ranger_fms_create_db.sql @@ -1,3 +1,5 @@ +SET sql_notes=0; + create database if not exists orm_fms_db DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; use orm_fms_db; diff --git a/orm/services/id_generator/scripts/db_scripts/db_create.sql b/orm/services/id_generator/scripts/db_scripts/db_create.sql index 4d48283f..b950cd72 100755 --- a/orm/services/id_generator/scripts/db_scripts/db_create.sql +++ b/orm/services/id_generator/scripts/db_scripts/db_create.sql @@ -1,3 +1,5 @@ +SET sql_notes=0; + CREATE DATABASE if not exists orm; USE orm; diff --git a/orm/services/image_manager/scripts/db_scripts/create_db.sql b/orm/services/image_manager/scripts/db_scripts/create_db.sql index 30d046d8..745f2e09 100755 --- a/orm/services/image_manager/scripts/db_scripts/create_db.sql +++ b/orm/services/image_manager/scripts/db_scripts/create_db.sql @@ -1,3 +1,5 @@ +SET sql_notes=0; + create database if not exists orm_ims_db DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; use orm_ims_db; diff --git a/orm/services/region_manager/scripts/db_scripts/create_db.sql b/orm/services/region_manager/scripts/db_scripts/create_db.sql index ae6c0cf3..43072807 100644 --- a/orm/services/region_manager/scripts/db_scripts/create_db.sql +++ b/orm/services/region_manager/scripts/db_scripts/create_db.sql @@ -1,3 +1,5 @@ +SET sql_notes=0; + create database if not exists orm_rms_db DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; use orm_rms_db; diff --git a/orm/services/resource_distributor/scripts/db_scripts/create_db.sql b/orm/services/resource_distributor/scripts/db_scripts/create_db.sql index 9b58a5e5..de213fa0 100755 --- a/orm/services/resource_distributor/scripts/db_scripts/create_db.sql +++ b/orm/services/resource_distributor/scripts/db_scripts/create_db.sql @@ -1,3 +1,5 @@ +SET sql_notes=0; + create database if not exists orm_rds DEFAULT CHARACTER SET utf8 COLLATE utf8_bin; use orm_rds; diff --git a/setup.cfg b/setup.cfg index d9edf87c..8db558d4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -27,13 +27,14 @@ packages = orm [entry_points] console_scripts= - orm-fms = orm.cmd.fms:main - orm-cms = orm.cmd.cms:main - orm-rms = orm.cmd.rms:main - orm-rds = orm.cmd.rds:main - orm-ims = orm.cmd.ims:main - orm-audit = orm.cmd.audit:main - orm-uuidgen = orm.cmd.uuidgen:main + ranger-fms = orm.cmd.fms:main + ranger-cms = orm.cmd.cms:main + ranger-rms = orm.cmd.rms:main + ranger-rds = orm.cmd.rds:main + ranger-ims = orm.cmd.ims:main + ranger-audit = orm.cmd.audit:main + ranger-uuidgen = orm.cmd.uuidgen:main + ranger-dbsync = orm.cmd.db_sync:main oslo.config.opts = ranger = orm.common.config:list_opts diff --git a/setup.py b/setup.py index 70aab5a0..0e7d8dd1 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ except ImportError: from setuptools import setup, find_packages setup( - name='orm', + name='ranger', version='0.1', description='', author='', @@ -15,7 +15,7 @@ setup( install_requires=[ "pecan", ], - test_suite='orm', + test_suite='ranger', zip_safe=False, packages=find_packages(), include_package_data=True,