|
|
@@ -16,6 +16,7 @@
|
|
|
# limitations under the License.
|
|
|
|
|
|
import logging
|
|
|
+import os
|
|
|
|
|
|
from subprocess import CalledProcessError
|
|
|
|
|
|
@@ -23,11 +24,10 @@ from django.utils.translation import ugettext_lazy as _t
|
|
|
|
|
|
from desktop.conf import AUTH_USERNAME as DEFAULT_AUTH_USERNAME, CLUSTER_ID as DEFAULT_CLUSTER_ID
|
|
|
from desktop.lib.conf import Config, ConfigSection, coerce_bool, coerce_password_from_script
|
|
|
-from desktop.lib.paths import get_config_root
|
|
|
-
|
|
|
-from hadoop.core_site import is_kerberos_enabled
|
|
|
+from desktop.lib.paths import get_config_root, get_desktop_root
|
|
|
|
|
|
from metadata.settings import DJANGO_APPS
|
|
|
+from metadata.catalog import atlas_flags
|
|
|
|
|
|
|
|
|
OPTIMIZER_AUTH_PASSWORD = None
|
|
|
@@ -40,18 +40,17 @@ def get_auth_username():
|
|
|
"""Get from top level default from desktop"""
|
|
|
return DEFAULT_AUTH_USERNAME.get()
|
|
|
|
|
|
-
|
|
|
def default_catalog_url():
|
|
|
"""Get from main Hue config directory if present"""
|
|
|
- return None
|
|
|
+ return atlas_flags.get_api_url() if atlas_flags.get_api_url() else None
|
|
|
|
|
|
def default_catalog_config_dir():
|
|
|
"""Get from usual main Hue config directory"""
|
|
|
- return get_config_root()
|
|
|
+ return os.environ.get("HUE_CONF_DIR", get_desktop_root("conf")) + '/hive-conf'
|
|
|
|
|
|
def default_catalog_interface():
|
|
|
"""Detect if the configured catalog is Navigator or default to Atlas"""
|
|
|
- return 'navigator' if default_navigator_url() else 'atlas'
|
|
|
+ return 'atlas' if atlas_flags.get_api_url() else 'navigator'
|
|
|
|
|
|
def default_navigator_config_dir():
|
|
|
"""Get from usual main Hue config directory"""
|
|
|
@@ -225,7 +224,7 @@ DEFAULT_PUBLIC_KEY = Config(
|
|
|
# Data Catalog
|
|
|
|
|
|
def get_catalog_url():
|
|
|
- return (CATALOG.API_URL.get() and CATALOG.API_URL.get().strip('/')[:-3]) or get_navigator_url()
|
|
|
+ return (CATALOG.API_URL.get() and CATALOG.API_URL.get().strip('/')) or get_navigator_url()
|
|
|
|
|
|
def has_catalog(user):
|
|
|
from desktop.auth.backend import is_admin
|
|
|
@@ -239,10 +238,11 @@ def get_catalog_search_cluster():
|
|
|
return CATALOG.SEARCH_CLUSTER.get()
|
|
|
|
|
|
def get_kerberos_enabled_default():
|
|
|
- '''Use core-site is_kerberos_enabled'''
|
|
|
- return is_kerberos_enabled()
|
|
|
+ '''Use atlas.authentication.method.kerberos if catalog interface is atlas else False '''
|
|
|
+ return atlas_flags.is_kerberos_enabled() if CATALOG.INTERFACE.get() == 'atlas' else False
|
|
|
|
|
|
def get_catalog_server_password_script():
|
|
|
+ '''Execute script at path'''
|
|
|
return CATALOG.SERVER_PASSWORD_SCRIPT.get()
|
|
|
|
|
|
|
|
|
@@ -288,6 +288,11 @@ CATALOG = ConfigSection(
|
|
|
help=_t("Set to true when authenticating via kerberos instead of username/password"),
|
|
|
type=coerce_bool,
|
|
|
dynamic_default=get_kerberos_enabled_default
|
|
|
+ ),
|
|
|
+ CONF_DIR=Config(
|
|
|
+ key="conf_dir",
|
|
|
+ help=_t("Directory of the configuration. Defaults to HUE_CONF_DIR/hue-conf"),
|
|
|
+ dynamic_default=default_catalog_config_dir
|
|
|
)
|
|
|
)
|
|
|
)
|