|
@@ -16,12 +16,33 @@
|
|
|
# limitations under the License.
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
import os
|
|
import os
|
|
|
|
|
+import subprocess
|
|
|
|
|
+from urlparse import urlparse
|
|
|
|
|
|
|
|
from django.utils.translation import ugettext_lazy as _t
|
|
from django.utils.translation import ugettext_lazy as _t
|
|
|
|
|
|
|
|
from desktop.lib.conf import Config
|
|
from desktop.lib.conf import Config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def solrctl():
|
|
|
|
|
+ """
|
|
|
|
|
+ solrctl path
|
|
|
|
|
+ """
|
|
|
|
|
+ try:
|
|
|
|
|
+ return subprocess.check_output(['which', 'solrctl'])
|
|
|
|
|
+ except subprocess.CalledProcessError:
|
|
|
|
|
+ return '/usr/bin/solrctl'
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def zkensemble():
|
|
|
|
|
+ """
|
|
|
|
|
+ ZooKeeper Ensemble
|
|
|
|
|
+ """
|
|
|
|
|
+ from search.conf import SOLR_URL
|
|
|
|
|
+ parsed = urlparse(SOLR_URL.get())
|
|
|
|
|
+ return "%s:2181/solr" % (parsed.hostname or 'localhost')
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
# Unused
|
|
# Unused
|
|
|
BATCH_INDEXER_PATH = Config(
|
|
BATCH_INDEXER_PATH = Config(
|
|
|
key="batch_indexer_path",
|
|
key="batch_indexer_path",
|
|
@@ -40,7 +61,7 @@ SOLRCTL_PATH = Config(
|
|
|
key="solrctl_path",
|
|
key="solrctl_path",
|
|
|
help=_t("Location of the solrctl binary."),
|
|
help=_t("Location of the solrctl binary."),
|
|
|
type=str,
|
|
type=str,
|
|
|
- default="/usr/bin/solrctl")
|
|
|
|
|
|
|
+ dynamic_default=solrctl)
|
|
|
|
|
|
|
|
SOLR_HOME = Config(
|
|
SOLR_HOME = Config(
|
|
|
key="solr_home",
|
|
key="solr_home",
|
|
@@ -52,4 +73,4 @@ SOLR_ZK_ENSEMBLE = Config(
|
|
|
key="solr_zk_ensemble",
|
|
key="solr_zk_ensemble",
|
|
|
help=_t("Zookeeper ensemble."),
|
|
help=_t("Zookeeper ensemble."),
|
|
|
type=str,
|
|
type=str,
|
|
|
- default="localhost:2181/solr")
|
|
|
|
|
|
|
+ dynamic_default=zkensemble)
|