Exemple #1
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

    # 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 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, e:
        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. '
        msg += 'Error message: %s' % str(e)
        raise InitializationException(msg), None, sys.exc_info()[2]
Exemple #2
0
 def test_init(self, get_url, broker):
     Services.init()
     broker.assert_called_with(get_url.return_value)
     broker = broker.return_value
     self.assertEqual(broker.ssl.ca_certificate, messaging['cacert'])
     self.assertEqual(broker.ssl.client_certificate,
                      messaging['clientcert'])
Exemple #3
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()
Exemple #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

    # 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
Exemple #5
0
 def test_init(self):
     Services.init()
     url = pulp_conf.get('messaging', 'url')
     ca_cert = pulp_conf.get('messaging', 'cacert')
     client_cert = pulp_conf.get('messaging', 'clientcert')
     broker = Broker(url)
     self.assertEqual(broker.url, URL(url))
     self.assertEqual(broker.cacert, ca_cert)
     self.assertEqual(broker.clientcert, client_cert)
 def test_init(self, mock_broker):
     Services.init()
     url = pulp_conf.get('messaging', 'url')
     transport = pulp_conf.get('messaging', 'transport')
     ca_cert = pulp_conf.get('messaging', 'cacert')
     client_cert = pulp_conf.get('messaging', 'clientcert')
     mock_broker.assert_called_with(url, transport=transport)
     broker = mock_broker()
     self.assertEqual(broker.cacert, ca_cert)
     self.assertEqual(broker.clientcert, client_cert)
Exemple #7
0
 def test_init(self, mock_broker):
     Services.init()
     url = pulp_conf.get('messaging', 'url')
     transport = pulp_conf.get('messaging', 'transport')
     ca_cert = pulp_conf.get('messaging', 'cacert')
     client_cert = pulp_conf.get('messaging', 'clientcert')
     mock_broker.assert_called_with(url, transport=transport)
     broker = mock_broker()
     self.assertEqual(broker.cacert, ca_cert)
     self.assertEqual(broker.clientcert, client_cert)
Exemple #8
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
Exemple #9
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
Exemple #10
0
def _initialize_web_services():
    """
    This function initializes Pulp for webservices.
    """

    # 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

    logs.start_logging()

    # Run the common initialization code that all processes should share. This will start the
    # database connection, initialize plugins, and initialize the manager factory.
    initialization.initialize()

    # 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()

    # If we got this far, it was successful, so flip the flag
    _IS_INITIALIZED = True
Exemple #11
0
def _initialize_web_services():
    """
    This function initializes Pulp for webservices.
    """

    # 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

    logs.start_logging()

    # Run the common initialization code that all processes should share. This will start the
    # database connection, initialize plugins, and initialize the manager factory.
    initialization.initialize()

    # 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()

    # If we got this far, it was successful, so flip the flag
    _IS_INITIALIZED = True
Exemple #12
0
 def __init__(self, consumer, **details):
     """
     :param consumer: A consumer DB model object.
     :type consumer: dict
     :param details: A dictionary of information to be round-tripped.
         Primarily used to correlate asynchronous replies.
     :type details: dict
     """
     self.route = 'pulp.agent.%s' % consumer['id']
     self.secret = str(consumer['_id'])
     self.url = Services.get_url()
     self.details = details
     self.reply_queue = ReplyHandler.REPLY_QUEUE
     self.authenticator = Authenticator()
     self.authenticator.load()
     queue = Queue(self.route)
     queue.declare(self.url)
Exemple #13
0
 def test_get_url(self):
     url = messaging['url']
     adapter = messaging['transport']
     self.assertEqual('+'.join((adapter, url)), Services.get_url())
Exemple #14
0
 def test_start(self, mock_reply_handler):
     Services.start()
     mock_reply_handler.start.assert_called()
Exemple #15
0
 def test_get_url(self):
     url = messaging['url']
     adapter = messaging['transport']
     self.assertEqual('+'.join((adapter, url)), Services.get_url())
Exemple #16
0
 def test_start(self, reply_handler, get_url):
     Services.start()
     reply_handler.assert_called_once_with(get_url.return_value)
     reply_handler.return_value.start.assert_called_once_with()
Exemple #17
0
 def test_init(self, add_connector):
     Services.init()
     add_connector.assert_called_once_with()
Exemple #18
0
 def test_start(self, mock_watchdog, mock_reply_handler, mock_journal):
     Services.start()
     mock_watchdog.start.assert_called()
     mock_reply_handler.start.assert_called()
Exemple #19
0
 def test_init(self, add_connector):
     Services.init()
     add_connector.assert_called_once_with()
Exemple #20
0
 def test_start(self, reply_handler):
     Services.start()
     reply_handler.start.assert_called()
Exemple #21
0
 def test_init(self, get_url, broker):
     Services.init()
     broker.assert_called_with(get_url.return_value)
     broker = broker.return_value
     self.assertEqual(broker.ssl.ca_certificate, messaging['cacert'])
     self.assertEqual(broker.ssl.client_certificate, messaging['clientcert'])
Exemple #22
0
    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


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
Exemple #23
0
 def test_start(self, reply_handler, get_url):
     Services.start()
     reply_handler.assert_called_once_with(get_url.return_value)
     reply_handler.return_value.start.assert_called_once_with()
Exemple #24
0
    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()

    # 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