Pārlūkot izejas kodu

HUE-8643 [importer] Fix showing the import command

Also fix listing k8s clusters starting up
Fix NavOpt upload API change
Romain Rigaux 7 gadi atpakaļ
vecāks
revīzija
841da88

+ 2 - 2
desktop/core/src/desktop/api2.py

@@ -116,7 +116,7 @@ def get_context_namespaces(request, interface):
         sdx_namespaces = SdxApi(request.user).list_namespaces()
 
       # Adding "fake" namespace for cluster without one
-      sdx_namespaces.extend([_cluster for _cluster in adb_clusters if not _cluster.get('namespaceCrn') or (IS_K8S_ONLY.get() and _cluster['status'] == 'ONLINE')])
+      sdx_namespaces.extend([_cluster for _cluster in adb_clusters if not _cluster.get('namespaceCrn') or (IS_K8S_ONLY.get() and _cluster['status'] != 'TERMINATING')])
 
       namespaces.extend([{
           'id': namespace.get('crn', 'None'),
@@ -164,7 +164,7 @@ def get_context_computes(request, interface):
           'namespace': cluster.get('namespaceCrn', cluster.get('crn')),
           'compute_end_point': IS_K8S_ONLY.get() and '%(publicHost)s' % cluster['coordinatorEndpoint'] or '',
           'type': 'altus-dw'
-        } for cluster in dw_clusters if (cluster.get('status') == 'CREATED' and cluster.get('cdhVersion') >= 'CDH515') or (IS_K8S_ONLY.get() and cluster['status'] == 'ONLINE')]
+        } for cluster in dw_clusters if (cluster.get('status') == 'CREATED' and cluster.get('cdhVersion') >= 'CDH515') or (IS_K8S_ONLY.get() and cluster['status'] != 'TERMINATING')]
       )
 
     if interface == 'oozie' or interface == 'spark2':

+ 6 - 5
desktop/libs/indexer/src/indexer/api3.py

@@ -355,7 +355,7 @@ def importer_submit(request):
       stats = request.fs.stats(parent_path)
       split = urlparse(path)
       # Only for HDFS, import data and non-external table
-      if split.scheme in ('', 'hdfs') and destination['importData'] and destination['useDefaultLocation'] and oct(stats["mode"])[-1] != '7' and not request.POST.get('options'):
+      if split.scheme in ('', 'hdfs') and destination['importData'] and destination['useDefaultLocation'] and oct(stats["mode"])[-1] != '7' and not request.POST.get('show_command'):
         user_scratch_dir = request.fs.get_home_dir() + '/.scratchdir'
         request.fs.do_as_user(request.user, request.fs.mkdir, user_scratch_dir, 00777)
         request.fs.do_as_user(request.user, request.fs.rename, source['path'], user_scratch_dir)
@@ -487,7 +487,8 @@ def _create_database(request, source, destination, start_time):
 
 def _create_table(request, source, destination, start_time=-1):
   notebook = SQLIndexer(user=request.user, fs=request.fs).create_table_from_a_file(source, destination, start_time)
-  if request.POST.get('options'):
+
+  if request.POST.get('show_command'):
     return {'status': 0, 'commands': notebook.get_str()}
   else:
     return notebook.execute(request, batch=False)
@@ -505,7 +506,7 @@ def _large_indexing(request, file_format, collection_name, query=None, start_tim
 
   client = SolrClient(user=request.user)
 
-  if not client.exists(collection_name) and not request.POST.get('options'): # if destination['isTargetExisting']:
+  if not client.exists(collection_name) and not request.POST.get('show_command'): # if destination['isTargetExisting']:
     client.create_index(
       name=collection_name,
       fields=request.POST.get('fields', schema_fields),
@@ -522,7 +523,7 @@ def _large_indexing(request, file_format, collection_name, query=None, start_tim
     input_path = table_metadata.path_location
   elif file_format['inputFormat'] == 'stream' and file_format['streamSelection'] == 'flume':
     indexer = FlumeIndexer(user=request.user)
-    if request.POST.get('options'):
+    if request.POST.get('show_command'):
       configs = indexer.generate_config(file_format, destination)
       return {'status': 0, 'commands': configs[-1]}
     else:
@@ -638,7 +639,7 @@ def _envelope_job(request, file_format, destination, start_time=None, lib_path=N
 
   configs = indexer.generate_config(properties)
 
-  if request.POST.get('options'):
+  if request.POST.get('show_command'):
     return {'status': 0, 'commands': configs['envelope.conf']}
   else:
     return indexer.run(request, collection_name, configs, input_path, start_time=start_time, lib_path=lib_path)

+ 1 - 1
desktop/libs/indexer/src/indexer/indexers/rdbms.py

@@ -260,7 +260,7 @@ def run_sqoop(request, source, destination, start_time):
     is_task=True
   )
 
-  if request.POST.get('options'):
+  if request.POST.get('show_command'):
     return {'status': 0, 'commands': task.get_str()}
   else:
     return task.execute(request, batch=False)

+ 4 - 3
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -1073,7 +1073,7 @@ ${ assist.assistPanel() }
       <!-- /ko -->
 
       <!-- ko if: currentStep() == 2 -->
-        <button class="btn btn-primary disable-feedback" data-bind="click: createWizard.indexFile, enable: createWizard.readyToIndex() && !createWizard.indexingStarted()">
+        <button class="btn btn-primary disable-feedback" data-bind="click: function() { createWizard.indexFile(); }, enable: createWizard.readyToIndex() && !createWizard.indexingStarted()">
           ${ _('Submit') } <i class="fa fa-spinner fa-spin" data-bind="visible: createWizard.indexingStarted"></i>
         </button>
         
@@ -1081,7 +1081,7 @@ ${ assist.assistPanel() }
         <button class="btn disable-feedback" data-bind="click: createWizard.showCommands, enable: createWizard.readyToIndex()">
           ${ _('Show Commands') }
         </button>
-        <button class="btn disable-feedback" data-bind="click: createWizard.indexFile">
+        <button class="btn disable-feedback">
           ${ _('Save') }
         </button>
         % endif
@@ -2751,6 +2751,7 @@ ${ assist.assistPanel() }
         self.indexFile({show: true});
       };
       self.indexFile = function (options) {
+        var options = options || {};
         if (!self.readyToIndex()) {
           return;
         }
@@ -2865,7 +2866,7 @@ ${ assist.assistPanel() }
           "source": ko.mapping.toJSON(self.source),
           "destination": ko.mapping.toJSON(self.destination),
           "start_time": ko.mapping.toJSON((new Date()).getTime()),
-          "options": ko.mapping.toJSON(options || {})
+          "show_command": ko.mapping.toJSON(options.show || '')
         }, function (resp) {
           self.indexingStarted(false);
           if (resp.status === 0) {

+ 1 - 0
desktop/libs/metadata/src/metadata/optimizer_client.py

@@ -128,6 +128,7 @@ class OptimizerApi(object):
     else:
       data_suffix = '.csv'
       extra_parameters = {
+          'fileType': 'QUERY',
           'colDelim': ',',
           'rowDelim': '\n',
           "headerFields": [