Beispiel #1
0
def configure_module(flask_app):
    load_model_layers()
    try:
        IOC.get_class_instance(ReleaseRouter, flask_app).configure_urls()
    except:
        import traceback
        traceback.print_exc()
Beispiel #2
0
def setup_config_from_file(app, args):
    if app.rapid_config['_is'] == 'client':
        from ..client import client_configuration
        app.rapid_config = client_configuration.ClientConfiguration(
            args.config_file)
    elif app.rapid_config['_is'] == 'master':
        from ..master import master_configuration
        app.rapid_config = master_configuration.MasterConfiguration(
            args.config_file)
    IOC.register_global('rapid_config', app.rapid_config)
Beispiel #3
0
def configure_module(flask_app):
    load_model_layers()

    try:
        IOC.get_class_instance(GithubController,
                               flask_app).register_url_rules(flask_app)
        IOC.get_class_instance(CIController).register_url_rules()
    except Exception:  # pylint: disable=broad-except
        import traceback
        traceback.print_exc()
Beispiel #4
0
    def test_setup_dals(self):
        mock_app = Mock()
        IOC.register_global(ModuleConstants.CI_MODULE, Mock())
        IOC.register_global('flask_app', mock_app)
        setup_dals(mock_app)

        for clazz in [
                Action, ActionInstance, Pipeline, PipelineInstance,
                PipelineParameters, PipelineStatistics, Stage, StageInstance,
                Statistics, Status, Workflow, WorkflowInstance
        ]:
            if Pipeline == clazz:
                eq_(PipelineDal, get_dal(clazz).__class__, clazz)
            else:
                eq_(GeneralDal, get_dal(clazz).__class__, clazz)
Beispiel #5
0
def register_ioc_globals(flask_app):  # pylint: disable=unused-argument
    from rapid.workflow.action_service import ActionService
    from rapid.workflow.workflow_service import WorkflowService
    from rapid.lib.queue_handler_constants import QueueHandlerConstants
    from rapid.workflow.queue_handlers import setup_queue_handlers

    setup_queue_handlers()

    IOC.register_global('queue_constants',
                        IOC.get_class_instance(QueueHandlerConstants))
    IOC.register_global('workflow_module',
                        IOC.get_class_instance(WorkflowService))
    IOC.register_global('action_module', IOC.get_class_instance(ActionService))
Beispiel #6
0
def setup_dals(flask_app):
    from rapid.master.data.database.dal.general_dal import GeneralDal
    from rapid.workflow.data.dal.pipeline_dal import PipelineDal

    for dal in [PipelineDal, GeneralDal]:
        tmp = IOC.get_class_instance(dal)
        tmp.register_url_rules(flask_app)
        registered_dals.append(tmp)
Beispiel #7
0
def configure_application(flask_app, args, manual_db_upgrade=False):
    IOC.register_global('flask_app', flask_app)
    setup_config_from_file(flask_app, args)
    configure_db()
    configure_sub_modules(flask_app, args)
    configure_data_layer(flask_app)
    register_controllers(flask_app)
    setup_status_route(flask_app)

    if args.static_file_dir:
        flask_app.rapid_config.static_file_directory = args.static_file_dir

    if args.basic_auth:
        flask_app.rapid_config.set_basic_auth(args.basic_auth)

    if is_primary_worker() and not manual_db_upgrade:
        if args.db_downgrade:
            run_db_downgrade(flask_app, args.db_downgrade)
        else:
            run_db_upgrades(flask_app)
            setup_queue_thread(flask_app)
Beispiel #8
0
def run_queue(flask_app):
    from rapid.lib.store_service import StoreService
    from rapid.workflow.queue import Queue
    with flask_app.app_context():
        queue = IOC.get_class_instance(Queue)  # type: Queue
        while True:
            clients = []
            try:
                clients = StoreService.get_clients(flask_app)
            except:
                pass

            try:
                queue.process_queue(clients)
            except Exception as exception:
                logger.error(exception)

            try:
                queue.verify_still_working(clients)
            except Exception as exception:
                logger.error(exception)

            try:
                queue.reconcile_pipeline_instances()
            except Exception as exception:
                logger.error(exception)

            try:
                queue.reconcile_releases()
            except Exception as exception:
                logger.exception(exception)

            filtered_clients = {
                name: client
                for name, client in list(clients.items())
                if not hasattr(client, 'no-longer-active')
            }

            if filtered_clients != clients:
                StoreService.save_clients(filtered_clients, flask_app)
            time.sleep(flask_app.rapid_config.queue_time)
Beispiel #9
0
    def test_multi_dependency(self):
        testclass = IOC.get_class_instance(TestClass, "Something")

        eq_(False, testclass.trial.has_trial())
Beispiel #10
0
def load_extensions(flask_app):
    from rapid.lib.framework.ioc import IOC
    from rapid.extensions.extension_loader import ExtensionLoader
    extension_loader = IOC.get_class_instance(ExtensionLoader)
    extension_loader.load_extensions(flask_app)
Beispiel #11
0
def configure_module(flask_app):
    from rapid.workflow.api_controller import APIRouter
    router = IOC.get_class_instance(APIRouter)
    router.register_url_rules(flask_app)
Beispiel #12
0
def configure_module(flask_app):
    from rapid.qa.controllers.qa_controller import QAController
    controller = IOC.get_class_instance(QAController)
    controller.register_url_rules(flask_app)

    load_model_layers()
Beispiel #13
0
def register_ioc_globals(flask_app):  # pylint: disable=unused-argument
    IOC.register_global('qa_module', IOC.get_class_instance(QaService))