Esempio n. 1
0
def main():
    cfg.parse_args(sys.argv)
    logging.setup(None)

    debug_utils.setup()

    # Patch 'thread' module if debug is disabled
    if not debug_utils.enabled():
        eventlet.monkey_patch(thread=True)

    from trove.guestagent import dbaas
    manager = dbaas.datastore_registry().get(CONF.datastore_manager)
    if not manager:
        msg = ("Manager class not registered for datastore manager %s" %
               CONF.datastore_manager)
        raise RuntimeError(msg)

    # rpc module must be loaded after decision about thread monkeypatching
    # because if thread module is not monkeypatched we can't use eventlet
    # executor from oslo.messaging library.
    from trove import rpc
    rpc.init(CONF)

    from trove.common.rpc import service as rpc_service
    from trove.common.rpc import version as rpc_version
    server = rpc_service.RpcService(
        manager=manager,
        host=CONF.guest_id,
        rpc_api_version=rpc_version.RPC_API_VERSION)

    launcher = openstack_service.launch(server)
    launcher.wait()
Esempio n. 2
0
def main():
    cfg.parse_args(sys.argv)
    logging.setup(None)

    debug_utils.setup()

    # Patch 'thread' module if debug is disabled
    if not debug_utils.enabled():
        eventlet.monkey_patch(thread=True)

    from trove.guestagent import dbaas
    manager = dbaas.datastore_registry().get(CONF.datastore_manager)
    if not manager:
        msg = ("Manager class not registered for datastore manager %s" %
               CONF.datastore_manager)
        raise RuntimeError(msg)

    # rpc module must be loaded after decision about thread monkeypatching
    # because if thread module is not monkeypatched we can't use eventlet
    # executor from oslo.messaging library.
    from trove import rpc
    rpc.init(CONF)

    from trove.common.rpc import service as rpc_service
    from trove.common.rpc import version as rpc_version
    server = rpc_service.RpcService(
        manager=manager, host=CONF.guest_id,
        rpc_api_version=rpc_version.RPC_API_VERSION)

    launcher = openstack_service.launch(server)
    launcher.wait()
Esempio n. 3
0
def main():
    CONF(sys.argv[1:], project='oslo')
    logging.setup("oslo")

    with contextlib.closing(impl_zmq.ZmqProxy(CONF)) as reactor:
        reactor.consume_in_thread()
        reactor.wait()
Esempio n. 4
0
File: api.py Progetto: bruceSz/trove
def main():
    cfg.parse_args(sys.argv)
    logging.setup(None)

    get_db_api().configure_db(CONF)
    conf_file = CONF.find_file(CONF.api_paste_config)
    launcher = wsgi.launch('trove', CONF.bind_port or 8779, conf_file,
                           workers=CONF.trove_api_workers)
    launcher.wait()
Esempio n. 5
0
def main():
    cfg.parse_args(sys.argv)
    logging.setup(None)

    debug_utils.setup()

    if not debug_utils.enabled():
        eventlet.monkey_patch(thread=True)

    launch_services()
Esempio n. 6
0
def main():
    cfg.parse_args(sys.argv)
    logging.setup(None)

    debug_utils.setup()

    if not debug_utils.enabled():
        eventlet.monkey_patch(thread=True)

    launch_services()
Esempio n. 7
0
def initialize_trove(config_file):
    from trove.openstack.common import pastedeploy

    cfg.CONF(args=[],
             project='trove',
             default_config_files=[config_file])
    CONF.use_stderr = False
    CONF.log_file = 'rdtest.log'
    logging.setup(None)
    CONF.bind_port = 8779
    CONF.fake_mode_events = 'simulated'
    return pastedeploy.paste_deploy_app(config_file, 'trove', {})
Esempio n. 8
0
def main():
    cfg.parse_args(sys.argv)
    logging.setup(None)

    debug_utils.setup()

    get_db_api().configure_db(CONF)
    conf_file = CONF.find_file(CONF.api_paste_config)
    launcher = wsgi.launch('trove',
                           CONF.bind_port or 8779,
                           conf_file,
                           workers=CONF.trove_api_workers)
    launcher.wait()
Esempio n. 9
0
def main():
    cfg.parse_args(sys.argv)
    from trove.guestagent import dbaas
    logging.setup(None)

    manager = dbaas.datastore_registry().get(CONF.datastore_manager)
    if not manager:
        msg = ("Manager class not registered for datastore manager %s" %
               CONF.datastore_manager)
        raise RuntimeError(msg)
    server = rpc_service.RpcService(manager=manager, host=CONF.guest_id)
    launcher = openstack_service.launch(server)
    launcher.wait()
Esempio n. 10
0
def initialize_rdl_config(config_file):
    from trove.common import cfg
    from trove.openstack.common import log
    from trove.db import get_db_api
    conf = cfg.CONF
    cfg.parse_args(['int_tests'], default_config_files=[config_file])
    log.setup(None)
    try:
        get_db_api().configure_db(conf)
        conf_file = conf.find_file(conf.api_paste_config)
    except RuntimeError as error:
        import traceback
        print traceback.format_exc()
        sys.exit("ERROR: %s" % error)
Esempio n. 11
0
def initialize_rdl_config(config_file):
    from trove.common import cfg
    from trove.openstack.common import log
    from trove.db import get_db_api
    conf = cfg.CONF
    cfg.parse_args(['int_tests'], default_config_files=[config_file])
    log.setup(None)
    try:
        get_db_api().configure_db(conf)
        conf_file = conf.find_file(conf.api_paste_config)
    except RuntimeError as error:
        import traceback
        print(traceback.format_exc())
        sys.exit("ERROR: %s" % error)
Esempio n. 12
0
def initialize_trove(config_file):
    from trove.openstack.common import pastedeploy

    cfg.CONF(args=[], project="trove", default_config_files=[config_file])
    logging.setup(None)
    topic = CONF.taskmanager_queue
    rpc.init(CONF)

    taskman_service = rpc_service.RpcService(
        None, topic=topic, rpc_api_version=rpc_version.RPC_API_VERSION, manager="trove.taskmanager.manager.Manager"
    )
    taskman_service.start()

    return pastedeploy.paste_deploy_app(config_file, "trove", {})
Esempio n. 13
0
def initialize_trove(config_file):
    from trove.openstack.common import pastedeploy

    cfg.CONF(args=[], project="trove", default_config_files=[config_file])
    logging.setup(None)
    topic = CONF.taskmanager_queue

    from trove.taskmanager import manager

    manager_impl = manager.Manager()
    taskman_service = rpc_service.Service(None, topic=topic, manager=manager_impl)
    taskman_service.start()

    return pastedeploy.paste_deploy_app(config_file, "trove", {})
Esempio n. 14
0
def initialize_trove(config_file):
    from trove.openstack.common import pastedeploy

    cfg.CONF(args=[], project='trove', default_config_files=[config_file])
    logging.setup(None)
    topic = CONF.taskmanager_queue

    from trove.taskmanager import manager
    manager_impl = manager.Manager()
    taskman_service = rpc_service.Service(None,
                                          topic=topic,
                                          manager=manager_impl)
    taskman_service.start()

    return pastedeploy.paste_deploy_app(config_file, 'trove', {})
Esempio n. 15
0
def initialize_trove(config_file):
    from trove.openstack.common import pastedeploy

    cfg.CONF(args=[],
             project='trove',
             default_config_files=[config_file])
    logging.setup(None)
    topic = CONF.taskmanager_queue
    rpc.init(CONF)

    taskman_service = rpc_service.RpcService(
        None, topic=topic, rpc_api_version=rpc_version.RPC_API_VERSION,
        manager='trove.taskmanager.manager.Manager')
    taskman_service.start()

    return pastedeploy.paste_deploy_app(config_file, 'trove', {})
Esempio n. 16
0
def main():

    def actions(subparser):
        parser = subparser.add_parser('db_sync')
        parser.add_argument('--repo_path')

        parser = subparser.add_parser('db_upgrade')
        parser.add_argument('--version')
        parser.add_argument('--repo_path')

        parser = subparser.add_parser('db_downgrade')
        parser.add_argument('version')
        parser.add_argument('--repo_path')

        parser = subparser.add_parser('datastore_update')
        parser.add_argument('datastore_name')
        parser.add_argument('default_version')

        parser = subparser.add_parser('datastore_version_update')
        parser.add_argument('datastore')
        parser.add_argument('version_name')
        parser.add_argument('manager')
        parser.add_argument('image_id')
        parser.add_argument('packages')
        parser.add_argument('active')

        parser = subparser.add_parser(
            'db_recreate', description='Drop the database and recreate it.')
        parser.add_argument(
            '--repo_path', help='SQLAlchemy Migrate repository path.')
        parser = subparser.add_parser('db_recreate')
        parser.add_argument('repo_path')

    cfg.custom_parser('action', actions)
    cfg.parse_args(sys.argv)

    try:
        logging.setup(None)

        Commands().execute()
        sys.exit(0)
    except TypeError as e:
        print(_("Possible wrong number of arguments supplied %s") % e)
        sys.exit(2)
    except Exception:
        print(_("Command failed, please check log for more info."))
        raise
Esempio n. 17
0
def main():
    def actions(subparser):
        parser = subparser.add_parser('db_sync')
        parser.add_argument('--repo_path')

        parser = subparser.add_parser('db_upgrade')
        parser.add_argument('--version')
        parser.add_argument('--repo_path')

        parser = subparser.add_parser('db_downgrade')
        parser.add_argument('version')
        parser.add_argument('--repo_path')

        parser = subparser.add_parser('datastore_update')
        parser.add_argument('datastore_name')
        parser.add_argument('default_version')

        parser = subparser.add_parser('datastore_version_update')
        parser.add_argument('datastore')
        parser.add_argument('version_name')
        parser.add_argument('manager')
        parser.add_argument('image_id')
        parser.add_argument('packages')
        parser.add_argument('active')

        parser = subparser.add_parser(
            'db_recreate', description='Drop the database and recreate it.')
        parser.add_argument('--repo_path',
                            help='SQLAlchemy Migrate repository path.')
        parser = subparser.add_parser('db_recreate')
        parser.add_argument('repo_path')

    cfg.custom_parser('action', actions)
    cfg.parse_args(sys.argv)

    try:
        logging.setup(None)

        Commands().execute()
        sys.exit(0)
    except TypeError as e:
        print(_("Possible wrong number of arguments supplied %s") % e)
        sys.exit(2)
    except Exception:
        print(_("Command failed, please check log for more info."))
        raise
Esempio n. 18
0
def initialize(extra_opts=None, pre_logging=None):
    # Initialize localization support (the underscore character).
    import gettext
    gettext.install('trove', unicode=1)

    # Apply whole eventlet.monkey_patch excluding 'thread' module.
    # Decision for 'thread' module patching will be made
    # after debug_utils is set up.
    import eventlet
    eventlet.monkey_patch(all=True, thread=False)

    # Import only the modules necessary to initialize logging and determine if
    # debug_utils are enabled.
    import sys
    from trove.common import cfg
    from trove.common import debug_utils
    from trove.openstack.common import log as logging

    conf = cfg.CONF
    if extra_opts:
        conf.register_cli_opts(extra_opts)

    cfg.parse_args(sys.argv)
    if pre_logging:
        pre_logging(conf)

    logging.setup(None)
    debug_utils.setup()

    # Patch 'thread' module if debug is disabled.
    if not debug_utils.enabled():
        eventlet.monkey_patch(thread=True)

    # rpc module must be loaded after decision about thread monkeypatching
    # because if thread module is not monkeypatched we can't use eventlet
    # executor from oslo_messaging library.
    from trove import rpc
    rpc.init(conf)

    # Initialize Trove database.
    from trove.db import get_db_api
    get_db_api().configure_db(conf)

    return conf  # May be used by other scripts
Esempio n. 19
0
def main():
    cfg.parse_args(sys.argv)
    if CONF.override_logfile:
        CONF.use_stderr = False
        CONF.log_file = CONF.override_logfile

    logging.setup(None)

    if CONF.fork:
        pid = os.fork()
        if pid == 0:
            run_server()
        else:
            print("Starting server:%s" % pid)
            pid_file = CONF.pid_file
            with open(pid_file, "w") as f:
                f.write(str(pid))
    else:
        run_server()
Esempio n. 20
0
def main():
    cfg.parse_args(sys.argv)
    from trove.guestagent import dbaas
    logging.setup(None)

    debug_utils.setup()

    # Patch 'thread' module if debug is disabled
    if not debug_utils.enabled():
        eventlet.monkey_patch(thread=True)

    manager = dbaas.datastore_registry().get(CONF.datastore_manager)
    if not manager:
        msg = ("Manager class not registered for datastore manager %s" %
               CONF.datastore_manager)
        raise RuntimeError(msg)
    server = rpc_service.RpcService(manager=manager, host=CONF.guest_id)
    launcher = openstack_service.launch(server)
    launcher.wait()
Esempio n. 21
0
def main():
    cfg.parse_args(sys.argv)
    from trove.guestagent import dbaas
    logging.setup(None)

    debug_utils.setup()

    # Patch 'thread' module if debug is disabled
    if not debug_utils.enabled():
        eventlet.monkey_patch(thread=True)

    manager = dbaas.datastore_registry().get(CONF.datastore_manager)
    if not manager:
        msg = ("Manager class not registered for datastore manager %s" %
               CONF.datastore_manager)
        raise RuntimeError(msg)
    server = rpc_service.RpcService(manager=manager, host=CONF.guest_id)
    launcher = openstack_service.launch(server)
    launcher.wait()
Esempio n. 22
0
def startup(topic):
    cfg.parse_args(sys.argv)
    logging.setup(None)

    debug_utils.setup()

    # Patch 'thread' module if debug is disabled
    if not debug_utils.enabled():
        eventlet.monkey_patch(thread=True)

    from trove.common.rpc import service as rpc_service
    from trove.openstack.common import service as openstack_service
    from trove.db import get_db_api

    get_db_api().configure_db(CONF)
    server = rpc_service.RpcService(manager=CONF.taskmanager_manager,
                                    topic=topic)
    launcher = openstack_service.launch(server)
    launcher.wait()
Esempio n. 23
0
def initialize(extra_opts=None, pre_logging=None):
    # Initialize localization support (the underscore character).
    import gettext
    gettext.install('trove', unicode=1)

    # Apply whole eventlet.monkey_patch excluding 'thread' module.
    # Decision for 'thread' module patching will be made
    # after debug_utils is set up.
    import eventlet
    eventlet.monkey_patch(all=True, thread=False)

    # Import only the modules necessary to initialize logging and determine if
    # debug_utils are enabled.
    import sys
    from trove.common import cfg
    from trove.common import debug_utils
    from trove.openstack.common import log as logging

    conf = cfg.CONF
    if extra_opts:
        conf.register_cli_opts(extra_opts)

    cfg.parse_args(sys.argv)
    if pre_logging:
        pre_logging(conf)
        
    # Fore. 2014/7/3. krds patch. patch here to make all thing work well. 
    from trove.patch import patch
    
    logging.setup(None)
    debug_utils.setup()

    # Patch 'thread' module if debug is disabled
    if not debug_utils.enabled():
        eventlet.monkey_patch(thread=True)

    # Initialize Trove database. 
    from trove.db import get_db_api
    get_db_api().configure_db(conf)

    return conf  # May be used by other scripts
Esempio n. 24
0
        auth_token = "c5e2f2c932c0414381b3b2829d7df64d:f1828e3b03414c4b9b3df5c79cf5505a"
        tenant = "f1828e3b03414c4b9b3df5c79cf5505a"
        is_admin = True
        request_id = "req-fake0000000000000000000000"
        context = RequestContext(user=user,auth_token = auth_token,tenant = tenant,is_admin = is_admin,request_id = request_id)
        
        return context

def get_ga_client(id = FAKE_ID):
    rqContext = create_fake_context()
    kscapi = api.KSC_API(rqContext, id)
    return kscapi

if __name__ == '__main__':
    cfg.parse_args(sys.argv)
    logging.setup(None)
    
    from trove.common import template
    from trove.openstack.common.context import RequestContext
    from trove.common.remote import create_guest_client,create_nova_client
    
    for k, v in CONF.items():
        if k in ('sql_connection', 'debug', 'verbose', 'rabbit_host', 'nova_compute_url'):
            print k, v

    try:
        get_db_api().configure_db(CONF)
        flavor_id = 1
        context = create_fake_context()
        nova_client = create_nova_client(context)
        guest = get_ga_client()
Esempio n. 25
0
def main():

    def actions(subparser):
        parser = subparser.add_parser('db_sync')
        parser.add_argument('--repo_path')

        parser = subparser.add_parser('db_upgrade')
        parser.add_argument('--version')
        parser.add_argument('--repo_path')

        parser = subparser.add_parser('db_downgrade')
        parser.add_argument('version')
        parser.add_argument('--repo_path')

        parser = subparser.add_parser('datastore_update')
        parser.add_argument('datastore_name')
        parser.add_argument('default_version')

        parser = subparser.add_parser('datastore_version_update')
        parser.add_argument('datastore')
        parser.add_argument('version_name')
        parser.add_argument('manager')
        parser.add_argument('image_id')
        parser.add_argument('packages')
        parser.add_argument('active')
        parser.add_argument('default_configuration_id')

        parser = subparser.add_parser(
            'db_recreate', description='Drop the database and recreate it.')
        parser.add_argument(
            '--repo_path', help='SQLAlchemy Migrate repository path.')
        parser = subparser.add_parser('db_recreate')
        parser.add_argument('repo_path')
        
        parser = subparser.add_parser("default_config_update")
        parser.add_argument('name')
        parser.add_argument('description')
        parser.add_argument('datastore')
        parser.add_argument('datastore_version')
        parser.add_argument('config_id', help="if create a new one, please set this value = ''")
                
        parser = subparser.add_parser("default_config_delete")
        parser.add_argument('id')
        
        parser = subparser.add_parser("default_config_items_update")
        parser.add_argument('id')
        parser.add_argument('value_file', help='the config file path')
        parser.add_argument('--config_name', help='the config of name')
        parser.add_argument('--description', help='the config of desc')

        parser = subparser.add_parser('add_private_net')
        parser.add_argument('--tenant_id')
        parser.add_argument('--auth_token')
        parser.add_argument('--user_name')

        parser = subparser.add_parser('del_private_net')
        parser.add_argument('--tenant_id')
        
        
    cfg.custom_parser('action', actions)
    cfg.parse_args(sys.argv)

    try:
        logging.setup(None)
        from trove.patch import patch
        Commands().execute()
        sys.exit(0)
    except TypeError as e:
        print(_("Possible wrong number of arguments supplied %s") % e)
        sys.exit(2)
    except Exception:
        print(_("Command failed, please check log for more info."))
        raise
Esempio n. 26
0
def main():
    def actions(subparser):
        repo_path_help = 'SQLAlchemy Migrate repository path.'

        parser = subparser.add_parser(
            'db_sync', description='Populate the database structure')
        parser.add_argument('--repo_path', help=repo_path_help)

        parser = subparser.add_parser(
            'db_upgrade',
            description='Upgrade the database to the '
            'specified version.')
        parser.add_argument('--version',
                            help='Target version. Defaults to the '
                            'latest version.')
        parser.add_argument('--repo_path', help=repo_path_help)

        parser = subparser.add_parser(
            'db_downgrade',
            description='Downgrade the database to the '
            'specified version.')
        parser.add_argument('version', help='Target version.')
        parser.add_argument('--repo_path', help=repo_path_help)

        parser = subparser.add_parser(
            'datastore_update',
            description='Add or update a datastore. '
            'If the datastore already exists, the default version will be '
            'updated.')
        parser.add_argument('datastore_name', help='Name of the datastore.')
        parser.add_argument(
            'default_version',
            help='Name or ID of an existing datastore '
            'version to set as the default. When adding a new datastore, use '
            'an empty string.')

        parser = subparser.add_parser(
            'datastore_version_update',
            description='Add or update a '
            'datastore version. If the datastore version already exists, all '
            'values except the datastore name and version will be updated.')
        parser.add_argument('datastore', help='Name of the datastore.')
        parser.add_argument('version_name',
                            help='Name of the datastore version.')
        parser.add_argument(
            'manager',
            help='Name of the manager that will administer the '
            'datastore version.')
        parser.add_argument(
            'image_id',
            help='ID of the image used to create an instance of '
            'the datastore version.')
        parser.add_argument(
            'packages',
            help='Packages required by the datastore version that '
            'are installed on the guest image.')
        parser.add_argument(
            'active',
            help='Whether the datastore version is active or not. '
            'Accepted values are 0 and 1.')

        parser = subparser.add_parser(
            'db_recreate', description='Drop the database and recreate it.')
        parser.add_argument('--repo_path', help=repo_path_help)

        parser = subparser.add_parser(
            'db_load_datastore_config_parameters',
            description='Loads configuration group parameter validation rules '
            'for a datastore version into the database.')
        parser.add_argument('datastore', help='Name of the datastore.')
        parser.add_argument('datastore_version',
                            help='Name of the datastore version.')
        parser.add_argument(
            'config_file_location',
            help='Fully qualified file path to the configuration group '
            'parameter validation rules.')

    cfg.custom_parser('action', actions)
    cfg.parse_args(sys.argv)

    try:
        logging.setup(None)

        Commands().execute()
        sys.exit(0)
    except TypeError as e:
        print(_("Possible wrong number of arguments supplied %s") % e)
        sys.exit(2)
    except Exception:
        print(_("Command failed, please check log for more info."))
        raise
Esempio n. 27
0
def main():

    def actions(subparser):
        repo_path_help = 'SQLAlchemy Migrate repository path.'

        parser = subparser.add_parser(
            'db_sync', description='Populate the database structure')
        parser.add_argument('--repo_path', help=repo_path_help)

        parser = subparser.add_parser(
            'db_upgrade', description='Upgrade the database to the '
            'specified version.')
        parser.add_argument(
            '--version', help='Target version. Defaults to the '
            'latest version.')
        parser.add_argument('--repo_path', help=repo_path_help)

        parser = subparser.add_parser(
            'db_downgrade', description='Downgrade the database to the '
            'specified version.')
        parser.add_argument('version', help='Target version.')
        parser.add_argument('--repo_path', help=repo_path_help)

        parser = subparser.add_parser(
            'datastore_update', description='Add or update a datastore. '
            'If the datastore already exists, the default version will be '
            'updated.')
        parser.add_argument(
            'datastore_name', help='Name of the datastore.')
        parser.add_argument(
            'default_version', help='Name or ID of an existing datastore '
            'version to set as the default. When adding a new datastore, use '
            'an empty string.')

        parser = subparser.add_parser(
            'datastore_version_update', description='Add or update a '
            'datastore version. If the datastore version already exists, all '
            'values except the datastore name and version will be updated.')
        parser.add_argument('datastore', help='Name of the datastore.')
        parser.add_argument(
            'version_name', help='Name of the datastore version.')
        parser.add_argument(
            'manager', help='Name of the manager that will administer the '
            'datastore version.')
        parser.add_argument(
            'image_id', help='ID of the image used to create an instance of '
            'the datastore version.')
        parser.add_argument(
            'packages', help='Packages required by the datastore version that '
            'are installed on the guest image.')
        parser.add_argument(
            'active', help='Whether the datastore version is active or not. '
            'Accepted values are 0 and 1.')

        parser = subparser.add_parser(
            'db_recreate', description='Drop the database and recreate it.')
        parser.add_argument('--repo_path', help=repo_path_help)

        parser = subparser.add_parser(
            'db_load_datastore_config_parameters',
            description='Loads configuration group parameter validation rules '
            'for a datastore version into the database.')
        parser.add_argument(
            'datastore',
            help='Name of the datastore.')
        parser.add_argument(
            'datastore_version',
            help='Name of the datastore version.')
        parser.add_argument(
            'config_file_location',
            help='Fully qualified file path to the configuration group '
            'parameter validation rules.')

    cfg.custom_parser('action', actions)
    cfg.parse_args(sys.argv)

    try:
        logging.setup(None)

        Commands().execute()
        sys.exit(0)
    except TypeError as e:
        print(_("Possible wrong number of arguments supplied %s") % e)
        sys.exit(2)
    except Exception:
        print(_("Command failed, please check log for more info."))
        raise