瀏覽代碼

HUE-8758 [connectors] Update conf to properly list connectors

Romain 6 年之前
父節點
當前提交
390d54daaf

+ 29 - 11
desktop/core/src/desktop/conf.py

@@ -1807,19 +1807,37 @@ CLUSTERS = UnspecifiedConfigSection(
 )
 
 
-CONNECTORS = ConfigSection(
+CONNECTORS = UnspecifiedConfigSection(
   key='connectors',
   help=_("""Configuration options for connectors to external services"""),
-  members=dict(
-    # IS_ENABLED=Config(
-    #   key='is_enabled',
-    #   help=_('Enable connector page'),
-    #   default=False,
-    #   type=coerce_bool),
-   LIST=Config(
-      key='list',
-      default=['impala'],
-      type=coerce_csv),
+  each=ConfigSection(
+    help=_("Id of the connector."),
+    members=dict(
+      NAME=Config(
+          "name",
+          help=_("Nice name of the connector to show to the user. Same as id if not specified."),
+          default=None,
+          type=str,
+      ),
+      TYPE=Config(
+          "type",
+          help=_("Type of cluster, e.g. single, direct, local ini, CM API, Dataeng, Arcus, BigQuery, Presto."),
+          default='direct',
+          type=str,
+      ),
+      INTERFACE=Config(
+          "interface",
+          help=_("Type of cluster interface"),
+          default='hive',
+          type=str,
+      ),
+      OPTIONS=Config(
+        key='options',
+        help=_('Specific options for connecting to the server.'),
+        type=coerce_json_dict,
+        default='{}'
+      )
+    )
   )
 )
 

+ 0 - 2
desktop/core/src/desktop/lib/connectors/api.py

@@ -114,7 +114,6 @@ CONNECTOR_INSTANCES = [
   {'name': 'MySQL', 'type': 'mysql-4', 'connector_name': 'sql-alchemy', 'interface': 'sqlalchemy', 'settings': [], 'id': 4, 'category': 'engines', 'description': ''},
 ]
 
-
 CONNECTOR_INSTANCES[0]['settings'] = [
   {'name': 'server_host', 'value': 'self-service-dw-2.gce.cloudera.com'},
   {'name': 'server_port', 'value': '21050'},
@@ -132,7 +131,6 @@ CONNECTOR_INSTANCES[3]['settings'] = [
 ]
 
 
-
 def get_connector_classes(request):
   global AVAILABLE_CONNECTORS
   global CATEGORIES

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

@@ -324,15 +324,13 @@ def get_api(request, snippet):
   interpreter = interpreter[0]
   interface = interpreter['interface']
 
-
+  # TODO: Multi cluster --> multi computes of a connector
   if has_connectors():
     cluster = {
       'connector': snippet['type'],
       'id': interpreter['type'],
     }
-    snippet['type'] = snippet['type'].split('-', 2)[0]
     cluster.update(interpreter['options'])
-  # Multi cluster
   elif has_multi_cluster():
     cluster = json.loads(request.POST.get('cluster', '""')) # Via Catalog autocomplete API or Notebook create sessions
     if cluster == '""' or cluster == 'undefined':