Browse Source

HUE-8330 [editor] Adding config flags for workload analysis

Romain Rigaux 7 years ago
parent
commit
c33c5cebed

+ 9 - 0
desktop/libs/metadata/src/metadata/conf.py

@@ -56,6 +56,9 @@ def get_optimizer_url():
 def has_optimizer():
   return bool(OPTIMIZER.AUTH_KEY_ID.get())
 
+def has_workload_analytics():
+  return bool(ALTUS.AUTH_KEY_ID.get()) and ALTUS.HAS_WA.get()
+
 
 def get_navigator_url():
   return NAVIGATOR.API_URL.get() and NAVIGATOR.API_URL.get().strip('/')[:-3]
@@ -178,6 +181,12 @@ ALTUS = ConfigSection(
       key='hostname_wa',
       help=_t('Hostname prefix to Altus WA API or compatible service.'),
       default='waapi.us-west-1.altus.cloudera.com'),
+    HAS_WA = Config(
+      key="has_wa",
+      help=_t("Switch to turn on workload analytics insights."),
+      default=True,
+      type=coerce_bool
+    ),
     AUTH_KEY_ID=Config(
       key="auth_key_id",
       help=_t("The name of the key of the service."),

+ 3 - 1
desktop/libs/notebook/src/notebook/views.py

@@ -31,7 +31,7 @@ from desktop.lib.json_utils import JSONEncoderForHTML
 from desktop.models import Document2, Document, FilesystemException
 from desktop.views import serve_403_error
 
-from metadata.conf import has_optimizer, has_navigator
+from metadata.conf import has_optimizer, has_navigator, has_workload_analytics
 
 from notebook.conf import get_ordered_interpreters, SHOW_NOTEBOOKS
 from notebook.connectors.base import Notebook, get_api, _get_snippet_name
@@ -86,6 +86,7 @@ def notebook(request, is_embeddable=False):
           'languages': get_ordered_interpreters(request.user),
           'session_properties': SparkApi.get_properties(),
           'is_optimizer_enabled': has_optimizer(),
+          'is_wa_enabled': has_workload_analytics(),
           'is_navigator_enabled': has_navigator(request.user),
           'editor_type': 'notebook'
       }),
@@ -126,6 +127,7 @@ def editor(request, is_mobile=False, is_embeddable=False):
         'languages': get_ordered_interpreters(request.user),
         'mode': 'editor',
         'is_optimizer_enabled': has_optimizer(),
+        'is_wa_enabled': has_workload_analytics(),
         'is_navigator_enabled': has_navigator(request.user),
         'editor_type': editor_type,
         'mobile': is_mobile