コード例 #1
0
    def handle(self, *args, **options):
        """Executes the command."""
        apps = get_search_apps_by_name(options['model'])

        if not are_apps_initialised(apps):
            raise CommandError(
                f'Index and mapping not initialised, please run `init_es` first.',
            )

        with advisory_lock('leeloo_migrate_es'):
            migrate_apps(apps)
コード例 #2
0
    def handle(self, *args, **options):
        """Executes the command."""
        with advisory_lock('leeloo_init_es'):
            logger.info(
                'Creating Elasticsearch indices and initialising mappings...')

            for app in get_search_apps_by_name(options['model']):
                app.init_es(
                    force_update_mapping=options['force_update_mapping'])

            logger.info('Elasticsearch indices and mappings initialised')
コード例 #3
0
    def handle(self, *args, **options):
        """Handle."""
        es_logger = getLogger('elasticsearch')
        es_logger.setLevel(WARNING)

        apps = get_search_apps_by_name(options['model'])

        if not are_apps_initialised(apps):
            raise CommandError(
                f'Index and mapping not initialised, please run `init_es` first.',
            )

        sync_es(
            batch_size=options['batch_size'],
            search_apps=apps,
        )
コード例 #4
0
    def handle(self, *args, **options):
        """Handle."""
        getLogger('opensearch').setLevel(WARNING)

        apps = get_search_apps_by_name(options['model'])

        if not are_apps_initialised(apps):
            raise CommandError(
                'Index and mapping not initialised, please run `migrate_search` first.',
            )

        for app in apps:
            task_args = (app.name, )

            if options['foreground']:
                sync_model.apply(args=task_args, throw=True)
            else:
                sync_model.apply_async(args=task_args)

        logger.info('OpenSearch sync complete!')
コード例 #5
0
    def handle(self, *args, **options):
        """Executes the command."""
        apps = get_search_apps_by_name(options['model'])

        with advisory_lock('migrate-opensearch-lock-id'):
            migrate_apps(apps)