Ejemplo n.º 1
0
def _init_solr(instance_id):
    solr_url = solr_manager.get_internal_http_endpoint()
    solr_manager.create_collection(instance_id)
    assert solr_url.startswith('https://') and solr_url.endswith('/solr')
    host, port = solr_url.replace('https://', '').replace('/solr',
                                                          '').split(':')
    return host, port
Ejemplo n.º 2
0
    def test_create_collection(self, solr_curl, get_num_shards,
                               get_replication_factor):
        get_replication_factor.return_value = 2
        get_num_shards.return_value = 1
        solr_curl.return_value = ''

        manager.create_collection('montreal', 'config_27_default')
        solr_curl.assert_called_once_with(
            '/admin/collections?action=CREATE&name=montreal&collection.configName=config_27_default&replicationFactor=2&numShards=1',
            required=True)
Ejemplo n.º 3
0
def _init_solr(instance_id):
    solr_status = solr_manager.get_collectoin_status(instance_id)
    if not solr_status['ready']:
        solr_manager.create_collection(instance_id, 'ckan_28_default')
    else:
        logs.info(f'collection already exists ({instance_id})')
    solr_url = solr_status['solr_http_endpoint']
    assert solr_url.startswith('http') and solr_url.endswith(
        '/solr'), f'invalid solr_url ({solr_url})'
    host, port = solr_url.replace('https://',
                                  '').replace('http://',
                                              '').replace('/solr',
                                                          '').split(':')
    return host, port
Ejemplo n.º 4
0
 def _update(self):
     status = self.get()
     if status['ready']:
         schema_name = status['schemaName']
         schema_version = status['schemaVersion']
         logs.info(
             f'Using existing solr schema: {schema_name} {schema_version}')
     elif 'configName' in self.solr_spec:
         config_name = self.solr_spec['configName']
         from ckan_cloud_operator.providers.solr import manager as solr_manager
         solr_manager.create_collection(status['collection_name'],
                                        config_name)
     else:
         raise NotImplementedError(
             f'Unsupported solr cloud collection spec: {self.solr_spec}')
Ejemplo n.º 5
0
def _init_solr(instance_id, dry_run=False):
    logs.debug('Initializing solr', instance_id=instance_id)
    solr_status = solr_manager.get_collection_status(instance_id)
    logs.debug_yaml_dump(solr_status)
    if not solr_status['ready']:
        logs.info('Creating solr collection', collection_name=instance_id, solr_config='ckan_28_default')
        if not dry_run:
            solr_manager.create_collection(instance_id, 'ckan_28_default')
    else:
        logs.info(f'collection already exists ({instance_id})')
    solr_url = solr_status['solr_http_endpoint']
    logs.debug(solr_url=solr_url)
    assert solr_url.startswith('http') and solr_url.endswith('/solr'), f'invalid solr_url ({solr_url})'
    host, port = solr_url.replace('https://', '').replace('http://', '').replace('/solr', '').split(':')
    logs.debug('Solr initialization completed successfully', host=host, port=port)
    return host, port