conf.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/usr/bin/env python
  2. # Licensed to Cloudera, Inc. under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. Cloudera, Inc. licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. from future import standard_library
  18. standard_library.install_aliases()
  19. import logging
  20. import sys
  21. from django.utils.translation import ugettext_lazy as _t
  22. from desktop.lib.conf import Config, coerce_bool
  23. from desktop.conf import default_ssl_validate
  24. from libzookeeper.conf import ENSEMBLE
  25. if sys.version_info[0] > 2:
  26. from urllib.parse import urlparse
  27. new_str = str
  28. else:
  29. from urlparse import urlparse
  30. LOG = logging.getLogger(__name__)
  31. SSL_CERT_CA_VERIFY = Config(
  32. key="ssl_cert_ca_verify",
  33. help=_t("In secure mode (HTTPS), if Solr SSL certificates have to be verified against certificate authority"),
  34. dynamic_default=default_ssl_validate,
  35. type=coerce_bool
  36. )
  37. def zkensemble_path():
  38. """
  39. Try to guess Solr path in ZooKeeper.
  40. """
  41. try:
  42. parsed = urlparse(ENSEMBLE.get())
  43. if parsed.port == 9983: # Standalone Solr cloud
  44. return ''
  45. except:
  46. LOG.warn('Failed to get Zookeeper ensemble path')
  47. return '/solr'
  48. SOLR_ZK_PATH = Config(
  49. key="solr_zk_path",
  50. help=_t("Default path to Solr in ZooKeeper"),
  51. dynamic_default=zkensemble_path,
  52. type=str
  53. )