Esempio n. 1
0
    def delete_collection(self, name, core):
        """
    Delete solr collection/core and instance dir
    """
        api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())
        if core:
            raise PopupException(_('Cannot remove Solr cores.'))

        if api.remove_collection(name):
            # Delete instance directory.
            solrctl_path = get_solrctl_path()

            process = subprocess.Popen(
                [solrctl_path, "instancedir", "--delete", name],
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE,
                env={'SOLR_ZK_ENSEMBLE': conf.SOLR_ZK_ENSEMBLE.get()})
            if process.wait() != 0:
                LOG.error(
                    "Cloud not delete instance directory.\nOutput stream: %s\nError stream: %s"
                    % process.communicate())
                raise PopupException(
                    _('Could not create instance directory. Check error logs for more info.'
                      ))
        else:
            raise PopupException(
                _('Could not remove collection. Check error logs for more info.'
                  ))
Esempio n. 2
0
    def delete_collection(self, name, core):
        """
    Delete solr collection/core and instance dir
    """
        api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())
        client = SolrClient(self.user)

        if core:
            raise PopupException(_('Cannot remove Solr cores.'))

        if api.remove_collection(name):
            # Delete instance directory.
            try:
                root_node = '%s/%s' % (ZK_SOLR_CONFIG_NAMESPACE, name)
                with ZookeeperClient(hosts=client.get_zookeeper_host(),
                                     read_only=False) as zc:
                    zc.delete_path(root_node)
            except Exception as e:
                # Re-create collection so that we don't have an orphan config
                api.add_collection(name)
                raise PopupException(
                    _('Error in deleting Solr configurations.'), detail=e)
        else:
            raise PopupException(
                _('Could not remove collection. Check error logs for more info.'
                  ))
Esempio n. 3
0
def delete_collections(request):
    response = {'status': -1}

    names = request.POST.get_list('name')

    api = SolrApi(user=request.user)

    response['statuses'] = [api.remove_collection(name) for name in names]
    response['status'] = 0

    return JsonResponse(response)
Esempio n. 4
0
  def delete_collection(self, name, core):
    """
    Delete solr collection/core and instance dir
    """
    api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())
    if core:
      raise PopupException(_('Cannot remove Solr cores.'))

    if api.remove_collection(name):
      # Delete instance directory.
      try:
        root_node = '%s/%s' % (ZK_SOLR_CONFIG_NAMESPACE, name)
        with ZookeeperClient(hosts=get_solr_ensemble(), read_only=False) as zc:
          zc.delete_path(root_node)
      except Exception, e:
        # Re-create collection so that we don't have an orphan config
        api.add_collection(name)
        raise PopupException(_('Error in deleting Solr configurations.'), detail=e)
Esempio n. 5
0
  def delete_collection(self, name, core):
    """
    Delete solr collection/core and instance dir
    """
    api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())
    if core:
      raise PopupException(_('Cannot remove Solr cores.'))

    if api.remove_collection(name):
      # Delete instance directory.
      try:
        root_node = '%s/%s' % (ZK_SOLR_CONFIG_NAMESPACE, name)
        zc = ZookeeperClient(hosts=get_solr_ensemble(), read_only=False)
        zc.delete_path(root_node)
      except Exception, e:
        # Re-create collection so that we don't have an orphan config
        api.add_collection(name)
        raise PopupException(_('Error in deleting Solr configurations.'), detail=e)
Esempio n. 6
0
 def delete_collection(self, name):
   """
   Delete solr collection and instance dir
   """
   api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())
   if api.remove_collection(name):
     # Delete instance directory.
     process = subprocess.Popen([conf.SOLRCTL_PATH.get(), "instancedir", "--delete", name],
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE,
                                env={
                                  'SOLR_HOME': conf.SOLR_HOME.get(),
                                  'SOLR_ZK_ENSEMBLE': conf.SOLR_ZK_ENSEMBLE.get()
                                })
     if process.wait() != 0:
       LOG.error("Cloud not delete instance directory.\nOutput stream: %s\nError stream: %s" % process.communicate())
       raise PopupException(_('Could not create instance directory. Check error logs for more info.'))
   else:
     raise PopupException(_('Could not create collection. Check error logs for more info.'))
Esempio n. 7
0
  def delete_collection(self, name, core):
    """
    Delete solr collection/core and instance dir
    """
    api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())
    if core:
      raise PopupException(_('Cannot remove Solr cores.'))

    if api.remove_collection(name):
      # Delete instance directory.
      solrctl_path = get_solrctl_path()

      process = subprocess.Popen([solrctl_path, "--zk", get_solr_ensemble(), "instancedir", "--delete", name],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE
                                 )
      if process.wait() != 0:
        LOG.error("Cloud not delete instance directory.\nOutput stream: %s\nError stream: %s" % process.communicate())
        raise PopupException(_('Could not create instance directory. Check error logs for more info.'))
    else:
      raise PopupException(_('Could not remove collection. Check error logs for more info.'))