瀏覽代碼

HUE-2997 [oozie] Easier usage of email action when workflow fails

Romain Rigaux 10 年之前
父節點
當前提交
6c32b5aebe

+ 10 - 3
apps/oozie/src/oozie/models2.py

@@ -176,7 +176,7 @@ class Workflow(Job):
           node['properties']['retry_interval'] = []
 
       # Backward compatibility
-      _upgrade_sqoop_node(node)
+      _upgrade_older_node(node)
 
     return _data
 
@@ -407,7 +407,7 @@ class Node():
       self.data['properties']['retry_interval'] = []
 
     # Backward compatibility
-    _upgrade_sqoop_node(self.data)
+    _upgrade_older_node(self.data)
 
   def get_template_name(self):
     return 'editor2/gen/workflow-%s.xml.mako' % self.data['type']
@@ -416,10 +416,17 @@ class Node():
     return find_parameters(self) + (find_parameters(self, ['sla']) if self.sla_enabled else [])
 
 
-def _upgrade_sqoop_node(node):
+def _upgrade_older_node(node):
   if node['type'] in ('sqoop', 'sqoop-widget') and 'arguments' not in node['properties']:
     node['properties']['arguments'] = node['properties']['parameters']
 
+  if node['type'] in ('kill', 'kill-widget') and 'to' not in node['properties']:
+    node['properties']['enableMail'] = False
+    node['properties']['to'] = ''
+    node['properties']['cc'] = ''
+    node['properties']['subject'] = ''
+    node['properties']['body'] = ''
+
 
 class Action(object):
 

+ 31 - 7
apps/oozie/src/oozie/templates/editor2/common_workflow.mako

@@ -328,6 +328,30 @@
       <div data-bind="visible: $parent.ooziePropertiesExpanded">
         <h6 class="field-title">${ _('Message') }</h6>
         <textarea class="span12" data-bind="value: properties.message" />
+
+        <h6 class="field-title">${ _('Email on error') }</h6>
+        <input type="checkbox" data-bind="checked: properties.enableMail" />
+        <span data-bind="visible: properties.enableMail">
+          <div class="airy">
+            <span class="widget-label" data-bind="text: $root.workflow_properties.to.label"></span>
+            <input type="text" class="seventy" data-bind="value: properties.to, attr: { placeholder: $root.workflow_properties.to.help_text }" validate="nonempty"/>
+          </div>
+
+          <div class="airy">
+            <span class="widget-label" data-bind="text: $root.workflow_properties.cc.label"></span>
+            <input type="text" class="seventy" data-bind="value: properties.cc, attr: { placeholder: $root.workflow_properties.cc.help_text }" />
+          </div>
+
+          <div class="airy">
+            <span class="widget-label" data-bind="text: $root.workflow_properties.subject.label"></span>
+            <input type="text" class="seventy" data-bind="value: properties.subject, attr: { placeholder: $root.workflow_properties.subject.help_text }" />
+          </div>
+
+          <div class="airy">
+            <span class="widget-label" data-bind="text: $root.workflow_properties.body.label"></span>
+            <textarea class="seventy" style="resize:both" data-bind="value: properties.body, attr: { placeholder: $root.workflow_properties.body.help_text }"></textarea>
+          </div>
+        </span>
       </div>
     </div>
   </div>
@@ -556,12 +580,12 @@
 
 
 <script type="text/html" id="common-fs-link">
-<!-- ko if: $data.path.length > 0 -->
-  <!-- ko if: with_label -->
-    <a data-bind="attr: {href: '/filebrowser/view=' + ($data.path[0] != '/' ? $root.workflow.properties.deployment_dir() + '/' : '') + $data.path , title: '${ _ko('Open') } '+ $data.path }" target="_blank">
+ <!-- ko if: $data.path.length > 0 -->
+   <!-- ko if: with_label -->
+     <a data-bind="attr: {href: '/filebrowser/view=' + ($data.path[0] != '/' ? $root.workflow.properties.deployment_dir() + '/' : '') + $data.path , title: '${ _ko('Open') } '+ $data.path }" target="_blank">
       <span data-bind="text: $data.path.lastIndexOf('/') == $data.path.length - 1 ? $data.path : $data.path.split('/').pop()"></span>
-    </a>
-  <!-- /ko -->
+     </a>
+   <!-- /ko -->
 
    <!-- ko if: ! with_label -->
      <a data-bind="attr: {href: '/filebrowser/view=' + ($data.path[0] != '/' ? $root.workflow.properties.deployment_dir() + '/' : '') + $data.path }" target="_blank" title="${ _('Open') }">
@@ -580,6 +604,7 @@
   <!-- /ko -->
 </script>
 
+
 <script type="text/html" id="logs-icon">
   <!-- ko if: $parent.logsURL() != '' && $parent.logsURL() != null -->
     <a class="pull-right pointer logs-icon" data-bind="click: function(){ location.href = $parent.logsURL(); }" title="${ _('View logs') }"><i class="fa fa-tasks"></i></a>
@@ -666,7 +691,6 @@
       </div>
     </div>
 
-
     <div data-bind="visible: $parent.ooziePropertiesExpanded">
       <ul class="nav nav-tabs">
         <li class="active"><a data-bind="attr: { href: '#properties-' + id()}" data-toggle="tab">${ _('Properties') }</a></li>
@@ -1551,7 +1575,7 @@
 
         <div class="airy">
           <span class="widget-label" data-bind="text: $root.workflow_properties.body.label"></span>
-          <textarea class="seventy" data-bind="value: properties.body, attr: { placeholder: $root.workflow_properties.body.help_text }"></textarea>
+          <textarea class="seventy" style="resize:both" data-bind="value: properties.body, attr: { placeholder: $root.workflow_properties.body.help_text }"></textarea>
         </div>
       </div>
     </div>

+ 19 - 0
apps/oozie/src/oozie/templates/editor2/gen/workflow-kill.xml.mako

@@ -15,6 +15,25 @@
 ## See the License for the specific language governing permissions and
 ## limitations under the License.
 
+%if node['properties']['enableMail']:
+    <action name="${ node['name'] }">
+        <email xmlns="uri:oozie:email-action:0.1">
+            <to>${ node['properties']['to'] }</to>
+            % if node['properties']['cc']:
+            <cc>${ node['properties']['cc'] }</cc>
+            % endif
+            <subject>${ node['properties']['subject'] }</subject>
+            <body>${ node['properties']['body'] }</body>
+        </email>
+        <ok to="${ node['name'] }-kill"/>
+        <error to="${ node['name'] }-kill"/>
+    </action>
+
+    <kill name="${ node['name'] }-kill">
+        <message>${ node['properties']['message'] }</message>
+    </kill>
+%else:
     <kill name="${ node['name'] }">
         <message>${ node['properties']['message'] }</message>
     </kill>
+%endif

文件差異過大導致無法顯示
+ 1 - 0
apps/oozie/src/oozie/tests2.py


部分文件因文件數量過多而無法顯示