예제 #1
0
파일: manage.py 프로젝트: CUXIDUMDUM/pulp
def _auto_manage_db(options):
    """
    Find and apply all available database migrations, and install or update all available content
    types.

    :param options: The command line parameters from the user.
    """
    message = _('Loading content types.')
    logger.info(message)
    load_content_types()
    message = _('Content types loaded.')
    logger.info(message)

    message = _('Ensuring the admin role and user are in place.')
    logger.info(message)
    # Due to the silliness of the factory, we have to initialize it because the UserManager and
    # RoleManager are going to try to use it.
    factory.initialize()
    role_manager = RoleManager()
    role_manager.ensure_super_user_role()
    user_manager = UserManager()
    user_manager.ensure_admin()
    message = _('Admin role and user are in place.')
    logger.info(message)

    message = _('Beginning database migrations.')
    logger.info(message)
    migrate_database(options)
    message = _('Database migrations complete.')
    logger.info(message)

    return os.EX_OK
예제 #2
0
파일: manage.py 프로젝트: omps/pulp
def _auto_manage_db(options):
    """
    Find and apply all available database migrations, and install or update all available content
    types.

    :param options: The command line parameters from the user.
    """
    message = _('Loading content types.')
    logger.info(message)
    load_content_types()
    message = _('Content types loaded.')
    logger.info(message)

    message = _('Ensuring the admin role and user are in place.')
    logger.info(message)
    # Due to the silliness of the factory, we have to initialize it because the UserManager and
    # RoleManager are going to try to use it.
    factory.initialize()
    role_manager = RoleManager()
    role_manager.ensure_super_user_role()
    user_manager = UserManager()
    user_manager.ensure_admin()
    message = _('Admin role and user are in place.')
    logger.info(message)

    message = _('Beginning database migrations.')
    logger.info(message)
    migrate_database(options)
    message = _('Database migrations complete.')
    logger.info(message)

    return os.EX_OK
예제 #3
0
 def test_load_content_types_dry_run(self, mock_check_content, mock_load_type):
     """
     Test that calling load_content_types with dry_run=True results in checking the content types
      rather than loading them.
     """
     api.load_content_types(dry_run=True)
     self.assertEquals(1, mock_check_content.call_count)
     self.assertEquals(0, mock_load_type.call_count)
예제 #4
0
파일: test_api.py 프로젝트: zjhuntin/pulp
 def test_load_content_types_dry_run(self, mock_check_content, mock_load_type):
     """
     Test that calling load_content_types with dry_run=True results in checking the content types
      rather than loading them.
     """
     api.load_content_types(dry_run=True)
     self.assertEquals(1, mock_check_content.call_count)
     self.assertEquals(0, mock_load_type.call_count)
예제 #5
0
 def test_init_calls_entry_points(self, mock_load):
     api._MANAGER = None
     # This test is problematic, because it relies on the pulp_rpm package, which depends on this
     # package. We should really mock the type loading and test that the mocked types were loaded
     # For now, we can get around the problem by just calling load_content_types.
     api.load_content_types()
     api.initialize()
     # calls for 5 types of plugins
     self.assertEqual(mock_load.call_count, 6)
예제 #6
0
def migrate(*args, **kwargs):
    """
    Perform the migration as described in this module's docblock.

    :param args:   unused
    :type  args:   list
    :param kwargs: unused
    :type  kwargs: dict
    """

    load_content_types(drop_indices=True)
예제 #7
0
def _auto_manage_db(options):
    """
    Find and apply all available database migrations, and install or update all available content
    types.

    :param options: The command line parameters from the user.
    """
    print _('Beginning database migrations.')
    migrate_database(options)
    print _('Database migrations complete.')

    print _('Loading content types.')
    load_content_types()
    print _('Content types loaded.')
    return os.EX_OK
예제 #8
0
파일: manage.py 프로젝트: pombreda/pulp
def _auto_manage_db(options):
    """
    Find and apply all available database migrations, and install or update all available content
    types.

    :param options: The command line parameters from the user.
    """
    unperformed_migrations = False

    message = _('Loading content types.')
    _logger.info(message)
    # Note that if dry_run is False, None is always returned
    old_content_types = load_content_types(dry_run=options.dry_run)
    if old_content_types:
        for content_type in old_content_types:
            message = _(
                'Would have created or updated the following type definition: '
                + content_type.id)
            _logger.info(message)
    message = _('Content types loaded.')
    _logger.info(message)

    message = _('Ensuring the admin role and user are in place.')
    _logger.info(message)
    # Due to the silliness of the factory, we have to initialize it because the UserManager and
    # RoleManager are going to try to use it.
    factory.initialize()
    role_manager = RoleManager()
    if options.dry_run:
        if not role_manager.get_role(SUPER_USER_ROLE):
            unperformed_migrations = True
            message = _('Would have created the admin role.')
            _logger.info(message)
    else:
        role_manager.ensure_super_user_role()

    user_manager = UserManager()
    if options.dry_run:
        if not user_manager.get_admins():
            unperformed_migrations = True
            message = _('Would have created the default admin user.')
            _logger.info(message)
    else:
        user_manager.ensure_admin()
    message = _('Admin role and user are in place.')
    _logger.info(message)

    message = _('Beginning database migrations.')
    _logger.info(message)
    migrate_database(options)
    message = _('Database migrations complete.')
    _logger.info(message)

    if unperformed_migrations:
        return 1

    return os.EX_OK
예제 #9
0
파일: manage.py 프로젝트: alexxa/pulp
def _auto_manage_db(options):
    """
    Find and apply all available database migrations, and install or update all available content
    types.

    :param options: The command line parameters from the user.
    """
    unperformed_migrations = False

    message = _('Loading content types.')
    _logger.info(message)
    # Note that if dry_run is False, None is always returned
    old_content_types = load_content_types(dry_run=options.dry_run)
    if old_content_types:
        for content_type in old_content_types:
            message = _(
                'Would have created or updated the following type definition: ' + content_type.id)
            _logger.info(message)
    message = _('Content types loaded.')
    _logger.info(message)

    message = _('Ensuring the admin role and user are in place.')
    _logger.info(message)
    # Due to the silliness of the factory, we have to initialize it because the UserManager and
    # RoleManager are going to try to use it.
    factory.initialize()
    role_manager = RoleManager()
    if options.dry_run:
        if not role_manager.get_role(SUPER_USER_ROLE):
            unperformed_migrations = True
            message = _('Would have created the admin role.')
            _logger.info(message)
    else:
        role_manager.ensure_super_user_role()

    user_manager = managers.UserManager()
    if options.dry_run:
        if not user_manager.get_admins():
            unperformed_migrations = True
            message = _('Would have created the default admin user.')
            _logger.info(message)
    else:
        user_manager.ensure_admin()
    message = _('Admin role and user are in place.')
    _logger.info(message)

    message = _('Beginning database migrations.')
    _logger.info(message)
    migrate_database(options)
    message = _('Database migrations complete.')
    _logger.info(message)

    if unperformed_migrations:
        return 1

    return os.EX_OK
예제 #10
0
def _auto_manage_db(options):
    """
    Find and apply all available database migrations, and install or update all available content
    types.

    :param options: The command line parameters from the user.
    """
    message = _('Beginning database migrations.')
    print message
    logger.info(message)
    migrate_database(options)
    message = _('Database migrations complete.')
    print message
    logger.info(message)

    message = _('Loading content types.')
    print message
    logger.info(message)
    load_content_types()
    message = _('Content types loaded.')
    print message
    logger.info(message)
    return os.EX_OK