Browse Source

HUE-8330 [cluster] Start using has_computes flag in API

Romain 6 years ago
parent
commit
727ae97297

+ 4 - 6
desktop/core/src/desktop/api2.py

@@ -93,12 +93,11 @@ def get_context_namespaces(request, interface):
       'name': cluster['name'],
       'status': 'CREATED',
       'computes': [cluster]
-    } for cluster in clusters if cluster.get('type') == 'direct' and cluster['interface'] in (interface, 'all')
+    } for cluster in clusters if cluster.get('type') == 'direct'
   ])
 
   if interface == 'hive' or interface == 'impala' or interface == 'report':
-    # From Altus SDX
-    if [cluster for cluster in clusters if 'altus' in cluster['type']]:
+    if get_cluster_config(request.user)['has_computes']:
       # Note: attaching computes to namespaces might be done via the frontend in the future
       if interface == 'impala':
         if IS_K8S_ONLY.get():
@@ -146,7 +145,6 @@ def get_context_computes(request, interface):
   computes = []
 
   clusters = get_clusters(request.user).values()
-  has_altus_clusters = [cluster for cluster in clusters if 'altus' in cluster['type'] or 'snowball' in cluster['type']]
 
   # Currently broken if not sent
   computes.extend([{
@@ -155,10 +153,10 @@ def get_context_computes(request, interface):
       'namespace': cluster['id'],
       'interface': interface,
       'type': cluster['type']
-    } for cluster in clusters if cluster.get('type') == 'direct' and cluster['interface'] in (interface, 'all')
+    } for cluster in clusters if cluster.get('type') == 'direct'
   ])
 
-  if has_altus_clusters:
+  if get_cluster_config(request.user)['has_computes']:
     if interface == 'impala' or interface == 'report':
       if IS_K8S_ONLY.get():
         dw_clusters = DataWarehouse2Api(request.user).list_clusters()['clusters']

+ 3 - 11
desktop/libs/notebook/src/notebook/connectors/base.py

@@ -278,7 +278,7 @@ def get_interpreter(connector_type, user=None):
     interpreter for interpreter in get_ordered_interpreters(user) if connector_type == interpreter['type']
   ]
   if not interpreter:
-    if snippet['type'] == 'hbase': # TODO move to connectors
+    if connector_type == 'hbase': # TODO move to connectors
       interpreter = [{
         'name': 'hbase',
         'type': 'hbase',
@@ -286,7 +286,7 @@ def get_interpreter(connector_type, user=None):
         'options': {},
         'is_sql': False
       }]
-    elif snippet['type'] == 'kafka':
+    elif connector_type == 'kafka':
       interpreter = [{
         'name': 'kafka',
         'type': 'kafka',
@@ -294,7 +294,7 @@ def get_interpreter(connector_type, user=None):
         'options': {},
         'is_sql': False
       }]
-    elif snippet['type'] == 'solr':
+    elif connector_type == 'solr':
       interpreter = [{
         'name': 'solr',
         'type': 'solr',
@@ -302,14 +302,6 @@ def get_interpreter(connector_type, user=None):
         'options': {},
         'is_sql': False
       }]
-    elif snippet['type'] == 'custom':
-      interpreter = [{
-        'name': snippet['name'],
-        'type': snippet['type'],
-        'interface': snippet['interface'],
-        'options': snippet.get('options', {}),
-        'is_sql': False
-      }]
     else:
       raise PopupException(_('Snippet type %(type)s is not configured.') % snippet)
   elif len(interpreter) > 1: