Explorar o código

HUE-1176 [jb] Adding skeleton for bundle page

Romain Rigaux %!s(int64=9) %!d(string=hai) anos
pai
achega
66a3d59

+ 4 - 1
apps/jobbrowser/src/jobbrowser/apis/base_api.py

@@ -26,9 +26,10 @@ LOG = logging.getLogger(__name__)
 
 
 def get_api(user, interface):
-  from jobbrowser.apis.workflow_api import WorkflowApi
+  from jobbrowser.apis.bundle_api import BundleApi
   from jobbrowser.apis.job_api import JobApi
   from jobbrowser.apis.schedule_api import ScheduleApi
+  from jobbrowser.apis.workflow_api import WorkflowApi
 
   if interface == 'apps':
     return JobApi(user)
@@ -36,6 +37,8 @@ def get_api(user, interface):
     return WorkflowApi(user)
   elif interface == 'schedules':
     return ScheduleApi(user)
+  elif interface == 'bundles':
+    return BundleApi(user)
   else:
     raise PopupException(_('Interface %s is unknown') % interface)
 

+ 65 - 0
apps/jobbrowser/src/jobbrowser/apis/bundle_api.py

@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+# Licensed to Cloudera, Inc. under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  Cloudera, Inc. licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import logging
+
+from django.utils.translation import ugettext as _
+
+from liboozie.oozie_api import get_oozie
+from notebook.connectors.oozie_batch import OozieApi
+
+from jobbrowser.apis.base_api import Api
+from oozie.views.dashboard import get_oozie_job_log
+
+
+LOG = logging.getLogger(__name__)
+
+
+try:
+  from oozie.conf import OOZIE_JOBS_COUNT
+  from oozie.views.dashboard import massaged_coordinator_actions_for_json
+except Exception, e:
+  LOG.exception('Some application are not enabled: %s' % e)
+
+
+class BundleApi(Api):
+
+  def apps(self):
+    oozie_api = get_oozie(self.user)
+    kwargs = {'cnt': OOZIE_JOBS_COUNT.get(), 'filters': []}
+    wf_list = oozie_api.get_bundles(**kwargs)
+
+    return [{
+        'id': app.id,
+        'name': app.appName,
+        'status': app.status,
+        'type': 'bundle',
+        'user': app.user,
+        'progress': 100,
+        'duration': 10 * 3600,
+        'submitted': 10 * 3600
+    } for app in wf_list.jobs]
+
+  def app(self, appid):
+    oozie_api = get_oozie(self.user)
+    bundle = oozie_api.get_bundle(jobid=appid)
+
+    return {
+        'id': bundle.bundleJobId,
+        'name': bundle.bundleJobName,
+        'status': bundle.status,
+    }

+ 17 - 1
apps/jobbrowser/src/jobbrowser/templates/apps.mako

@@ -182,6 +182,10 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
             <!-- ko if: $root.job().mainType() == 'schedules' -->
               <div data-bind="template: { name: 'schedule-page', data: $root.job() }"></div>
             <!-- /ko -->
+
+            <!-- ko if: $root.job().mainType() == 'bundles' -->
+              <div data-bind="template: { name: 'bundle-page', data: $root.job() }"></div>
+            <!-- /ko -->
           <!-- /ko -->
 
           <div data-bind="template: { name: 'pagination' }, visible: ! $root.job()"></div>
@@ -620,6 +624,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
 
 </script>
 
+
 <script type="text/html" id="schedule-page">
   ${ _('Id') } <span data-bind="text: id"></span>
   ${ _('Name') } <span data-bind="text: name"></span>
@@ -657,8 +662,18 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
   </table>
   </div>
   <!-- /ko -->
-</div>
+</script>
+
 
+<script type="text/html" id="bundle-page">
+  ${ _('Id') } <span data-bind="text: id"></span>
+  ${ _('Name') } <span data-bind="text: name"></span>
+  ${ _('Type') } <span data-bind="text: type"></span>
+  ${ _('Status') } <span data-bind="text: status"></span>
+  ${ _('User') } <span data-bind="text: user"></span>
+  ${ _('Progress') } <span data-bind="text: progress"></span>
+  ${ _('Duration') } <span data-bind="text: duration"></span>
+  ${ _('Submitted') } <span data-bind="text: submitted"></span>
 </script>
 
 
@@ -856,6 +871,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
           case 'apps':
           case 'workflows':
           case 'schedules':
+          case 'bundles':
             viewModel.interface(h);
             break;
           default: