[pve-devel] [PATCH 3/4] Add suspend/resume options to web UI CmdMenus

Daniel Hunsaker danhunsaker at gmail.com
Thu Oct 9 01:02:07 CEST 2014


From: Dan Hunsaker <danhunsaker at gmail.com>

The PVE2 API supports suspend/resume of VMs (and now CTs), but the web UI
doesn't make these options available.  This patch adds Suspend and Resume
items to the CmdMenus of OpenVZ and QEMU guests.  I considered adding the
options to the toolbar, but since it is already pretty full, I opted
against doing so for the moment.  Perhaps the various startup options can
be combined into a dropdown menu similar to how the console options are
set up, and the various shutdown opitons combined into another.  That
would provide the necesarry space to add the Suspend and Resume options
there.

This patch also provides descriptions for Suspend and Resume tasks in the
task logs, bringing full suspend/resume support to the web GUI.

Signed-off-by: Dan Hunsaker <danhunsaker at gmail.com>
---
 www/manager/Utils.js          |  2 ++
 www/manager/openvz/CmdMenu.js | 27 ++++++++++++++++++++++++---
 www/manager/qemu/CmdMenu.js   | 20 ++++++++++++++++++++
 3 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/www/manager/Utils.js b/www/manager/Utils.js
index f95c180..93bd90b 100644
--- a/www/manager/Utils.js
+++ b/www/manager/Utils.js
@@ -510,6 +510,8 @@ Ext.define('PVE.Utils', { statics: {
 	vzmount: ['CT', gettext('Mount') ],
 	vzumount: ['CT', gettext('Unmount') ],
 	vzshutdown: ['CT', gettext('Shutdown') ],
+	vzsuspend: [ 'CT', gettext('Suspend') ],
+	vzresume: [ 'CT', gettext('Resume') ],
 	hamigrate: [ 'HA', gettext('Migrate') ],
 	hastart: [ 'HA', gettext('Start') ],
 	hastop: [ 'HA', gettext('Stop') ],
diff --git a/www/manager/openvz/CmdMenu.js b/www/manager/openvz/CmdMenu.js
index 85589ed..0c6f5bb 100644
--- a/www/manager/openvz/CmdMenu.js
+++ b/www/manager/openvz/CmdMenu.js
@@ -11,7 +11,7 @@ Ext.define('PVE.openvz.CmdMenu', {
 
 	var vmid = me.pveSelNode.data.vmid;
 	if (!vmid) {
-	    throw "no VM ID specified";
+	    throw "no CT ID specified";
 	}
 
 	var vmname = me.pveSelNode.data.name;
@@ -50,10 +50,31 @@ Ext.define('PVE.openvz.CmdMenu', {
 		}
 	    },
 	    {
+		text: gettext('Suspend'),
+		icon: '/pve2/images/forward.png',
+		handler: function() {
+		    var msg = Ext.String.format(gettext("Do you really want to suspend CT {0}?"), vmid);
+		    Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
+			if (btn !== 'yes') {
+			    return;
+			}
+			
+			vm_command('suspend');
+		    });
+		}
+	    },
+	    {
+		text: gettext('Resume'),
+		icon: '/pve2/images/forward.png',
+		handler: function() {
+		    vm_command('resume');
+		}
+	    },
+	    {
 		text: gettext('Shutdown'),
 		icon: '/pve2/images/stop.png',
 		handler: function() {
-		    var msg = Ext.String.format(gettext("Do you really want to shutdown VM {0}?"), vmid);
+		    var msg = Ext.String.format(gettext("Do you really want to shutdown CT {0}?"), vmid);
 		    Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
 			if (btn !== 'yes') {
 			    return;
@@ -67,7 +88,7 @@ Ext.define('PVE.openvz.CmdMenu', {
 		text: gettext('Stop'),
 		icon: '/pve2/images/gtk-stop.png',
 		handler: function() {
-		    var msg = Ext.String.format(gettext("Do you really want to stop VM {0}?"), vmid);
+		    var msg = Ext.String.format(gettext("Do you really want to stop CT {0}?"), vmid);
 		    Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
 			if (btn !== 'yes') {
 			    return;
diff --git a/www/manager/qemu/CmdMenu.js b/www/manager/qemu/CmdMenu.js
index 853f57b..a9a8ce4 100644
--- a/www/manager/qemu/CmdMenu.js
+++ b/www/manager/qemu/CmdMenu.js
@@ -50,6 +50,26 @@ Ext.define('PVE.qemu.CmdMenu', {
 		}
 	    },
 	    {
+		text: gettext('Suspend'),
+		icon: '/pve2/images/forward.png',
+		handler: function() {
+		    var msg = Ext.String.format(gettext("Do you really want to suspend VM {0}?"), vmid);
+		    Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
+			if (btn !== 'yes') {
+			    return;
+			}
+			vm_command('suspend');
+		    });
+		}
+	    },
+	    {
+		text: gettext('Resume'),
+		icon: '/pve2/images/forward.png',
+		handler: function() {
+		    vm_command('resume');
+		}
+	    },
+	    {
 		text: gettext('Shutdown'),
 		icon: '/pve2/images/stop.png',
 		handler: function() {
-- 
1.9.1




More information about the pve-devel mailing list