Exemple #1
0
def init_expr_components():
    from expr import ExprManager, AzureVMExprStarter, AzureHostedDockerStarter, AlaudaDockerStarter, K8SExprStarter
    factory.provide("expr_manager", ExprManager)
    factory.provide("alauda_docker", AlaudaDockerStarter)
    factory.provide("azure_docker", AzureHostedDockerStarter)
    factory.provide("azure_vm", AzureVMExprStarter)
    factory.provide("k8s_service", K8SExprStarter)
def init_expr_components():
    from expr import ExprManager, AzureVMExprStarter, AzureHostedDockerStarter, AlaudaDockerStarter, K8SExprStarter
    factory.provide("expr_manager", ExprManager)
    factory.provide("alauda_docker", AlaudaDockerStarter)
    factory.provide("azure_docker", AzureHostedDockerStarter)
    factory.provide("azure_vm", AzureVMExprStarter)
    factory.provide("k8s_service", K8SExprStarter)
Exemple #3
0
def init_voice_verify():
    """ initial voice verify service
    Example for config.py:
    "voice_verify": {
        "enabled": True,
        "provider": "rong_lian",
        "rong_lian": {
            ... ...
        }
    }
    """
    provider_name = safe_get_config("voice_verify.provider", None)
    enabled = safe_get_config("voice_verify.enabled", False)
    if not enabled:
        log.warn("voice verify disabled")
        factory.provide("voice_verify", DisabledVoiceVerify)
    elif provider_name and safe_get_config("voice_verify." + provider_name,
                                           None):
        log.warn("Voice verify initialized to:" + provider_name)
        # if provider other than Ronglian is supported, update following lines
        factory.provide("voice_verify", RonglianVoiceVerify)
    else:
        log.warn(
            "either voice verify provider name or provider config is missing, Please check your configuration"
        )
        raise ConfigurationException("voice_verify.provider")
Exemple #4
0
def init_hackathon_storage():
    """Add storage implementation to hackathon factory

    The type of storage is configured by ""storage.type"" in config.py which is 'local' by default
    """
    from hackathon.storage import AzureStorage, LocalStorage

    storage_type = safe_get_config("storage.type", "azure")
    if storage_type == "azure":
        factory.provide("storage", AzureStorage)
    else:
        factory.provide("storage", LocalStorage)
Exemple #5
0
def init_hackathon_storage():
    """Add storage implementation to hackathon factory

    The type of storage is configured by ""storage.type"" in config.py which is 'local' by default
    """
    from hackathon.storage import AzureStorage, LocalStorage

    storage_type = safe_get_config("storage.type", "azure")
    if storage_type == "azure":
        factory.provide("storage", AzureStorage)
    else:
        factory.provide("storage", LocalStorage)
def init_sms():
    """ initial SMS service """
    provider_name = safe_get_config("sms.provider", None)
    enabled = safe_get_config("sms.enabled", False)
    if not enabled:
        log.warn("SMS service disabled")
        factory.provide("sms", DisabledSms)
    elif provider_name and safe_get_config("sms." + provider_name, None):
        log.warn("SMS initialized to:" + provider_name)
        # if provider other than ChinaTelecom is supported, update following lines
        factory.provide("sms", ChinaTelecomSms)
    else:
        log.warn("Either SMS provider name or provider config is missing, Please check your configuration")
        raise ConfigurationException("sms.provider")
Exemple #7
0
def init_sms():
    """ initial SMS service """
    provider_name = safe_get_config("sms.provider", None)
    enabled = safe_get_config("sms.enabled", False)
    if not enabled:
        log.warn("SMS service disabled")
        factory.provide("sms", DisabledSms)
    elif provider_name and safe_get_config("sms." + provider_name, None):
        log.warn("SMS initialized to:" + provider_name)
        # if provider other than ChinaTelecom is supported, update following lines
        factory.provide("sms", ChinaTelecomSms)
    else:
        log.warn("Either SMS provider name or provider config is missing, Please check your configuration")
        raise ConfigurationException("sms.provider")
def init_voice_verify():
    """ initial voice verify service
    Example for config.py:
    "voice_verify": {
        "enabled": True,
        "provider": "rong_lian",
        "rong_lian": {
            ... ...
        }
    }
    """
    provider_name = safe_get_config("voice_verify.provider", None)
    enabled = safe_get_config("voice_verify.enabled", False)
    if not enabled:
        log.warn("voice verify disabled")
        factory.provide("voice_verify", DisabledVoiceVerify)
    elif provider_name and safe_get_config("voice_verify." + provider_name, None):
        log.warn("Voice verify initialized to:" + provider_name)
        # if provider other than Ronglian is supported, update following lines
        factory.provide("voice_verify", RonglianVoiceVerify)
    else:
        log.warn("either voice verify provider name or provider config is missing, Please check your configuration")
        raise ConfigurationException("voice_verify.provider")
Exemple #9
0
def init_hackathon_storage():
    """Add storage implementation to hackathon factory

    The type of storage is configured by ""storage.type"" in config.py which is 'local' by default
    """
    from hackathon.storage import AzureStorage, LocalStorage

    storage_type = safe_get_config("storage.type", "azure")
    if storage_type == "azure":
        # init BlobServiceAdapter first since AzureStorage depends on it. And accountKey must be included in config file
        from hackathon.hazure import BlobServiceAdapter
        factory.provide("azure_blob_service", BlobServiceAdapter)
        factory.provide("storage", AzureStorage)
    else:
        factory.provide("storage", LocalStorage)
Exemple #10
0
def init_hackathon_storage():
    """Add storage implementation to hackathon factory

    The type of storage is configured by ""storage.type"" in config.py which is 'local' by default
    """
    from hackathon.storage import AzureStorage, LocalStorage

    storage_type = safe_get_config("storage.type", "azure")
    if storage_type == "azure":
        # init BlobServiceAdapter first since AzureStorage depends on it. And accountKey must be included in config file
        from hackathon.hazure import BlobServiceAdapter
        factory.provide("azure_blob_service", BlobServiceAdapter)
        factory.provide("storage", AzureStorage)
    else:
        factory.provide("storage", LocalStorage)
def init_components():
    """Init hackathon factory"""
    from hackathon.user import UserManager, UserProfileManager
    from hackathon.hack import HackathonManager, AdminManager, TeamManager, DockerHostManager, \
        AzureCertManager, RegisterManager, HackathonTemplateManager, Cryptor
    from hackathon.template import TemplateLibrary
    from hackathon.remote.guacamole import GuacamoleInfo
    from hackathon.cache.cache_mgr import CacheManagerExt

    # dependencies MUST be provided in advance
    factory.provide("util", Utility)
    factory.provide("log", log)
    init_db()

    # utils
    init_voice_verify()
    init_sms()
    factory.provide("email", Email)

    # cache
    factory.provide("cache", CacheManagerExt)

    # scheduler
    factory.provide("scheduler", scheduler)

    # business components
    factory.provide("user_manager", UserManager)
    factory.provide("user_profile_manager", UserProfileManager)
    factory.provide("hackathon_manager", HackathonManager)
    factory.provide("register_manager", RegisterManager)
    factory.provide("azure_cert_manager", AzureCertManager)
    factory.provide("cryptor", Cryptor)
    factory.provide("docker_host_manager", DockerHostManager)
    factory.provide("hackathon_template_manager", HackathonTemplateManager)
    factory.provide("template_library", TemplateLibrary)
    factory.provide("admin_manager", AdminManager)
    factory.provide("team_manager", TeamManager)
    factory.provide("guacamole", GuacamoleInfo)

    # experiment starter
    init_expr_components()

    # health check items
    factory.provide("health_check_hosted_docker", get_class("hackathon.health.health_check.HostedDockerHealthCheck"))
    factory.provide("health_check_alauda_docker", get_class("hackathon.health.health_check.AlaudaDockerHealthCheck"))
    factory.provide("health_check_guacamole", get_class("hackathon.health.health_check.GuacamoleHealthCheck"))
    factory.provide("health_check_azure", get_class("hackathon.health.health_check.AzureHealthCheck"))
    factory.provide("health_check_mongodb", get_class("hackathon.health.health_check.MongoDBHealthCheck"))

    # docker
    factory.provide("hosted_docker_proxy", get_class("hackathon.docker.hosted_docker.HostedDockerFormation"))
    factory.provide("alauda_docker_proxy", get_class("hackathon.docker.alauda_docker.AlaudaDockerFormation"))

    # storage
    init_hackathon_storage()
Exemple #12
0
def init_components():
    """Init hackathon factory"""
    from hackathon.database import db_session
    from hackathon.database.db_adapters import SQLAlchemyAdapter
    from hackathon.user import UserManager
    from hackathon.azureformation.azure_file_service import FileService
    from hackathon.hack import HackathonManager, AdminManager, TeamManager, DockerHostManager, AzureCertManager
    from hackathon.registration.register_mgr import RegisterManager
    from hackathon.template.template_mgr import TemplateManager
    from hackathon.remote.guacamole import GuacamoleInfo
    from hackathon.expr.expr_mgr import ExprManager
    from hackathon.cache.cache_mgr import CacheManagerExt
    from hackathon.azureformation.azure_adapter import AzureAdapter
    from hackathon.azureformation.azure_subscription_service import SubscriptionService
    from hackathon.azureformation.azure_vm_service import AzureVMService
    from hackathon.azureformation.azure_storage_account_service import StorageAccount
    from hackathon.azureformation.azure_cloud_service import CloudService

    # dependencies MUST be provided in advance
    factory.provide("util", Utility)
    factory.provide("log", log)
    print '--------factory db---------'
    factory.provide("db", SQLAlchemyAdapter, db_session)
    print '--------end factory db---------'
    # scheduler
    factory.provide("scheduler", scheduler)

    # business components
    factory.provide("user_manager", UserManager)
    factory.provide("hackathon_manager", HackathonManager)
    factory.provide("register_manager", RegisterManager)
    factory.provide("file_service", FileService)
    factory.provide("azure_cert_manager", AzureCertManager)
    factory.provide("docker_host_manager", DockerHostManager)
    factory.provide("template_manager", TemplateManager)
    factory.provide("expr_manager", ExprManager)
    factory.provide("admin_manager", AdminManager)
    factory.provide("team_manager", TeamManager)
    factory.provide("guacamole", GuacamoleInfo)
    factory.provide("cache", CacheManagerExt)

    # health check items
    factory.provide("health_check_mysql", get_class("hackathon.health.health_check.MySQLHealthCheck"))
    factory.provide("health_check_hosted_docker", get_class("hackathon.health.health_check.HostedDockerHealthCheck"))
    factory.provide("health_check_alauda_docker", get_class("hackathon.health.health_check.AlaudaDockerHealthCheck"))
    factory.provide("health_check_guacamole", get_class("hackathon.health.health_check.GuacamoleHealthCheck"))
    factory.provide("health_check_azure", get_class("hackathon.health.health_check.AzureHealthCheck"))

    # docker
    factory.provide("docker", get_class("hackathon.docker.docker_helper.DockerHelper"))
    factory.provide("hosted_docker", get_class("hackathon.docker.hosted_docker.HostedDockerFormation"))
    factory.provide("alauda_docker", get_class("hackathon.docker.alauda_docker.AlaudaDockerFormation"))

    # azure
    factory.provide("azure_adapter", AzureAdapter)
    factory.provide("azure_subscription_service", SubscriptionService)
    factory.provide("azure_vm_service", AzureVMService)
    factory.provide("azure_cloud_service", CloudService)
    factory.provide("azure_storage_account_service", StorageAccount)

    # storage
    init_hackathon_storage()
def init_db():
    from hmongo import db
    factory.provide("db", db, suspend_callable=True)
Exemple #14
0
def init_components():
    """Init hackathon factory"""
    from hackathon.database import db_session
    from hackathon.database.db_adapters import SQLAlchemyAdapter
    from hackathon.user import UserManager, UserProfileManager
    from hackathon.hack import HackathonManager, AdminManager, TeamManager, DockerHostManager, \
        AzureCertManager, RegisterManager, HackathonTemplateManager
    from hackathon.template import TemplateLibrary
    from hackathon.remote.guacamole import GuacamoleInfo
    from hackathon.expr.expr_mgr import ExprManager
    from hackathon.cache.cache_mgr import CacheManagerExt
    from hackathon.hazure.azure_formation import AzureFormation

    # dependencies MUST be provided in advance
    factory.provide("util", Utility)
    factory.provide("log", log)
    factory.provide("db", SQLAlchemyAdapter, db_session)

    # hazure
    factory.provide("azure_formation", AzureFormation)

    # utils
    init_voice_verify()
    init_sms()
    factory.provide("email", Email)

    # cache
    factory.provide("cache", CacheManagerExt)

    # scheduler
    factory.provide("scheduler", scheduler)

    # business components
    factory.provide("user_manager", UserManager)
    factory.provide("user_profile_manager", UserProfileManager)
    factory.provide("hackathon_manager", HackathonManager)
    factory.provide("register_manager", RegisterManager)
    factory.provide("azure_cert_manager", AzureCertManager)
    factory.provide("docker_host_manager", DockerHostManager)
    factory.provide("hackathon_template_manager", HackathonTemplateManager)
    factory.provide("template_library", TemplateLibrary)
    factory.provide("expr_manager", ExprManager)
    factory.provide("admin_manager", AdminManager)
    factory.provide("team_manager", TeamManager)
    factory.provide("guacamole", GuacamoleInfo)

    # health check items
    factory.provide(
        "health_check_mysql",
        get_class("hackathon.health.health_check.MySQLHealthCheck"))
    factory.provide(
        "health_check_hosted_docker",
        get_class("hackathon.health.health_check.HostedDockerHealthCheck"))
    factory.provide(
        "health_check_alauda_docker",
        get_class("hackathon.health.health_check.AlaudaDockerHealthCheck"))
    factory.provide(
        "health_check_guacamole",
        get_class("hackathon.health.health_check.GuacamoleHealthCheck"))
    factory.provide(
        "health_check_azure",
        get_class("hackathon.health.health_check.AzureHealthCheck"))

    # docker
    factory.provide(
        "hosted_docker",
        get_class("hackathon.docker.hosted_docker.HostedDockerFormation"))
    factory.provide(
        "alauda_docker",
        get_class("hackathon.docker.alauda_docker.AlaudaDockerFormation"))

    # storage
    init_hackathon_storage()
Exemple #15
0
def init_hackathon_storage():
    from hackathon.storage import LocalStorage
    factory.provide("storage", LocalStorage)
Exemple #16
0
def init_db():
    from hmongo import db
    factory.provide("db", db, suspend_callable=True)
Exemple #17
0
def init_components():
    """Init hackathon factory"""
    from hackathon.user import UserManager, UserProfileManager
    from hackathon.hack import HackathonManager, AdminManager, TeamManager, DockerHostManager, \
        AzureCertManager, RegisterManager, HackathonTemplateManager, Cryptor
    from hackathon.template import TemplateLibrary
    from hackathon.remote.guacamole import GuacamoleInfo
    from hackathon.cache.cache_mgr import CacheManagerExt

    # dependencies MUST be provided in advance
    factory.provide("util", Utility)
    factory.provide("log", log)
    init_db()

    # utils
    init_voice_verify()
    init_sms()
    factory.provide("email", Email)

    # cache
    factory.provide("cache", CacheManagerExt)

    # scheduler
    factory.provide("scheduler", scheduler)

    # business components
    factory.provide("user_manager", UserManager)
    factory.provide("user_profile_manager", UserProfileManager)
    factory.provide("hackathon_manager", HackathonManager)
    factory.provide("register_manager", RegisterManager)
    factory.provide("azure_cert_manager", AzureCertManager)
    factory.provide("cryptor", Cryptor)
    factory.provide("docker_host_manager", DockerHostManager)
    factory.provide("hackathon_template_manager", HackathonTemplateManager)
    factory.provide("template_library", TemplateLibrary)
    factory.provide("admin_manager", AdminManager)
    factory.provide("team_manager", TeamManager)
    factory.provide("guacamole", GuacamoleInfo)

    # experiment starter
    init_expr_components()

    # health check items
    factory.provide("health_check_hosted_docker", get_class("hackathon.health.health_check.HostedDockerHealthCheck"))
    factory.provide("health_check_alauda_docker", get_class("hackathon.health.health_check.AlaudaDockerHealthCheck"))
    factory.provide("health_check_guacamole", get_class("hackathon.health.health_check.GuacamoleHealthCheck"))
    factory.provide("health_check_azure", get_class("hackathon.health.health_check.AzureHealthCheck"))
    factory.provide("health_check_mongodb", get_class("hackathon.health.health_check.MongoDBHealthCheck"))

    # docker
    factory.provide("hosted_docker_proxy", get_class("hackathon.docker.hosted_docker.HostedDockerFormation"))
    factory.provide("alauda_docker_proxy", get_class("hackathon.docker.alauda_docker.AlaudaDockerFormation"))

    # storage
    init_hackathon_storage()
Exemple #18
0
def init_components():
    """Init hackathon factory"""
    from hackathon.database import db_session
    from hackathon.database.db_adapters import SQLAlchemyAdapter
    from hackathon.user import UserManager, UserProfileManager
    from hackathon.hack import HackathonManager, AdminManager, TeamManager, DockerHostManager, \
        AzureCertManager, RegisterManager, HackathonTemplateManager
    from hackathon.template import TemplateLibrary
    from hackathon.remote.guacamole import GuacamoleInfo
    from hackathon.expr.expr_mgr import ExprManager
    from hackathon.cache.cache_mgr import CacheManagerExt

    # dependencies MUST be provided in advance
    factory.provide("util", Utility)
    factory.provide("log", log)
    factory.provide("db", SQLAlchemyAdapter, db_session)

    # cache
    factory.provide("cache", CacheManagerExt)

    # scheduler
    factory.provide("scheduler", scheduler)

    # business components
    factory.provide("user_manager", UserManager)
    factory.provide("user_profile_manager", UserProfileManager)
    factory.provide("hackathon_manager", HackathonManager)
    factory.provide("register_manager", RegisterManager)
    factory.provide("azure_cert_manager", AzureCertManager)
    factory.provide("docker_host_manager", DockerHostManager)
    factory.provide("hackathon_template_manager", HackathonTemplateManager)
    factory.provide("template_library", TemplateLibrary)
    factory.provide("expr_manager", ExprManager)
    factory.provide("admin_manager", AdminManager)
    factory.provide("team_manager", TeamManager)
    factory.provide("guacamole", GuacamoleInfo)

    # health check items
    factory.provide("health_check_mysql", get_class("hackathon.health.health_check.MySQLHealthCheck"))
    factory.provide("health_check_hosted_docker", get_class("hackathon.health.health_check.HostedDockerHealthCheck"))
    factory.provide("health_check_alauda_docker", get_class("hackathon.health.health_check.AlaudaDockerHealthCheck"))
    factory.provide("health_check_guacamole", get_class("hackathon.health.health_check.GuacamoleHealthCheck"))
    factory.provide("health_check_azure", get_class("hackathon.health.health_check.AzureHealthCheck"))

    # docker
    factory.provide("hosted_docker", get_class("hackathon.docker.hosted_docker.HostedDockerFormation"))
    factory.provide("alauda_docker", get_class("hackathon.docker.alauda_docker.AlaudaDockerFormation"))

    # storage
    init_hackathon_storage()
Exemple #19
0
def init_components():
    """Init hackathon factory"""
    from hackathon.database import db_session
    from hackathon.database.db_adapters import SQLAlchemyAdapter
    from hackathon.user import UserManager
    from hackathon.azureformation.azure_file_service import FileService
    from hackathon.hack import HackathonManager, AdminManager, TeamManager, DockerHostManager, AzureCertManager
    from hackathon.registration.register_mgr import RegisterManager
    from hackathon.template.template_mgr import TemplateManager
    from hackathon.remote.guacamole import GuacamoleInfo
    from hackathon.expr.expr_mgr import ExprManager
    from hackathon.cache.cache_mgr import CacheManagerExt
    from hackathon.azureformation.azure_adapter import AzureAdapter
    from hackathon.azureformation.azure_subscription_service import SubscriptionService
    from hackathon.azureformation.azure_vm_service import AzureVMService
    from hackathon.azureformation.azure_storage_account_service import StorageAccount
    from hackathon.azureformation.azure_cloud_service import CloudService

    # dependencies MUST be provided in advance
    factory.provide("util", Utility)
    factory.provide("log", log)
    print '--------factory db---------'
    factory.provide("db", SQLAlchemyAdapter, db_session)
    print '--------end factory db---------'
    # scheduler
    factory.provide("scheduler", scheduler)

    # business components
    factory.provide("user_manager", UserManager)
    factory.provide("hackathon_manager", HackathonManager)
    factory.provide("register_manager", RegisterManager)
    factory.provide("file_service", FileService)
    factory.provide("azure_cert_manager", AzureCertManager)
    factory.provide("docker_host_manager", DockerHostManager)
    factory.provide("template_manager", TemplateManager)
    factory.provide("expr_manager", ExprManager)
    factory.provide("admin_manager", AdminManager)
    factory.provide("team_manager", TeamManager)
    factory.provide("guacamole", GuacamoleInfo)
    factory.provide("cache", CacheManagerExt)

    # health check items
    factory.provide(
        "health_check_mysql",
        get_class("hackathon.health.health_check.MySQLHealthCheck"))
    factory.provide(
        "health_check_hosted_docker",
        get_class("hackathon.health.health_check.HostedDockerHealthCheck"))
    factory.provide(
        "health_check_alauda_docker",
        get_class("hackathon.health.health_check.AlaudaDockerHealthCheck"))
    factory.provide(
        "health_check_guacamole",
        get_class("hackathon.health.health_check.GuacamoleHealthCheck"))
    factory.provide(
        "health_check_azure",
        get_class("hackathon.health.health_check.AzureHealthCheck"))

    # docker
    factory.provide("docker",
                    get_class("hackathon.docker.docker_helper.DockerHelper"))
    factory.provide(
        "hosted_docker",
        get_class("hackathon.docker.hosted_docker.HostedDockerFormation"))
    factory.provide(
        "alauda_docker",
        get_class("hackathon.docker.alauda_docker.AlaudaDockerFormation"))

    # azure
    factory.provide("azure_adapter", AzureAdapter)
    factory.provide("azure_subscription_service", SubscriptionService)
    factory.provide("azure_vm_service", AzureVMService)
    factory.provide("azure_cloud_service", CloudService)
    factory.provide("azure_storage_account_service", StorageAccount)

    # storage
    init_hackathon_storage()