[pve-devel] [PATCH 1/3] VZDump: added email notification setting

Tobias Doerffel tobias.doerffel at ed-chemnitz.de
Fri Nov 21 10:27:38 CET 2014


It's now possible to make VZDump only send a mail in case of a failure.

Signed-off-by: Tobias Doerffel <tobias.doerffel at ed-chemnitz.de>
---
 PVE/VZDump.pm                                 |    9 +++++++++
 www/manager/dc/Backup.js                      |    7 +++++++
 www/manager/form/EmailNotificationSelector.js |   15 +++++++++++++++
 3 files changed, 31 insertions(+)
 create mode 100644 www/manager/form/EmailNotificationSelector.js

diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index c39165d..647eece 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -268,6 +268,8 @@ sub sendmail {
 	}
     }
 
+    return if (!$ecount && !$err && $opts->{mailnotification} eq 'failure');
+
     my $stat = ($ecount || $err) ? 'backup failed' : 'backup successful';
     $stat .= ": $err" if $err;
 
@@ -1134,6 +1136,13 @@ my $confdesc = {
 	description => "",
 	optional => 1,
     },
+    mailnotification => {
+        type => 'string',
+        description => "Specify when to send an email",
+        optional => 1,
+        enum => [ 'always', 'failure' ],
+        default => 'always',
+    },
     tmpdir => {
 	type => 'string',
 	description => "Store temporary files to specified directory.",
diff --git a/www/manager/dc/Backup.js b/www/manager/dc/Backup.js
index 7241613..9cc2f7d 100644
--- a/www/manager/dc/Backup.js
+++ b/www/manager/dc/Backup.js
@@ -161,6 +161,13 @@ Ext.define('PVE.dc.BackupEdit', {
 		name: 'mailto'
 	    },
 	    {
+		xtype: 'pveEmailNotificationSelector',
+		fieldLabel: gettext('Email notification'),
+		name: 'mailnotification',
+		deleteEmpty: me.create ? false : true,
+		value: me.create ? 'always' : ''
+	    },
+	    {
 		xtype: 'pveCompressionSelector',
 		fieldLabel: gettext('Compression'),
 		name: 'compress',
diff --git a/www/manager/form/EmailNotificationSelector.js b/www/manager/form/EmailNotificationSelector.js
new file mode 100644
index 0000000..1bdef20
--- /dev/null
+++ b/www/manager/form/EmailNotificationSelector.js
@@ -0,0 +1,15 @@
+Ext.define('PVE.form.EmailNotificationSelector', {
+    extend: 'PVE.form.KVComboBox',
+    alias: ['widget.pveEmailNotificationSelector'],
+
+    initComponent: function() {
+        var me = this;
+
+        me.data = [
+            ['always', gettext('Always')],
+            ['failure', gettext('On failure only')]
+        ];
+
+        me.callParent();
+    }
+});
-- 
1.7.9.5




More information about the pve-devel mailing list