浏览代码

HUE-5109 [oozie] Allow sending of email report when submitting a workflow

Romain Rigaux 9 年之前
父节点
当前提交
086b276faa
共有 2 个文件被更改,包括 27 次插入4 次删除
  1. 17 3
      apps/oozie/src/oozie/models2.py
  2. 10 1
      apps/oozie/src/oozie/templates/editor2/gen/workflow-end.xml.mako

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

@@ -44,7 +44,6 @@ from hadoop.fs.exceptions import WebHdfsException
 from liboozie.oozie_api import get_oozie
 from liboozie.submission2 import Submission
 from liboozie.submission2 import create_directories
-from notebook.connectors.oozie_batch import OozieApi
 from notebook.models import Notebook
 
 from oozie.conf import REMOTE_SAMPLE_DIR
@@ -931,7 +930,11 @@ def _upgrade_older_node(node):
   if node['type'] in ('end', 'end-widget') and 'to' not in node['properties']:
     node['properties']['enableMail'] = False
     node['properties']['to'] = ''
+    node['properties']['cc'] = ''
     node['properties']['subject'] = ''
+    node['properties']['body'] = ''
+    node['properties']['content_type'] = 'text/plain'
+    node['properties']['attachment'] = ''
 
   if node['type'] == 'email-widget' and 'bcc' not in node['properties']:
     node['properties']['bcc'] = ''
@@ -3118,6 +3121,8 @@ class Coordinator(Job):
 
   @property
   def name(self):
+    from notebook.connectors.oozie_batch import OozieApi # Import dependency
+
     if self.data['properties']['document']:
       return _("%s for %s") % (OozieApi.SCHEDULE_JOB_PREFIX, self.data['name'] or self.data['type'])
     else:
@@ -3948,7 +3953,15 @@ class WorkflowBuilder():
           u'actionParameters': [],
         }, {
           u'name': u'End',
-          u'properties': {},
+          u'properties': {
+              u'body': u'',
+              u'cc': u'',
+              u'to': u'',
+              u'enableMail': False,
+              u'message': u'Workflow ${wf:id()} finished',
+              u'subject': u'',
+              u'attachment': u''
+          },
           u'actionParametersFetched': False,
           u'id': u'33430f0f-ebfa-c3ec-f237-3e77efa03d0a',
           u'type': u'end-widget',
@@ -3963,7 +3976,8 @@ class WorkflowBuilder():
               u'enableMail': False,
               u'message': u'Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]',
               u'subject': u'',
-              },
+              u'attachment': u''
+          },
           u'actionParametersFetched': False,
           u'id': u'17c9c895-5a16-7443-bb81-f34b30b21548',
           u'type': u'kill-widget',

+ 10 - 1
apps/oozie/src/oozie/templates/editor2/gen/workflow-end.xml.mako

@@ -19,8 +19,17 @@
     <action name="${ node['name'] }">
         <email xmlns="uri:oozie:email-action:0.2">
             <to>${ node['properties']['to'] }</to>
+            % if node['properties']['cc']:
+            <cc>${ node['properties']['cc'] }</cc>
+            % endif
             <subject>${ node['properties']['subject'] }</subject>
-            <body></body>
+            <body>${ node['properties']['body'] }</body>
+            % if node['properties']['content_type']:
+            <content_type>${ node['properties']['content_type'] }</content_type>
+            % endif
+            % if node['properties']['attachment']:
+            <attachment>${ node['properties']['attachment'] }</attachment>
+            % endif
         </email>
         <ok to="${ node['name'] }-kill"/>
         <error to="${ node['name'] }-kill"/>