Browse Source

HUE-833 [oozie] Add Email action

Add example
Romain Rigaux 13 năm trước cách đây
mục cha
commit
c0f6257d2a

+ 0 - 0
apps/oozie/examples/email/empty


+ 134 - 0
apps/oozie/src/oozie/fixtures/initial_oozie_examples.json

@@ -153,6 +153,20 @@
       "description": "Example of Fs actions"
     }
   },
+  {
+    "pk": 18,
+    "model": "oozie.job",
+    "fields": {
+      "is_shared": true,
+      "name": "Email",
+      "parameters": "[{\"name\": \"oozie.use.system.libpath\", \"value\": \"true\"}]",
+      "deployment_dir": "/user/hue/oozie/workspaces/email",
+      "schema_version": "uri:oozie:workflow:0.4",
+      "last_modified": "2012-12-01 00:00:00",
+      "owner": 1100713,
+      "description": "Example of Email action"
+    }
+  },
   {
     "pk": 5,
     "model": "oozie.workflow",
@@ -263,6 +277,17 @@
       "job_properties": "[]"
     }
   },
+  {
+    "pk": 18,
+    "model": "oozie.workflow",
+    "fields": {
+      "job_xml": "",
+      "start": 79,
+      "is_single": false,
+      "end": 78,
+      "job_properties": "[]"
+    }
+  },
   {
     "pk": 23,
     "model": "oozie.link",
@@ -833,6 +858,46 @@
       "child": 74
     }
   },
+  {
+    "pk": 99,
+    "model": "oozie.link",
+    "fields": {
+      "comment": "",
+      "name": "to",
+      "parent": 79,
+      "child": 80
+    }
+  },
+  {
+    "pk": 100,
+    "model": "oozie.link",
+    "fields": {
+      "comment": "",
+      "name": "related",
+      "parent": 79,
+      "child": 78
+    }
+  },
+  {
+    "pk": 101,
+    "model": "oozie.link",
+    "fields": {
+      "comment": "",
+      "name": "ok",
+      "parent": 80,
+      "child": 78
+    }
+  },
+  {
+    "pk": 102,
+    "model": "oozie.link",
+    "fields": {
+      "comment": "",
+      "name": "error",
+      "parent": 80,
+      "child": 77
+    }
+  },
   {
     "pk": 16,
     "model": "oozie.node",
@@ -1323,6 +1388,46 @@
       "description": ""
     }
   },
+  {
+    "pk": 77,
+    "model": "oozie.node",
+    "fields": {
+      "node_type": "kill",
+      "workflow": 18,
+      "name": "kill",
+      "description": ""
+    }
+  },
+  {
+    "pk": 78,
+    "model": "oozie.node",
+    "fields": {
+      "node_type": "end",
+      "workflow": 18,
+      "name": "end",
+      "description": ""
+    }
+  },
+  {
+    "pk": 79,
+    "model": "oozie.node",
+    "fields": {
+      "node_type": "start",
+      "workflow": 18,
+      "name": "start",
+      "description": ""
+    }
+  },
+  {
+    "pk": 80,
+    "model": "oozie.node",
+    "fields": {
+      "node_type": "email",
+      "workflow": 18,
+      "name": "Email",
+      "description": "Send an email"
+    }
+  },
   {
     "pk": 19,
     "model": "oozie.mapreduce",
@@ -1516,6 +1621,16 @@
       "deletes": "[{\"name\": \"${output}/testfs\"}]"
     }
   },
+  {
+    "pk": 80,
+    "model": "oozie.email",
+    "fields": {
+      "cc": "",
+      "to": "example@example.org",
+      "body": "Hue",
+      "subject": "I love"
+    }
+  },
   {
     "pk": 18,
     "model": "oozie.start",
@@ -1586,6 +1701,13 @@
       "node_ptr": 75
     }
   },
+  {
+    "pk": 79,
+    "model": "oozie.start",
+    "fields": {
+      "node_ptr": 79
+    }
+  },
   {
     "pk": 17,
     "model": "oozie.end",
@@ -1636,6 +1758,11 @@
     "model": "oozie.end",
     "fields": {}
   },
+  {
+    "pk": 78,
+    "model": "oozie.end",
+    "fields": {}
+  },
   {
     "pk": 16,
     "model": "oozie.kill",
@@ -1706,6 +1833,13 @@
       "message": "Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]"
     }
   },
+  {
+    "pk": 77,
+    "model": "oozie.kill",
+    "fields": {
+      "message": "Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]"
+    }
+  },
   {
     "pk": 34,
     "model": "oozie.fork",

+ 15 - 1
apps/oozie/src/oozie/forms.py

@@ -23,7 +23,8 @@ from django.utils.translation import ugettext_lazy as _t
 
 from desktop.lib.django_forms import MultiForm, SplitDateTimeWidget
 from oozie.models import Workflow, Node, Java, Mapreduce, Streaming, Coordinator,\
-  Dataset, DataInput, DataOutput, Pig, Link, Hive, Sqoop, Ssh, Shell, DistCp, Fs
+  Dataset, DataInput, DataOutput, Pig, Link, Hive, Sqoop, Ssh, Shell, DistCp, Fs,\
+  Email
 
 LOG = logging.getLogger(__name__)
 
@@ -237,6 +238,18 @@ class FsForm(forms.ModelForm):
     }
 
 
+class EmailForm(forms.ModelForm):
+  class Meta:
+    model = Email
+    exclude = NodeForm.Meta.ALWAYS_HIDE
+    widgets = {
+      'to': forms.TextInput(attrs={'class': 'span8'}),
+      'cc': forms.TextInput(attrs={'class': 'span8'}),
+      'subject': forms.TextInput(attrs={'class': 'span8'}),
+      'body': forms.Textarea(attrs={'class': 'span8'}),
+    }
+
+
 class LinkForm(forms.ModelForm):
   comment = forms.CharField(label='if', max_length=1024, required=True, widget=forms.TextInput(attrs={'class': 'span8'}))
 
@@ -357,6 +370,7 @@ _node_type_TO_FORM_CLS = {
   Shell.node_type: ShellForm,
   DistCp.node_type: DistCpForm,
   Fs.node_type: FsForm,
+  Email.node_type: EmailForm,
 }
 
 

+ 291 - 0
apps/oozie/src/oozie/migrations/0011_auto__add_email.py

@@ -0,0 +1,291 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+
+        # Adding model 'Email'
+        db.create_table('oozie_email', (
+            ('cc', self.gf('django.db.models.fields.TextField')(default='', blank=True)),
+            ('to', self.gf('django.db.models.fields.TextField')(default='')),
+            ('subject', self.gf('django.db.models.fields.TextField')(default='[]', blank=True)),
+            ('body', self.gf('django.db.models.fields.TextField')(default='[]', blank=True)),
+            ('node_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['oozie.Node'], unique=True, primary_key=True)),
+        ))
+        db.send_create_signal('oozie', ['Email'])
+
+
+    def backwards(self, orm):
+
+        # Deleting model 'Email'
+        db.delete_table('oozie_email')
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True', 'blank': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'oozie.coordinator': {
+            'Meta': {'object_name': 'Coordinator', '_ormbases': ['oozie.Job']},
+            'concurrency': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'end': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 15, 23, 33, 6, 168007)'}),
+            'execution': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}),
+            'frequency_number': ('django.db.models.fields.SmallIntegerField', [], {'default': '1'}),
+            'frequency_unit': ('django.db.models.fields.CharField', [], {'default': "'days'", 'max_length': '20'}),
+            'job_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Job']", 'unique': 'True', 'primary_key': 'True'}),
+            'start': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 12, 23, 33, 6, 167976)'}),
+            'throttle': ('django.db.models.fields.PositiveSmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'timeout': ('django.db.models.fields.SmallIntegerField', [], {'null': 'True', 'blank': 'True'}),
+            'timezone': ('django.db.models.fields.CharField', [], {'default': "'America/Los_Angeles'", 'max_length': '24'}),
+            'workflow': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['oozie.Workflow']", 'null': 'True'})
+        },
+        'oozie.datainput': {
+            'Meta': {'object_name': 'DataInput'},
+            'coordinator': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['oozie.Coordinator']"}),
+            'dataset': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Dataset']", 'unique': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '40'})
+        },
+        'oozie.dataoutput': {
+            'Meta': {'object_name': 'DataOutput'},
+            'coordinator': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['oozie.Coordinator']"}),
+            'dataset': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Dataset']", 'unique': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '40'})
+        },
+        'oozie.dataset': {
+            'Meta': {'object_name': 'Dataset'},
+            'coordinator': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['oozie.Coordinator']"}),
+            'description': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '1024', 'blank': 'True'}),
+            'done_flag': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '64', 'blank': 'True'}),
+            'frequency_number': ('django.db.models.fields.SmallIntegerField', [], {'default': '1'}),
+            'frequency_unit': ('django.db.models.fields.CharField', [], {'default': "'days'", 'max_length': '20'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+            'start': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime(2012, 12, 12, 23, 33, 6, 168594)'}),
+            'timezone': ('django.db.models.fields.CharField', [], {'default': "'America/Los_Angeles'", 'max_length': '24'}),
+            'uri': ('django.db.models.fields.CharField', [], {'default': "'/data/${YEAR}${MONTH}${DAY}'", 'max_length': '1024'})
+        },
+        'oozie.decision': {
+            'Meta': {'object_name': 'Decision'},
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'})
+        },
+        'oozie.distcp': {
+            'Meta': {'object_name': 'DistCp'},
+            'job_properties': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'job_xml': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '512', 'blank': 'True'}),
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'}),
+            'params': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'prepares': ('django.db.models.fields.TextField', [], {'default': "'[]'"})
+        },
+        'oozie.email': {
+            'Meta': {'object_name': 'Email'},
+            'body': ('django.db.models.fields.TextField', [], {'default': "'[]'", 'blank': 'True'}),
+            'cc': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'}),
+            'subject': ('django.db.models.fields.TextField', [], {'default': "'[]'", 'blank': 'True'}),
+            'to': ('django.db.models.fields.TextField', [], {'default': "''"})
+        },
+        'oozie.end': {
+            'Meta': {'object_name': 'End'},
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'})
+        },
+        'oozie.fork': {
+            'Meta': {'object_name': 'Fork'},
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'})
+        },
+        'oozie.fs': {
+            'Meta': {'object_name': 'Fs'},
+            'chmods': ('django.db.models.fields.TextField', [], {'default': "'[]'", 'blank': 'True'}),
+            'deletes': ('django.db.models.fields.TextField', [], {'default': "'[]'", 'blank': 'True'}),
+            'mkdirs': ('django.db.models.fields.TextField', [], {'default': "'[]'", 'blank': 'True'}),
+            'moves': ('django.db.models.fields.TextField', [], {'default': "'[]'", 'blank': 'True'}),
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'}),
+            'touchzs': ('django.db.models.fields.TextField', [], {'default': "'[]'", 'blank': 'True'})
+        },
+        'oozie.history': {
+            'Meta': {'object_name': 'History'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'job': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['oozie.Job']"}),
+            'oozie_job_id': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'properties': ('django.db.models.fields.TextField', [], {}),
+            'submission_date': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}),
+            'submitter': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
+        },
+        'oozie.hive': {
+            'Meta': {'object_name': 'Hive'},
+            'archives': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'files': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'job_properties': ('django.db.models.fields.TextField', [], {'default': '\'[{"name":"oozie.hive.defaults","value":"hive-site.xml"}]\''}),
+            'job_xml': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '512', 'blank': 'True'}),
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'}),
+            'params': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'prepares': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'script_path': ('django.db.models.fields.CharField', [], {'max_length': '256'})
+        },
+        'oozie.java': {
+            'Meta': {'object_name': 'Java'},
+            'archives': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'args': ('django.db.models.fields.CharField', [], {'max_length': '4096', 'blank': 'True'}),
+            'files': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'jar_path': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
+            'java_opts': ('django.db.models.fields.CharField', [], {'max_length': '256', 'blank': 'True'}),
+            'job_properties': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'job_xml': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '512', 'blank': 'True'}),
+            'main_class': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'}),
+            'prepares': ('django.db.models.fields.TextField', [], {'default': "'[]'"})
+        },
+        'oozie.job': {
+            'Meta': {'object_name': 'Job'},
+            'deployment_dir': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'blank': 'True'}),
+            'description': ('django.db.models.fields.CharField', [], {'max_length': '1024', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_shared': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True', 'blank': 'True'}),
+            'last_modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+            'owner': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"}),
+            'parameters': ('django.db.models.fields.TextField', [], {'default': '\'[{"name":"oozie.use.system.libpath","value":"true"}]\''}),
+            'schema_version': ('django.db.models.fields.CharField', [], {'max_length': '128'})
+        },
+        'oozie.join': {
+            'Meta': {'object_name': 'Join'},
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'})
+        },
+        'oozie.kill': {
+            'Meta': {'object_name': 'Kill'},
+            'message': ('django.db.models.fields.CharField', [], {'default': "'Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]'", 'max_length': '256'}),
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'})
+        },
+        'oozie.link': {
+            'Meta': {'object_name': 'Link'},
+            'child': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'parent_node'", 'to': "orm['oozie.Node']"}),
+            'comment': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '1024', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+            'parent': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'child_node'", 'to': "orm['oozie.Node']"})
+        },
+        'oozie.mapreduce': {
+            'Meta': {'object_name': 'Mapreduce'},
+            'archives': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'files': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'jar_path': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
+            'job_properties': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'job_xml': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '512', 'blank': 'True'}),
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True'}),
+            'prepares': ('django.db.models.fields.TextField', [], {'default': "'[]'"})
+        },
+        'oozie.node': {
+            'Meta': {'object_name': 'Node'},
+            'children': ('django.db.models.fields.related.ManyToManyField', [], {'related_name': "'parents'", 'symmetrical': 'False', 'through': "orm['oozie.Link']", 'to': "orm['oozie.Node']"}),
+            'description': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '1024', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '40'}),
+            'node_type': ('django.db.models.fields.CharField', [], {'max_length': '64'}),
+            'workflow': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['oozie.Workflow']"})
+        },
+        'oozie.pig': {
+            'Meta': {'object_name': 'Pig'},
+            'archives': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'files': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'job_properties': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'job_xml': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '512', 'blank': 'True'}),
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'}),
+            'params': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'prepares': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'script_path': ('django.db.models.fields.CharField', [], {'max_length': '256'})
+        },
+        'oozie.shell': {
+            'Meta': {'object_name': 'Shell'},
+            'archives': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'capture_output': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'command': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'files': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'job_properties': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'job_xml': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '512', 'blank': 'True'}),
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'}),
+            'params': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'prepares': ('django.db.models.fields.TextField', [], {'default': "'[]'"})
+        },
+        'oozie.sqoop': {
+            'Meta': {'object_name': 'Sqoop'},
+            'archives': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'files': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'job_properties': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'job_xml': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '512', 'blank': 'True'}),
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'}),
+            'params': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'prepares': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'script_path': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'})
+        },
+        'oozie.ssh': {
+            'Meta': {'object_name': 'Ssh'},
+            'capture_output': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'command': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'host': ('django.db.models.fields.CharField', [], {'max_length': '256'}),
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'}),
+            'params': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'user': ('django.db.models.fields.CharField', [], {'max_length': '64'})
+        },
+        'oozie.start': {
+            'Meta': {'object_name': 'Start'},
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True'})
+        },
+        'oozie.streaming': {
+            'Meta': {'object_name': 'Streaming'},
+            'archives': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'files': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'job_properties': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'mapper': ('django.db.models.fields.CharField', [], {'max_length': '512'}),
+            'node_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Node']", 'unique': 'True', 'primary_key': 'True'}),
+            'reducer': ('django.db.models.fields.CharField', [], {'max_length': '512'})
+        },
+        'oozie.workflow': {
+            'Meta': {'object_name': 'Workflow', '_ormbases': ['oozie.Job']},
+            'end': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'end_workflow'", 'null': 'True', 'to': "orm['oozie.End']"}),
+            'is_single': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}),
+            'job_properties': ('django.db.models.fields.TextField', [], {'default': "'[]'"}),
+            'job_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['oozie.Job']", 'unique': 'True', 'primary_key': 'True'}),
+            'job_xml': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '512', 'blank': 'True'}),
+            'start': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'start_workflow'", 'null': 'True', 'to': "orm['oozie.Start']"})
+        }
+    }
+
+    complete_apps = ['oozie']

+ 18 - 1
apps/oozie/src/oozie/models.py

@@ -465,6 +465,8 @@ class Node(models.Model):
       node = self.distcp
     elif self.node_type == Fs.node_type:
       node = self.fs
+    elif self.node_type == Email.node_type:
+      node = self.email
     elif self.node_type == Streaming.node_type:
       node = self.streaming
     elif self.node_type == Java.node_type:
@@ -920,8 +922,22 @@ class Fs(Action):
     return json.loads(self.touchzs)
 
 
+class Email(Action):
+  PARAM_FIELDS = ('to', 'cc', 'subject', 'body')
+  node_type = 'email'
+
+  to = models.TextField(default='', verbose_name=_t('to addresses'),
+                            help_text=_t('Comma-separated values.'))
+  cc = models.TextField(default='', verbose_name=_t('cc addresses (optional)'), blank=True,
+                            help_text=_t('Comma-separated values.'))
+  subject = models.TextField(default="[]", verbose_name=_t('Subject'), blank=True,
+                            help_text=_t('Plain-text.'))
+  body = models.TextField(default="[]", verbose_name=_t('Body'), blank=True,
+                            help_text=_t('Plain-text.'))
+
+
 Action.types = (Mapreduce.node_type, Streaming.node_type, Java.node_type, Pig.node_type, Hive.node_type, Sqoop.node_type, Ssh.node_type, Shell.node_type,
-                DistCp.node_type, Fs.node_type)
+                DistCp.node_type, Fs.node_type, Email.node_type)
 
 
 class ControlFlow(Node):
@@ -1389,6 +1405,7 @@ ACTION_TYPES = {
   Shell.node_type: Shell,
   DistCp.node_type: DistCp,
   Fs.node_type: Fs,
+  Email.node_type: Email,
 }
 
 NODE_TYPES = ACTION_TYPES.copy()

+ 2 - 2
apps/oozie/src/oozie/templates/dashboard/list_oozie_coordinator.mako

@@ -98,7 +98,7 @@ ${ layout.menubar(section='dashboard') }
               % if oozie_coordinator.is_running():
                 <a title="${_('Kill %(coordinator)s') % dict(coordinator=oozie_coordinator.id)}"
                   id="kill-coordinator"
-                  class="btn btn-danger small confirmationModal"
+                  class="btn small confirmationModal"
                   alt="${ _('Are you sure you want to kill coordinator %s?') % oozie_coordinator.id }"
                   href="javascript:void(0)"
                   data-url="${ url('oozie:manage_oozie_jobs', job_id=oozie_coordinator.id, action='kill') }"
@@ -231,7 +231,7 @@ ${ layout.menubar(section='dashboard') }
   </div>
   <div class="modal-footer">
     <a href="#" class="btn" data-dismiss="modal">${_('No')}</a>
-    <a class="btn btn-primary" href="javascript:void(0);">${_('Yes')}</a>
+    <a class="btn btn-danger" href="javascript:void(0);">${_('Yes')}</a>
   </div>
 </div>
 

+ 2 - 2
apps/oozie/src/oozie/templates/dashboard/list_oozie_coordinators.mako

@@ -82,7 +82,7 @@ ${layout.menubar(section='dashboard')}
             <td>
               % if has_job_edition_permission(job, user):
                 <a title="${_('Kill %(coordinator)s') % dict(coordinator=job.id)}"
-                  class="btn btn-danger small confirmationModal"
+                  class="btn small confirmationModal"
                   alt="${ _('Are you sure you want to kill coordinator %s?') % job.id }"
                   href="javascript:void(0)"
                   data-message="${ _('The coordinator was killed!') }"
@@ -147,7 +147,7 @@ ${layout.menubar(section='dashboard')}
   </div>
   <div class="modal-footer">
     <a href="#" class="btn" data-dismiss="modal">${_('No')}</a>
-    <a class="btn btn-primary" href="javascript:void(0);">${_('Yes')}</a>
+    <a class="btn btn-danger" href="javascript:void(0);">${_('Yes')}</a>
   </div>
 </div>
 

+ 2 - 2
apps/oozie/src/oozie/templates/dashboard/list_oozie_workflow.mako

@@ -119,7 +119,7 @@ ${ layout.menubar(section='dashboard') }
       % if oozie_workflow.is_running():
         <a title="${_('Kill %(workflow)s') % dict(workflow=oozie_workflow.id)}"
           id="kill-workflow"
-          class="btn btn-danger small confirmationModal"
+          class="btn small confirmationModal"
           alt="${ _('Are you sure you want to kill workflow %s?') %  oozie_workflow.id }"
           href="javascript:void(0)"
           data-url="${ url('oozie:manage_oozie_jobs', job_id=oozie_workflow.id, action='kill') }"
@@ -290,7 +290,7 @@ ${ layout.menubar(section='dashboard') }
   </div>
   <div class="modal-footer">
     <a href="#" class="btn" data-dismiss="modal">${_('No')}</a>
-    <a class="btn btn-primary" href="javascript:void(0);">${_('Yes')}</a>
+    <a class="btn btn-danger" href="javascript:void(0);">${_('Yes')}</a>
   </div>
 </div>
 

+ 2 - 2
apps/oozie/src/oozie/templates/dashboard/list_oozie_workflows.mako

@@ -84,7 +84,7 @@ ${ layout.menubar(section='dashboard') }
             <td>
               % if has_job_edition_permission(job, user):
               <a title="${_('Kill %(workflow)s') % dict(workflow=job.id)}"
-                class="btn btn-danger small confirmationModal"
+                class="btn small confirmationModal"
                 alt="${ _('Are you sure you want to kill workflow %s?') %  job.id }"
                 href="javascript:void(0)"
                 data-url="${ url('oozie:manage_oozie_jobs', job_id=job.id, action='kill') }"
@@ -149,7 +149,7 @@ ${ layout.menubar(section='dashboard') }
   </div>
   <div class="modal-footer">
     <a href="#" class="btn" data-dismiss="modal">${_('No')}</a>
-    <a class="btn btn-primary" href="javascript:void(0);">${_('Yes')}</a>
+    <a class="btn btn-danger" href="javascript:void(0);">${_('Yes')}</a>
   </div>
 </div>
 

+ 5 - 0
apps/oozie/src/oozie/templates/editor/action_utils.mako

@@ -57,6 +57,11 @@
                 ${ _('The ssh server requires passwordless login') }.
               </p>
             % endif
+            % if node_type == 'email':
+              <p class="alert alert-warn span5">
+                ${ _('Requires some SMTP server configuration to be present (in oozie-site.xml)') }.
+              </p>
+            % endif
             </div>
           </div>
 

+ 6 - 0
apps/oozie/src/oozie/templates/editor/edit_workflow.mako

@@ -135,6 +135,12 @@ ${ layout.menubar(section='workflows') }
                   <i class="icon-plus"></i> ${ _('Fs') }
                 </a>
                 <p/>
+                <p>
+                <a data-node-type="email"
+                  title="${ _('Click to add to the end of the workflow') }" class="btn new-node-link">
+                  <i class="icon-plus"></i> ${ _('Email') }
+                </a>
+                <p/>
               </div>
             </div>
              % endif

+ 30 - 0
apps/oozie/src/oozie/templates/editor/gen/workflow-email.xml.mako

@@ -0,0 +1,30 @@
+## 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.
+
+<%namespace name="common" file="workflow-common.xml.mako" />
+
+    <action name="${ node }">
+        <email xmlns="uri:oozie:email-action:0.1">
+            <to>${ node.to }</to>
+            % if node.cc:
+              <cc>${ node.cc }</cc>
+            % endif
+            <subject>${ node.subject }</subject>
+            <body>${ node.body }</body>
+        </email>
+        <ok to="${ node.get_child('ok') }"/>
+        <error to="${ node.get_child('error') }"/>
+    </action>

+ 44 - 0
apps/oozie/src/oozie/tests.py

@@ -688,6 +688,50 @@ class TestEditor(OozieMockBase):
     </action>""" in xml, xml)
 
 
+  def test_workflow_email_gen_xml(self):
+    self.wf.node_set.filter(name='action-name-1').delete()
+
+    action1 = add_node(self.wf, 'action-name-1', 'email', [self.wf.start], {
+        u'name': 'MyEmail',
+        u'description': 'Execute an Email action',
+        u'to': 'hue@hue.org,django@python.org',
+        u'cc': '',
+        u'subject': 'My subject',
+        u'body': 'My body'
+    })
+    Link(parent=action1, child=self.wf.end, name="ok").save()
+
+    xml = self.wf.to_xml()
+
+    assert_true("""
+    <action name="MyEmail">
+        <email xmlns="uri:oozie:email-action:0.1">
+            <to>hue@hue.org,django@python.org</to>
+            <subject>My subject</subject>
+            <body>My body</body>
+        </email>
+        <ok to="end"/>
+        <error to="kill"/>
+    </action>""" in xml, xml)
+
+    action1.cc = 'lambda@python.org'
+    action1.save()
+
+    xml = self.wf.to_xml()
+
+    assert_true("""
+    <action name="MyEmail">
+        <email xmlns="uri:oozie:email-action:0.1">
+            <to>hue@hue.org,django@python.org</to>
+              <cc>lambda@python.org</cc>
+            <subject>My subject</subject>
+            <body>My body</body>
+        </email>
+        <ok to="end"/>
+        <error to="kill"/>
+    </action>""" in xml, xml)
+
+
   def test_workflow_flatten_list(self):
     assert_equal('[<Start: start>, <Mapreduce: action-name-1>, <Mapreduce: action-name-2>, <Mapreduce: action-name-3>, '
                  '<Kill: kill>, <End: end>]',

+ 1 - 1
apps/oozie/static/help/index.html

@@ -335,6 +335,6 @@ vertical-align: center;
                         </td>
         </tr>
       </table>
-  
+
     </body>
 </html>

+ 17 - 0
apps/oozie/static/js/workflow.js

@@ -419,6 +419,20 @@ $.extend(FsModel.prototype, {
   child_links: []
 });
 
+var EmailModel = ModelModule($);
+$.extend(EmailModel.prototype, {
+  id: 0,
+  name: '',
+  description: '',
+  node_type: 'email',
+  workflow: 0,
+  to: '',
+  cc: '',
+  subject: '',
+  body: '',
+  child_links: []
+});
+
 function nodeModelChooser(node_type) {
   switch(node_type) {
     case 'mapreduce':
@@ -441,6 +455,8 @@ function nodeModelChooser(node_type) {
       return DistCPModel;
     case 'fs':
         return FsModel;
+    case 'email':
+        return EmailModel;
     case 'fork':
       return ForkModel;
     case 'decision':
@@ -461,6 +477,7 @@ var IdGeneratorTable = {
   ssh: new IdGenerator({prefix: 'ssh'}),
   distcp: new IdGenerator({prefix: 'distcp'}),
   fs: new IdGenerator({prefix: 'fs'}),
+  email: new IdGenerator({prefix: 'email'}),
   fork: new IdGenerator({prefix: 'fork'}),
   decision: new IdGenerator({prefix: 'decision'}),
   join: new IdGenerator({prefix: 'join'}),