Example #1
0
def _initialize_pulp():
    # XXX ORDERING COUNTS
    # This initialization order is very sensitive, and each touches a number of
    # sub-systems in pulp. If you get this wrong, you will have pulp tripping
    # over itself on start up. If you do not know where to add something, ASK!
    global _IS_INITIALIZED, STACK_TRACER
    if _IS_INITIALIZED:
        return
    _IS_INITIALIZED = True

    # check our db version and other support
    check_version()

    # pulp generic content initialization
    manager_factory.initialize()
    plugin_api.initialize()

    # new async dispatch initialization
    dispatch_factory.initialize()

    # ensure necessary infrastructure
    ensure_builtin_roles()
    ensure_admin()

    # agent services
    AgentServices.start()

    # setup debugging, if configured
    if config.config.getboolean('server', 'debugging_mode'):
        STACK_TRACER = StacktraceDumper()
        STACK_TRACER.start()
Example #2
0
def _initialize_pulp():

    # This initialization order is very sensitive, and each touches a number of
    # sub-systems in pulp. If you get this wrong, you will have pulp tripping
    # over itself on start up.

    global _IS_INITIALIZED, STACK_TRACER
    if _IS_INITIALIZED:
        return

    # Verify the database has been migrated to the correct version. This is
    # very likely a reason the server will fail to start.
    try:
        migration_models.check_package_versions()
    except Exception:
        msg  = 'The database has not been migrated to the current version. '
        msg += 'Run pulp-manage-db and restart the application.'
        raise InitializationException(msg), None, sys.exc_info()[2]

    # Load plugins and resolve against types. This is also a likely candidate
    # for causing the server to fail to start.
    try:
        plugin_api.initialize()
    except Exception:
        msg  = 'One or more plugins failed to initialize. If a new type has '
        msg += 'been added, run pulp-manage-db to load the type into the '
        msg += 'database and restart the application.'
        raise InitializationException(msg), None, sys.exc_info()[2]

    # There's a significantly smaller chance the following calls will fail.
    # The previous two are likely user errors, but the remainder represent
    # something gone horribly wrong. As such, I'm not going to account for each
    # and instead simply let the exception itself bubble up.

    # Load the mappings of manager type to managers
    manager_factory.initialize()

    # Initialize the tasking subsystem
    dispatch_factory.initialize()

    # Ensure the minimal auth configuration
    role_manager = manager_factory.role_manager()
    role_manager.ensure_super_user_role()
    user_manager = manager_factory.user_manager()
    user_manager.ensure_admin()

    # database document reaper
    reaper.initialize()

    # agent services
    AgentServices.start()

    # Setup debugging, if configured
    if config.config.getboolean('server', 'debugging_mode'):
        STACK_TRACER = StacktraceDumper()
        STACK_TRACER.start()

    # If we got this far, it was successful, so flip the flag
    _IS_INITIALIZED = True
Example #3
0
def _initialize_pulp():

    # This initialization order is very sensitive, and each touches a number of
    # sub-systems in pulp. If you get this wrong, you will have pulp tripping
    # over itself on start up.

    global _IS_INITIALIZED, STACK_TRACER
    if _IS_INITIALIZED:
        return

    # Even though this import does not get used anywhere, we must import it for the Celery
    # application to be initialized. Also, this import cannot happen in the usual PEP-8 location,
    # as it calls initialization code at the module level. Calling that code at the module level
    # is necessary for the Celery application to initialize.
    from pulp.server.async import app

    # configure agent services
    AgentServices.init()

    # Verify the database has been migrated to the correct version. This is
    # very likely a reason the server will fail to start.
    try:
        migration_models.check_package_versions()
    except Exception:
        msg  = 'The database has not been migrated to the current version. '
        msg += 'Run pulp-manage-db and restart the application.'
        raise initialization.InitializationException(msg), None, sys.exc_info()[2]

    # There's a significantly smaller chance the following calls will fail.
    # The previous two are likely user errors, but the remainder represent
    # something gone horribly wrong. As such, I'm not going to account for each
    # and instead simply let the exception itself bubble up.

    # Initialize the tasking subsystem
    dispatch_factory.initialize()

    # Ensure the minimal auth configuration
    role_manager = manager_factory.role_manager()
    role_manager.ensure_super_user_role()
    user_manager = manager_factory.user_manager()
    user_manager.ensure_admin()

    # start agent services
    AgentServices.start()

    # Setup debugging, if configured
    if config.config.getboolean('server', 'debugging_mode'):
        STACK_TRACER = StacktraceDumper()
        STACK_TRACER.start()

    # If we got this far, it was successful, so flip the flag
    _IS_INITIALIZED = True
Example #4
0
def _initialize_pulp():

    # This initialization order is very sensitive, and each touches a number of
    # sub-systems in pulp. If you get this wrong, you will have pulp tripping
    # over itself on start up.

    global _IS_INITIALIZED, STACK_TRACER
    if _IS_INITIALIZED:
        return

    # Even though this import does not get used anywhere, we must import it for the Celery
    # application to be initialized. Also, this import cannot happen in the usual PEP-8 location,
    # as it calls initialization code at the module level. Calling that code at the module level
    # is necessary for the Celery application to initialize.
    from pulp.server. async import app

    # configure agent services
    AgentServices.init()

    # Verify the database has been migrated to the correct version. This is
    # very likely a reason the server will fail to start.
    try:
        migration_models.check_package_versions()
    except Exception:
        msg = 'The database has not been migrated to the current version. '
        msg += 'Run pulp-manage-db and restart the application.'
        raise initialization.InitializationException(
            msg), None, sys.exc_info()[2]

    # There's a significantly smaller chance the following calls will fail.
    # The previous two are likely user errors, but the remainder represent
    # something gone horribly wrong. As such, I'm not going to account for each
    # and instead simply let the exception itself bubble up.

    # start agent services
    AgentServices.start()

    # Setup debugging, if configured
    if config.config.getboolean('server', 'debugging_mode'):
        STACK_TRACER = StacktraceDumper()
        STACK_TRACER.start()

    # If we got this far, it was successful, so flip the flag
    _IS_INITIALIZED = True
Example #5
0
    # Ensure the minimal auth configuration
    role_manager = manager_factory.role_manager()
    role_manager.ensure_super_user_role()
    user_manager = manager_factory.user_manager()
    user_manager.ensure_admin()

    # database document reaper
    reaper.initialize()

    # start agent services
    AgentServices.start()

    # Setup debugging, if configured
    if config.config.getboolean('server', 'debugging_mode'):
        STACK_TRACER = StacktraceDumper()
        STACK_TRACER.start()

    # If we got this far, it was successful, so flip the flag
    _IS_INITIALIZED = True


def wsgi_application():
    """
    Application factory to create, configure, and return a WSGI application
    using the web.py framework and custom Pulp middleware.
    @return: wsgi application callable
    """
    application = web.subdir_application(URLS).wsgifunc()
    stack_components = [application, PostponedOperationMiddleware, ExceptionHandlerMiddleware]
    stack = reduce(lambda a, m: m(a), stack_components)
Example #6
0
    # Ensure the minimal auth configuration
    role_manager = manager_factory.role_manager()
    role_manager.ensure_super_user_role()
    user_manager = manager_factory.user_manager()
    user_manager.ensure_admin()

    # database document reaper
    reaper.initialize()

    # agent services
    AgentServices.start()

    # Setup debugging, if configured
    if config.config.getboolean('server', 'debugging_mode'):
        STACK_TRACER = StacktraceDumper()
        STACK_TRACER.start()

    # If we got this far, it was successful, so flip the flag
    _IS_INITIALIZED = True


def wsgi_application():
    """
    Application factory to create, configure, and return a WSGI application
    using the web.py framework and custom Pulp middleware.
    @return: wsgi application callable
    """
    application = web.subdir_application(URLS).wsgifunc()
    stack_components = [
        application, PostponedOperationMiddleware, ExceptionHandlerMiddleware