Browse Source

[raz] Auto detect API url from config file

Romain Rigaux 4 years ago
parent
commit
0d6812679f
2 changed files with 13 additions and 2 deletions
  1. 2 1
      desktop/core/src/desktop/conf.py
  2. 11 1
      desktop/libs/hadoop/src/hadoop/core_site.py

+ 2 - 1
desktop/core/src/desktop/conf.py

@@ -28,6 +28,7 @@ from collections import OrderedDict
 
 from django.db import connection
 
+from hadoop.core_site import get_raz_api_url
 from metadata.metadata_sites import get_navigator_audit_log_dir, get_navigator_audit_max_file_size
 
 from desktop import appmanager
@@ -2108,7 +2109,7 @@ RAZ = ConfigSection(
         key='api_url',
         help=_('Endpoint to contact'),
         type=str,
-        default='https://localhost:8080',
+        dynamic_default=get_raz_api_url,
     ),
     API_AUTHENTICATION=Config(
         key='api_authentication',

+ 11 - 1
desktop/libs/hadoop/src/hadoop/core_site.py

@@ -42,6 +42,8 @@ _CNF_S3A_ACCESS_KEY = 'fs.s3a.access.key'
 _CNF_S3A_SECRET_KEY = 'fs.s3a.secret.key'
 _CNF_S3A_SESSION_TOKEN = 'fs.s3a.session.token'
 
+_CNF_S3A_RAZ_API_URL = 'fs.s3a.ext.raz.rest.host.url'
+
 _CNF_ADLS_CLIENT_ID = 'dfs.adls.oauth2.client.id'
 _CNF_ADLS_AUTHENTICATION_CODE = 'dfs.adls.oauth2.credential'
 _CNF_ADLS_REFRESH_URL = 'dfs.adls.oauth2.refresh.url'
@@ -111,6 +113,14 @@ def get_s3a_secret_key():
 def get_s3a_session_token():
   return get_conf().get(_CNF_S3A_SESSION_TOKEN)
 
+def get_raz_api_url():
+  """
+  Get Raz API.
+
+  S3 only. Add check for Azure when supported.
+  """
+  return get_conf().get(_CNF_S3A_RAZ_API_URL, 'https://localhost:8080')
+
 def get_adls_client_id():
   """
   Get ADLS client id
@@ -149,4 +159,4 @@ def get_azure_client_secret():
   return get_conf().get(_CNF_AZURE_CLIENT_SECRET)
 
 def get_azure_client_endpoint():
-  return get_conf().get(_CNF_AZURE_CLIENT_ENDPOINT)
+  return get_conf().get(_CNF_AZURE_CLIENT_ENDPOINT)