Generate separate db for murano service broker

1) Create separate config use the separate config.py
to use: tox -egencfconfig

2) Create separate db for murano service broker
to use: tox -e venv murano-cfapi-db-manage \
	--config-file etc/murano/murano-cfapi.conf upgrade

Change-Id: Ifd3551ace000e496d99725f46dbead62f7ef64b0
partial-implement: bp separate-service-broker-from-murano
This commit is contained in:
zhurong 2016-04-07 06:09:52 +00:00
parent 5c8285de1e
commit deb487d8c0
10 changed files with 200 additions and 18 deletions

2
.gitignore vendored
View File

@ -39,9 +39,11 @@ murano/tests/functional/engine/config.conf
#Autogenerated sample config file
etc/murano/murano.conf.sample
etc/murano/murano-cfapi.conf.sample
#User Config file for Murano
etc/murano/murano.conf
etc/murano/murano-cfapi.conf
etc/murano/logging.conf
# pylint autogenerated support files

View File

@ -0,0 +1,6 @@
[DEFAULT]
output_file = etc/murano/murano-cfapi.conf.sample
namespace = keystone_authtoken
namespace = murano.cfapi
namespace = oslo.db
namespace = oslo.log

View File

@ -21,7 +21,7 @@ import retrying
import six
from webob import response
from murano.common.i18n import _, _LI, _LW
from murano.common.i18n import _LI, _LW
from murano.common import auth_utils # noqa
from murano.common import wsgi
from murano.db.services import cf_connections as db_cf
@ -29,23 +29,8 @@ import muranoclient.client as muranoclient
from muranoclient.glance import client as glare_client
cfapi_opts = [
cfg.StrOpt('tenant', default='admin',
help=_('Project for service broker')),
cfg.StrOpt('bind_host', default='localhost',
help=_('Host for service broker')),
cfg.StrOpt('bind_port', default='8083',
help=_('Port for service broker')),
cfg.StrOpt('auth_url', default='localhost:5000',
help=_('Authentication URL')),
cfg.StrOpt('user_domain_name', default='default',
help=_('Domain name of the user')),
cfg.StrOpt('project_domain_name', default='default',
help=_('Domain name of the project'))]
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
CONF.register_opts(cfapi_opts, group='cfapi')
class Controller(object):

View File

@ -35,7 +35,7 @@ from oslo_service import service
from murano.api.v1 import request_statistics
from murano.common import app_loader
from murano.common import config
from murano.common import cf_config as config
from murano.common import policy
from murano.common import server
from murano.common import wsgi

View File

@ -0,0 +1,80 @@
# 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
from oslo_db import options
from murano.db.cfapi_migration import migration
CONF = cfg.CONF
options.set_defaults(CONF)
class ApiDBCommand(object):
def upgrade(self, config):
migration.upgrade(CONF.command.revision, config=config)
def downgrade(self, config):
migration.downgrade(CONF.command.revision, config=config)
def revision(self, config):
migration.revision(CONF.command.message,
CONF.command.autogenerate,
config=config)
def stamp(self, config):
migration.stamp(CONF.command.revision, config=config)
def version(self, config):
print(migration.version())
def add_command_parsers(subparsers):
command_object = ApiDBCommand()
parser = subparsers.add_parser('upgrade')
parser.set_defaults(func=command_object.upgrade)
parser.add_argument('--revision', nargs='?')
parser = subparsers.add_parser('downgrade')
parser.set_defaults(func=command_object.downgrade)
parser.add_argument('--revision', nargs='?')
parser = subparsers.add_parser('stamp')
parser.add_argument('--revision', nargs='?')
parser.set_defaults(func=command_object.stamp)
parser = subparsers.add_parser('revision')
parser.add_argument('-m', '--message')
parser.add_argument('--autogenerate', action='store_true')
parser.set_defaults(func=command_object.revision)
parser = subparsers.add_parser('version')
parser.set_defaults(func=command_object.version)
command_opt = cfg.SubCommandOpt('command',
title='Command',
help='Available commands',
handler=add_command_parsers)
CONF.register_cli_opt(command_opt)
def main():
config = migration.get_alembic_config()
# attach the Murano conf to the Alembic conf
config.murano_config = CONF
CONF(project='murano')
CONF.command.func(config)

View File

@ -0,0 +1,73 @@
# Copyright 2011 OpenStack LLC.
# 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
from oslo_log import log as logging
from oslo_middleware import cors
from murano.common.i18n import _
from murano import version
cfapi_opts = [
cfg.StrOpt('tenant', default='admin',
help=_('Project for service broker')),
cfg.StrOpt('bind_host', default='localhost',
help=_('Host for service broker')),
cfg.StrOpt('bind_port', default='8083',
help=_('Port for service broker')),
cfg.StrOpt('auth_url', default='localhost:5000',
help=_('Authentication URL')),
cfg.StrOpt('user_domain_name', default='default',
help=_('Domain name of the user')),
cfg.StrOpt('project_domain_name', default='default',
help=_('Domain name of the project'))]
CONF = cfg.CONF
CONF.register_opts(cfapi_opts, group='cfapi')
def parse_args(args=None, usage=None, default_config_files=None):
logging.register_options(CONF)
CONF(args=args,
project='murano',
version=version.version_string,
usage=usage,
default_config_files=default_config_files)
def set_middleware_defaults():
"""Update default configuration options for oslo.middleware."""
# CORS Defaults
# TODO(krotscheck): Update with https://review.openstack.org/#/c/285368/
cfg.set_defaults(cors.CORS_OPTS,
allow_headers=['X-Auth-Token',
'X-Openstack-Request-Id',
'X-Configuration-Session',
'X-Roles',
'X-User-Id',
'X-Tenant-Id'],
expose_headers=['X-Auth-Token',
'X-Openstack-Request-Id',
'X-Configuration-Session',
'X-Roles',
'X-User-Id',
'X-Tenant-Id'],
allow_methods=['GET',
'PUT',
'POST',
'DELETE',
'PATCH']
)

View File

@ -0,0 +1,15 @@
Please see https://alembic.readthedocs.org/en/latest/index.html for general documentation
To create alembic migrations use:
$ murano-cfapi-db-manage revision --message --autogenerate
Stamp db with most recent migration version, without actually running migrations
$ murano-cfapi-db-manage stamp --revision head
Upgrade can be performed by:
$ murano-cfapi-db-manage upgrade
$ murano-cfapi-db-manage upgrade --revision head
Downgrading db:
$ murano-cfapi-db-manage downgrade
$ murano-cfapi-db-manage downgrade --revision base

View File

@ -12,6 +12,10 @@
# License for the specific language governing permissions and limitations
# under the License.
__all__ = [
'list_opts',
'list_cfapi_opts',
]
import copy
import itertools
@ -19,6 +23,7 @@ import itertools
import oslo_service.sslutils
import murano.api.middleware.ssl
import murano.common.cf_config
import murano.common.config
import murano.common.wsgi
@ -48,6 +53,10 @@ _opt_lists = [
])),
]
_cfapi_opt_lists = [
('cfapi', murano.common.cf_config.cfapi_opts),
]
_opt_lists.extend(oslo_service.sslutils.list_opts())
@ -68,3 +77,8 @@ def list_opts():
:returns: a list of (group_name, opts) tuples
"""
return [(g, copy.deepcopy(o)) for g, o in _opt_lists]
def list_cfapi_opts():
"""Return a list of oslo_config options available in service broker."""
return [(g, copy.deepcopy(o)) for g, o in _cfapi_opt_lists]

View File

@ -46,11 +46,13 @@ console_scripts =
murano-engine = murano.cmd.engine:main
murano-manage = murano.cmd.manage:main
murano-db-manage = murano.cmd.db_manage:main
murano-cfapi-db-manage = murano.cmd.cfapi_db_manage:main
murano-test-runner = murano.cmd.test_runner:main
murano-cfapi = murano.cmd.cfapi:main
oslo.config.opts =
murano = murano.opts:list_opts
keystone_authtoken = keystonemiddleware.opts:list_auth_token_opts
murano.cfapi = murano.opts:list_cfapi_opts
oslo.config.opts.defaults =
murano = murano.common.config:set_middleware_defaults
tempest.test_plugins =

View File

@ -66,7 +66,12 @@ setenv = VIRTUAL_ENV={envdir}
commands = bash tools/lintstack.sh
[testenv:genconfig]
commands = oslo-config-generator --config-file etc/oslo-config-generator/murano.conf
commands =
oslo-config-generator --config-file etc/oslo-config-generator/murano.conf
[testenv:gencfconfig]
commands =
oslo-config-generator --config-file etc/oslo-config-generator/murano-cfapi.conf
[testenv:releasenotes]
commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html