conf.py 1.9 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 desktop.lib.conf import Config, coerce_bool
  22. from desktop.conf import default_ssl_validate
  23. from libzookeeper.conf import ENSEMBLE
  24. if sys.version_info[0] > 2:
  25. from urllib.parse import urlparse
  26. new_str = str
  27. from django.utils.translation import gettext_lazy as _t
  28. else:
  29. from django.utils.translation import ugettext_lazy as _t
  30. from urlparse import urlparse
  31. LOG = logging.getLogger(__name__)
  32. SSL_CERT_CA_VERIFY = Config(
  33. key="ssl_cert_ca_verify",
  34. help=_t("In secure mode (HTTPS), if Solr SSL certificates have to be verified against certificate authority"),
  35. dynamic_default=default_ssl_validate,
  36. type=coerce_bool
  37. )
  38. def zkensemble_path():
  39. """
  40. Try to guess Solr path in ZooKeeper.
  41. """
  42. try:
  43. parsed = urlparse(ENSEMBLE.get())
  44. if parsed.port == 9983: # Standalone Solr cloud
  45. return ''
  46. except:
  47. LOG.warning('Failed to get Zookeeper ensemble path')
  48. return '/solr'
  49. SOLR_ZK_PATH = Config(
  50. key="solr_zk_path",
  51. help=_t("Default path to Solr in ZooKeeper"),
  52. dynamic_default=zkensemble_path,
  53. type=str
  54. )