Cleanup Ranger config and db setup files

Change-Id: I756a24f2bb9365903ae221d60f23c5fdf74587bd
This commit is contained in:
stewie925 2018-08-22 17:21:15 -05:00 committed by STEW TY
parent feb25dfd6f
commit 21f6bba340
13 changed files with 108 additions and 12 deletions

View File

@ -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',

58
orm/cmd/db_setup.py Normal file
View File

@ -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'

21
orm/cmd/db_sync.py Normal file
View File

@ -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()

View File

@ -1,3 +1,5 @@
SET sql_notes=0;
create database if not exists orm_audit;
use orm_audit;

View File

@ -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;

View File

@ -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 ;;

View File

@ -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;

View File

@ -1,3 +1,5 @@
SET sql_notes=0;
CREATE DATABASE if not exists orm;
USE orm;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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

View File

@ -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,