当前位置: 首页>>代码示例>>Python>>正文


Python conf.SECURITY_ENABLED类代码示例

本文整理汇总了Python中search.conf.SECURITY_ENABLED的典型用法代码示例。如果您正苦于以下问题:Python SECURITY_ENABLED类的具体用法?Python SECURITY_ENABLED怎么用?Python SECURITY_ENABLED使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SECURITY_ENABLED类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_collection

  def create_collection(self, name, fields, unique_key_field='id', df='text'):
    """
    Create solr collection or core and instance dir.
    Create schema.xml file so that we can set UniqueKey field.
    """
    if self.is_solr_cloud_mode():
      # solrcloud mode

      # Need to remove path afterwards
      tmp_path, solr_config_path = utils.copy_configs(fields, unique_key_field, df, True)

      # Create instance directory.
      solrctl_path = get_solrctl_path()

      process = subprocess.Popen([solrctl_path, "instancedir", "--create", name, solr_config_path],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,
                                 env={
                                   'SOLR_ZK_ENSEMBLE': conf.SOLR_ZK_ENSEMBLE.get()
                                 })
      status = process.wait()

      # Don't want directories laying around
      shutil.rmtree(tmp_path)

      if status != 0:
        LOG.error("Could not create instance directory.\nOutput: %s\nError: %s" % process.communicate())
        raise PopupException(_('Could not create instance directory. '
                               'Check if solr_zk_ensemble and solrctl_path are correct in Hue config [indexer].'))

      api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())
      if not api.create_collection(name):
        # Delete instance directory if we couldn't create a collection.
        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 collection.\nOutput: %s\nError: %s" % process.communicate())
        raise PopupException(_('Could not create collection. Check error logs for more info.'))
    else:
      # Non-solrcloud mode
      # Create instance directory locally.
      instancedir = os.path.join(conf.CORE_INSTANCE_DIR.get(), name)
      if os.path.exists(instancedir):
        raise PopupException(_("Instance directory %s already exists! Please remove it from the file system.") % instancedir)
      tmp_path, solr_config_path = utils.copy_configs(fields, unique_key_field, df, False)
      shutil.move(solr_config_path, instancedir)
      shutil.rmtree(tmp_path)

      api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())
      if not api.create_core(name, instancedir):
        # Delete instance directory if we couldn't create a collection.
        shutil.rmtree(instancedir)
        raise PopupException(_('Could not create collection. Check error logs for more info.'))
开发者ID:Lt-Pone,项目名称:hue,代码行数:57,代码来源:controller.py

示例2: get_fields

  def get_fields(self, collection_or_core_name):
    try:
      field_data = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get()).fields(collection_or_core_name)
      fields = self._format_flags(field_data['schema']['fields'])
    except:
      LOG.exception(_('Could not fetch fields for collection %s.') % collection_or_core_name)
      raise PopupException(_('Could not fetch fields for collection %s. See logs for more info.') % collection_or_core_name)

    try:
      uniquekey = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get()).uniquekey(collection_or_core_name)
    except:
      LOG.exception(_('Could not fetch unique key for collection %s.') % collection_or_core_name)
      raise PopupException(_('Could not fetch unique key for collection %s. See logs for more info.') % collection_or_core_name)

    return uniquekey, fields
开发者ID:zhxing,项目名称:hue,代码行数:15,代码来源:controller.py

示例3: create_collection

  def create_collection(self, name, fields, unique_key_field='id', df='text'):
    """
    Create solr collection or core and instance dir.
    Create schema.xml file so that we can set UniqueKey field.
    """
    if self.is_solr_cloud_mode():
      # solrcloud mode

      # Need to remove path afterwards
      tmp_path, solr_config_path = copy_configs(fields, unique_key_field, df, True)

      zc = ZookeeperClient(hosts=get_solr_ensemble(), read_only=False)
      root_node = '%s/%s' % (ZK_SOLR_CONFIG_NAMESPACE, name)
      config_root_path = '%s/%s' % (solr_config_path, 'conf')
      try:
        zc.copy_path(root_node, config_root_path)
      except Exception, e:
        zc.delete_path(root_node)
        raise PopupException(_('Error in copying Solr configurations.'), detail=e)

      # Don't want directories laying around
      shutil.rmtree(tmp_path)

      api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())
      if not api.create_collection(name):
        # Delete instance directory if we couldn't create a collection.
        try:
          zc.delete_path(root_node)
        except Exception, e:
          raise PopupException(_('Error in deleting Solr configurations.'), detail=e)
开发者ID:renxiawang,项目名称:hue,代码行数:30,代码来源:controller.py

示例4: __init__

 def __init__(self, solr_url, user, security_enabled=SECURITY_ENABLED.get()):
   self._url = solr_url
   self._user = user
   self._client = HttpClient(self._url, logger=LOG)
   self.security_enabled = security_enabled
   if self.security_enabled:
     self._client.set_kerberos_auth()
   self._root = resource.Resource(self._client)
开发者ID:findhy,项目名称:hue,代码行数:8,代码来源:api.py

示例5: is_solr_cloud_mode

 def is_solr_cloud_mode(self):
   api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())
   if not hasattr(self, '_solr_cloud_mode'):
     try:
       api.collections()
       setattr(self, '_solr_cloud_mode', True)
     except:
       setattr(self, '_solr_cloud_mode', False)
   return getattr(self, '_solr_cloud_mode')
开发者ID:Ile2,项目名称:hue,代码行数:9,代码来源:controller.py

示例6: create_or_edit_alias

def create_or_edit_alias(request):
  if request.method != 'POST':
    raise PopupException(_('POST request required.'))

  response = {'status': -1}

  alias = request.POST.get('alias', '')
  collections = json.loads(request.POST.get('collections', '[]'))

  api = SolrApi(SOLR_URL.get(), request.user, SECURITY_ENABLED.get())

  try:
    api.create_or_modify_alias(alias, collections)
    response['status'] = 0
    response['message'] = _('Alias created or modified!')
  except Exception, e:
    response['message'] = _('Alias could not be created or modified: %s') % e
开发者ID:jounex,项目名称:hue,代码行数:17,代码来源:api2.py

示例7: __init__

  def __init__(self, solr_url, user, security_enabled=SECURITY_ENABLED.get()):
    self._url = solr_url
    self._user = user
    self._client = HttpClient(self._url, logger=LOG)
    self.security_enabled = security_enabled

    if self.security_enabled:
      self._client.set_kerberos_auth()

    self._root = resource.Resource(self._client)

    # The Kerberos handshake requires two requests in order to authenticate,
    # but if our first request is a PUT/POST, it might flat-out reject the
    # first request if the body is too large. So, connect here in order to get
    # a cookie so future PUT/POSTs will be pre-authenticated.
    if self.security_enabled:
      self._root.invoke('HEAD', '/')
开发者ID:RoxC,项目名称:hue,代码行数:17,代码来源:api.py

示例8: delete_collection

 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.'))
开发者ID:CrazyJvm,项目名称:hue,代码行数:19,代码来源:controller.py

示例9: delete_collection

  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.'))
开发者ID:zhxing,项目名称:hue,代码行数:21,代码来源:controller.py

示例10: create_collection

  def create_collection(self, name, fields, unique_key_field='id', df='text'):
    """
    Create solr collection and instance dir.
    Create schema.xml file so that we can set UniqueKey field.
    """
    # Need to remove path afterwards
    tmp_path, solr_config_path = utils.copy_configs(fields, unique_key_field, df)

    # Create instance directory.
    process = subprocess.Popen([conf.SOLRCTL_PATH.get(), "instancedir", "--create", name, solr_config_path],
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE,
                               env={
                                 'SOLR_HOME': conf.SOLR_HOME.get(),
                                 'SOLR_ZK_ENSEMBLE': conf.SOLR_ZK_ENSEMBLE.get()
                               })
    status = process.wait()
    shutil.rmtree(tmp_path)

    if status != 0:
      LOG.error("Cloud not create instance directory.\nOutput stream: %s\nError stream: %s" % process.communicate())
      raise PopupException(_('Could not create instance directory. Check error logs for more info.'))

    api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())

    if not api.create_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 collection. Check error logs for more info.'))
开发者ID:CrazyJvm,项目名称:hue,代码行数:38,代码来源:controller.py

示例11: __init__

 def __init__(self, user):
   self.user = user
   self.api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())
开发者ID:GorillaTester,项目名称:hue,代码行数:3,代码来源:controller2.py

示例12: PopupException

        # Delete instance directory if we couldn't create a collection.
        try:
          zc.delete_path(root_node)
        except Exception, e:
          raise PopupException(_('Error in deleting Solr configurations.'), detail=e)
    else:
      # Non-solrcloud mode
      # Create instance directory locally.
      instancedir = os.path.join(CORE_INSTANCE_DIR.get(), name)
      if os.path.exists(instancedir):
        raise PopupException(_("Instance directory %s already exists! Please remove it from the file system.") % instancedir)
      tmp_path, solr_config_path = copy_configs(fields, unique_key_field, df, False)
      shutil.move(solr_config_path, instancedir)
      shutil.rmtree(tmp_path)

      api = SolrApi(SOLR_URL.get(), self.user, SECURITY_ENABLED.get())
      if not api.create_core(name, instancedir):
        # Delete instance directory if we couldn't create a collection.
        shutil.rmtree(instancedir)
        raise PopupException(_('Could not create collection. Check error logs for more info.'))

  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.
开发者ID:renxiawang,项目名称:hue,代码行数:31,代码来源:controller.py

示例13: __init__

 def __init__(self, solr_url):
   self._url = solr_url
   self._client = HttpClient(self._url, logger=LOG)
   if SECURITY_ENABLED.get():
     self._client.set_kerberos_auth()
   self._root = Resource(self._client)
开发者ID:Roxasora,项目名称:hue,代码行数:6,代码来源:api.py

示例14: is_enabled

def is_enabled():
  try:
    from search.conf import SECURITY_ENABLED
    return SECURITY_ENABLED.get()
  except ImportError, e:
    LOG.warn("Search app is not enabled")
开发者ID:CaeserNieh,项目名称:hue,代码行数:6,代码来源:conf.py


注:本文中的search.conf.SECURITY_ENABLED类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。