Ejemplo n.º 1
0
def create_application(arguments):
    database_metadata = None
    if arguments.database.startswith("postgresql://"):
        database_metadata = importlib.import_module(
            "bhamon_orchestra_model.database.sql_database_model").metadata

    database_administration_factory = factory.create_database_administration_factory(
        arguments.database, database_metadata)
    database_client_factory = factory.create_database_client_factory(
        arguments.database, database_metadata)
    data_storage_instance = FileDataStorage(".")
    date_time_provider_instance = DateTimeProvider()

    application = types.SimpleNamespace()
    application.database_administration_factory = database_administration_factory
    application.database_client_factory = database_client_factory
    application.authentication_provider = AuthenticationProvider(
        date_time_provider_instance)
    application.authorization_provider = AuthorizationProvider()
    application.job_provider = JobProvider(date_time_provider_instance)
    application.project_provider = ProjectProvider(date_time_provider_instance)
    application.run_provider = RunProvider(data_storage_instance,
                                           date_time_provider_instance)
    application.schedule_provider = ScheduleProvider(
        date_time_provider_instance)
    application.user_provider = UserProvider(date_time_provider_instance)
    application.worker_provider = WorkerProvider(date_time_provider_instance)

    return application
Ejemplo n.º 2
0
def create_application(configuration):
    database_metadata = None
    if configuration["orchestra_database_uri"].startswith("postgresql://"):
        database_metadata = importlib.import_module(
            "bhamon_orchestra_model.database.sql_database_model").metadata

    database_client_factory = factory.create_database_client_factory(
        database_uri=configuration["orchestra_database_uri"],
        database_authentication=configuration[
            "orchestra_database_authentication"],
        database_metadata=database_metadata,
    )

    data_storage_instance = FileDataStorage(
        configuration["orchestra_file_storage_path"])
    date_time_provider_instance = DateTimeProvider()

    application = flask.Flask(__name__)
    application.database_client_factory = database_client_factory
    application.authentication_provider = AuthenticationProvider(
        date_time_provider_instance)
    application.authorization_provider = AuthorizationProvider()
    application.job_provider = JobProvider(date_time_provider_instance)
    application.project_provider = ProjectProvider(date_time_provider_instance)
    application.run_provider = RunProvider(data_storage_instance,
                                           date_time_provider_instance)
    application.schedule_provider = ScheduleProvider(
        date_time_provider_instance)
    application.user_provider = UserProvider(date_time_provider_instance)
    application.worker_provider = WorkerProvider(date_time_provider_instance)

    application.run_result_transformer = transform_run_results

    service.configure(application)
    service.register_handlers(application)
    service.register_routes(application)

    application.external_services = {
        "artifacts":
        FileServerClient("Artifact Server",
                         configuration["artifact_server_web_url"]),
        "github":
        GitHubClient(configuration.get("github_access_token", None)),
        "python_packages":
        FileServerClient("Python Package Repository",
                         configuration["python_package_repository_web_url"]),
    }

    application.config["GITHUB_ACCESS_TOKEN"] = configuration.get(
        "github_access_token", None)

    return application
Ejemplo n.º 3
0
def create_application(environment_instance):
	application = flask.Flask(__name__, static_folder = None)
	application.authorization_provider = AuthorizationProvider()
	application.date_time_provider = DateTimeProvider()
	application.service_url = environment_instance["orchestra_service_url"]
	application.secret_key = "secret"

	website.configure(application)
	website.register_handlers(application)
	website.register_routes(application)
	website.register_resources(application)

	application.add_url_rule("/me/routes", methods = [ "GET" ], view_func = list_routes)

	return application
Ejemplo n.º 4
0
    def __init__(self,
                 temporary_directory,
                 database_type,
                 database_suffix=None):
        environment_instance = environment.load_test_context_environment(
            str(temporary_directory), database_type)

        self.temporary_directory = str(temporary_directory)
        self.master_address = environment_instance["master_address"]
        self.master_port = environment_instance["master_port"]
        self.service_address = environment_instance["service_address"]
        self.service_port = environment_instance["service_port"]
        self.website_address = environment_instance["website_address"]
        self.website_port = environment_instance["website_port"]
        self.database_uri = environment_instance["database_uri"]
        self.process_collection = []

        if self.database_uri is not None:
            self.database_uri += ("_" +
                                  database_suffix) if database_suffix else ""

            date_time_provider_instance = DateTimeProvider()

            self.database_administration_factory = factory.create_database_administration_factory(
                self.database_uri, sql_database_model.metadata)
            self.database_client_factory = factory.create_database_client_factory(
                self.database_uri, sql_database_model.metadata)
            self.data_storage = FileDataStorage(
                os.path.join(self.temporary_directory, "master"))

            self.authentication_provider = AuthenticationProvider(
                date_time_provider_instance)
            self.authorization_provider = AuthorizationProvider()
            self.job_provider = JobProvider(date_time_provider_instance)
            self.project_provider = ProjectProvider(
                date_time_provider_instance)
            self.run_provider = RunProvider(self.data_storage,
                                            date_time_provider_instance)
            self.schedule_provider = ScheduleProvider(
                date_time_provider_instance)
            self.user_provider = UserProvider(date_time_provider_instance)
            self.worker_provider = WorkerProvider(date_time_provider_instance)
Ejemplo n.º 5
0
def create_application(configuration):
	application = flask.Flask(__name__, static_folder = None)
	application.authorization_provider = AuthorizationProvider()
	application.date_time_provider = DateTimeProvider()
	application.artifact_server_url = configuration["artifact_server_web_url"]
	application.python_package_repository_url = configuration["python_package_repository_web_url"]
	application.service_url = configuration["orchestra_service_url"]
	application.secret_key = configuration["orchestra_website_secret"]

	resource_paths = [
		os.path.dirname(bhamon_orchestra_configuration.__file__),
		os.path.dirname(bhamon_orchestra_website.__file__),
	]

	website.configure(application)
	website.register_handlers(application)
	website.register_resources(application, resource_paths)
	website.register_routes(application)
	website_extensions.register_routes(application)

	return application
Ejemplo n.º 6
0
def create_application(arguments):
    database_metadata = None
    if arguments.database.startswith("postgresql://"):
        database_metadata = importlib.import_module(
            "bhamon_orchestra_model.database.sql_database_model").metadata

    database_client_factory = factory.create_database_client_factory(
        arguments.database, database_metadata)
    data_storage_instance = FileDataStorage(".")
    date_time_provider_instance = DateTimeProvider()

    application = flask.Flask(__name__)
    application.database_client_factory = database_client_factory
    application.authentication_provider = AuthenticationProvider(
        date_time_provider_instance)
    application.authorization_provider = AuthorizationProvider()
    application.job_provider = JobProvider(date_time_provider_instance)
    application.project_provider = ProjectProvider(date_time_provider_instance)
    application.run_provider = RunProvider(data_storage_instance,
                                           date_time_provider_instance)
    application.schedule_provider = ScheduleProvider(
        date_time_provider_instance)
    application.user_provider = UserProvider(date_time_provider_instance)
    application.worker_provider = WorkerProvider(date_time_provider_instance)

    application.run_result_transformer = transform_run_results

    application.external_services = {}

    service.configure(application)
    service.register_handlers(application)
    service.register_routes(application)

    application.add_url_rule("/me/routes",
                             methods=["GET"],
                             view_func=list_routes)

    return application
Ejemplo n.º 7
0
def create_application(configuration): # pylint: disable = too-many-locals
	database_metadata = None
	if configuration["orchestra_database_uri"].startswith("postgresql://"):
		database_metadata = importlib.import_module("bhamon_orchestra_model.database.sql_database_model").metadata

	database_client_factory = factory.create_database_client_factory(
		database_uri = configuration["orchestra_database_uri"],
		database_authentication = configuration["orchestra_database_authentication"],
		database_metadata = database_metadata,
	)

	data_storage_instance = FileDataStorage(configuration["orchestra_file_storage_path"])
	date_time_provider_instance = DateTimeProvider()

	authentication_provider_instance = AuthenticationProvider(date_time_provider_instance)
	authorization_provider_instance = AuthorizationProvider()
	job_provider_instance = JobProvider(date_time_provider_instance)
	project_provider_instance = ProjectProvider(date_time_provider_instance)
	run_provider_instance = RunProvider(data_storage_instance, date_time_provider_instance)
	schedule_provider_instance = ScheduleProvider(date_time_provider_instance)
	user_provider_instance = UserProvider(date_time_provider_instance)
	worker_provider_instance = WorkerProvider(date_time_provider_instance)

	protocol_factory = functools.partial(
		WebSocketServerProtocol,
		database_client_factory = database_client_factory,
		user_provider = user_provider_instance,
		authentication_provider = authentication_provider_instance,
		authorization_provider = authorization_provider_instance,
	)

	supervisor_instance = Supervisor(
		host = configuration["orchestra_master_listen_address"],
		port = configuration["orchestra_master_listen_port"],
		protocol_factory = protocol_factory,
		database_client_factory = database_client_factory,
		worker_provider = worker_provider_instance,
		run_provider = run_provider_instance,
	)

	worker_selector_instance = WorkerSelector(
		database_client_factory = database_client_factory,
		worker_provider = worker_provider_instance,
		supervisor = supervisor_instance,
	)

	job_scheduler_instance = JobScheduler(
		database_client_factory = database_client_factory,
		job_provider = job_provider_instance,
		run_provider = run_provider_instance,
		schedule_provider = schedule_provider_instance,
		supervisor = supervisor_instance,
		worker_selector = worker_selector_instance,
		date_time_provider = date_time_provider_instance,
	)

	master_instance = Master(
		database_client_factory = database_client_factory,
		project_provider = project_provider_instance,
		job_provider = job_provider_instance,
		schedule_provider = schedule_provider_instance,
		worker_provider = worker_provider_instance,
		job_scheduler = job_scheduler_instance,
		supervisor = supervisor_instance,
	)

	return master_instance
Ejemplo n.º 8
0
def create_application(arguments):  # pylint: disable = too-many-locals
    database_metadata = None
    if arguments.database.startswith("postgresql://"):
        database_metadata = importlib.import_module(
            "bhamon_orchestra_model.database.sql_database_model").metadata

    database_client_factory = factory.create_database_client_factory(
        arguments.database, database_metadata)
    data_storage_instance = FileDataStorage(".")
    date_time_provider_instance = DateTimeProvider()

    authentication_provider_instance = AuthenticationProvider(
        date_time_provider_instance)
    authorization_provider_instance = AuthorizationProvider()
    job_provider_instance = JobProvider(date_time_provider_instance)
    project_provider_instance = ProjectProvider(date_time_provider_instance)
    run_provider_instance = RunProvider(data_storage_instance,
                                        date_time_provider_instance)
    schedule_provider_instance = ScheduleProvider(date_time_provider_instance)
    user_provider_instance = UserProvider(date_time_provider_instance)
    worker_provider_instance = WorkerProvider(date_time_provider_instance)

    protocol_factory = functools.partial(
        WebSocketServerProtocol,
        database_client_factory=database_client_factory,
        user_provider=user_provider_instance,
        authentication_provider=authentication_provider_instance,
        authorization_provider=authorization_provider_instance,
    )

    supervisor_instance = Supervisor(
        host=arguments.address,
        port=arguments.port,
        protocol_factory=protocol_factory,
        database_client_factory=database_client_factory,
        worker_provider=worker_provider_instance,
        run_provider=run_provider_instance,
    )

    worker_selector_instance = WorkerSelector(
        database_client_factory=database_client_factory,
        worker_provider=worker_provider_instance,
        supervisor=supervisor_instance,
    )

    job_scheduler_instance = JobScheduler(
        database_client_factory=database_client_factory,
        job_provider=job_provider_instance,
        run_provider=run_provider_instance,
        schedule_provider=schedule_provider_instance,
        supervisor=supervisor_instance,
        worker_selector=worker_selector_instance,
        date_time_provider=date_time_provider_instance,
    )

    master_instance = Master(
        database_client_factory=database_client_factory,
        project_provider=project_provider_instance,
        job_provider=job_provider_instance,
        schedule_provider=schedule_provider_instance,
        worker_provider=worker_provider_instance,
        job_scheduler=job_scheduler_instance,
        supervisor=supervisor_instance,
    )

    # Rapid updates to reduce delays in tests
    job_scheduler_instance.update_interval_seconds = 1
    supervisor_instance.update_interval_seconds = 1

    return master_instance