Эх сурвалжийг харах

HUE-6857 [dataeng] Only filter the jobs of the active cluster

Romain Rigaux 8 жил өмнө
parent
commit
441b026

+ 14 - 7
apps/jobbrowser/src/jobbrowser/apis/data_eng_api.py

@@ -21,9 +21,11 @@ from datetime import datetime,  timedelta
 
 from django.utils.translation import ugettext as _
 
-from jobbrowser.apis.base_api import Api
+from desktop.models import Cluster, DATAENG
 from notebook.connectors.dataeng import DataEng, DATE_FORMAT
 
+from jobbrowser.apis.base_api import Api
+
 
 LOG = logging.getLogger(__name__)
 
@@ -37,18 +39,18 @@ class DataEngClusterApi(Api):
 
     return {
       'apps': [{
-        'id': app['clusterName'],
-        'name': '%(workersGroupSize)s %(instanceType)s %(cdhVersion)s' % app,
+        'id': app['crn'],
+        'name': '%(clusterName)s' % app,
         'status': app['status'],
         'apiStatus': self._api_status(app['status']),
-        'type': app['serviceType'],
+        'type': '%(serviceType)s %(workersGroupSize)s %(instanceType)s %(cdhVersion)s' % app,
         'user': app['clusterName'].split('-', 1)[0],
         'progress': 100,
         'queue': 'group',
-        'duration': 10 * 3600,
+        'duration': 1,
         'submitted': app['creationDate']
       } for app in jobs['clusters']],
-      'total': None
+      'total': len(jobs)
     }
 
 
@@ -90,6 +92,11 @@ class DataEngJobApi(Api):
         delta = timedelta(days=int(filters['time']['time_value']))
       kwargs['creation_date_after'] = (datetime.today() - delta).strftime(DATE_FORMAT)
 
+    # Could also come from filters
+    cluster = Cluster(self.user)
+    if cluster.get_type() == DATAENG:
+      kwargs['cluster_crn'] = cluster.get_id()
+
     api = DataEng(self.user)
 
     jobs = api.list_jobs(**kwargs)
@@ -106,7 +113,7 @@ class DataEngJobApi(Api):
         'duration': 10 * 3600,
         'submitted': app['creationDate']
       } for app in jobs['jobs']],
-      'total': None
+      'total': len(jobs)
     }
 
   def app(self, appid):

+ 3 - 0
desktop/core/src/desktop/models.py

@@ -1866,6 +1866,9 @@ class Cluster():
   def get_interface(self):
     return json.loads(self.default_cluster[USER_PREFERENCE_CLUSTER]).get('interface')
 
+  def get_id(self):
+    return json.loads(self.default_cluster[USER_PREFERENCE_CLUSTER]).get('id')
+
   def get_list_interface_indexes(self):
     default_cluster_index = 0
     default_cluster_interface = ''

+ 1 - 1
desktop/core/src/desktop/templates/hue.mako

@@ -1343,7 +1343,7 @@ ${ smart_unicode(login_modal(request).content) | n,unicode }
                 var interfaces = [];
                 if (data && data.apps) {
                   data.apps.forEach(function(cluster) {
-                    interfaces.push(ko.mapping.fromJS({'name': dataEngCluster[0].name(), 'type': 'dataeng', 'interface': cluster.id}));
+                    interfaces.push(ko.mapping.fromJS({'name': dataEngCluster[0].name(), 'type': 'dataeng', 'interface': cluster.name, 'id': cluster.id}));
                   });
                 }
                 dataEngCluster[0]['interfaces'](interfaces);

+ 2 - 0
desktop/libs/notebook/src/notebook/connectors/dataeng.py

@@ -40,6 +40,7 @@ def _exec(args):
        ] +
        args
     )
+    print args
   except Exception, e:
     raise PopupException(e, title=_('Error accessing'))
 
@@ -57,6 +58,7 @@ class DataEngApi(Api):
     Api.__init__(self, user, interpreter=interpreter, request=request)
     self.cluster_name = cluster_name
 
+
   def execute(self, notebook, snippet):
     statement = snippet['statement']