Browse Source

[raz] Try to guess default home storage

Romain Rigaux 4 years ago
parent
commit
d7dac58bb5
1 changed files with 5 additions and 0 deletions
  1. 5 0
      desktop/core/src/desktop/models.py

+ 5 - 0
desktop/core/src/desktop/models.py

@@ -40,6 +40,7 @@ from django.contrib.staticfiles.storage import staticfiles_storage
 from django.urls import reverse, NoReverseMatch
 from django.urls import reverse, NoReverseMatch
 
 
 from dashboard.conf import get_engines, HAS_REPORT_ENABLED, IS_ENABLED as DASHBOARD_ENABLED
 from dashboard.conf import get_engines, HAS_REPORT_ENABLED, IS_ENABLED as DASHBOARD_ENABLED
+from hadoop.core_site import get_raz_api_url, get_raz_default_endpoint
 from kafka.conf import has_kafka
 from kafka.conf import has_kafka
 from indexer.conf import ENABLE_DIRECT_UPLOAD
 from indexer.conf import ENABLE_DIRECT_UPLOAD
 from metadata.conf import get_optimizer_mode
 from metadata.conf import get_optimizer_mode
@@ -1954,7 +1955,11 @@ class ClusterConfig(object):
     elif 'filebrowser' in self.apps and fsmanager.is_enabled_and_has_access('hdfs', self.user):
     elif 'filebrowser' in self.apps and fsmanager.is_enabled_and_has_access('hdfs', self.user):
       hdfs_connectors.append(_('Files'))
       hdfs_connectors.append(_('Files'))
 
 
+
     remote_home_storage = REMOTE_STORAGE_HOME.get() if hasattr(REMOTE_STORAGE_HOME, 'get') and REMOTE_STORAGE_HOME.get() else None
     remote_home_storage = REMOTE_STORAGE_HOME.get() if hasattr(REMOTE_STORAGE_HOME, 'get') and REMOTE_STORAGE_HOME.get() else None
+    if not remote_home_storage:
+      if get_raz_api_url.get() and get_raz_default_endpoint():
+        remote_home_storage = 's3a://%(bucket)s' % get_raz_default_endpoint()
 
 
     for hdfs_connector in hdfs_connectors:
     for hdfs_connector in hdfs_connectors:
       force_home = remote_home_storage and not remote_home_storage.startswith('/')
       force_home = remote_home_storage and not remote_home_storage.startswith('/')