[Kimchi-devel] [PATCH 3/3] add confirmation for power off a VM

shaohef at linux.vnet.ibm.com shaohef at linux.vnet.ibm.com
Thu Apr 10 09:57:05 UTC 2014


From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>

"power off" action may produce undesirable results, for example
unflushed disk cache in the guest.

We should let user confirm it.

Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
 ui/js/src/kimchi.guest_main.js | 19 ++++++++++++++-----
 ui/pages/i18n.html.tmpl        |  4 ++++
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js
index 58e348b..ba93b1e 100644
--- a/ui/js/src/kimchi.guest_main.js
+++ b/ui/js/src/kimchi.guest_main.js
@@ -43,11 +43,20 @@ kimchi.vmpoweroff = function(event) {
         button.addClass('loading');
         var vm=button.closest('li[name=guest]');
         var vm_id=vm.attr("id");
-        kimchi.poweroffVM(vm_id, function(result) {
-            button.removeClass('loading');
-            kimchi.listVmsAuto();
-        }, function(err) {
-            kimchi.message.error(err.responseJSON.reason);
+        var settings = {
+            title : i18n['KCHVM6002M'],
+            content : i18n['KCHVM6003M'],
+            confirm : i18n['KCHAPI6002M'],
+            cancel : i18n['KCHAPI6003M']
+        };
+        kimchi.confirm(settings, function() {
+            kimchi.poweroffVM(vm_id, function(result) {
+                button.removeClass('loading');
+                kimchi.listVmsAuto();
+            }, function(err) {
+                kimchi.message.error(err.responseJSON.reason);
+            });
+        }, function() {
         });
     } else {
         event.preventDefault();
diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl
index caf5104..6f655e2 100644
--- a/ui/pages/i18n.html.tmpl
+++ b/ui/pages/i18n.html.tmpl
@@ -125,6 +125,10 @@ var i18n = {
     'KCHDR6011M': "$_("Report name should contain only letters, digits and/or hyphen ('-').")",
 
     'KCHVM6001M': "$_("This will delete the virtual machine and its virtual disks. This operation cannot be undone. Would you like to continue?")",
+    'KCHVM6002M': "$_("Power off Confirmation")",
+    'KCHVM6003M': "$_("This action may produce undesirable results, "
+                      "for example unflushed disk cache in the guest. "
+                      "Would you like to continue?")",
 
     'KCHVMCD6001M': "$_("This CDROM will be detached permanently and you can re-attach it. Continue to detach it?")",
     'KCHVMCD6002M': "$_("Attach")",
-- 
1.8.5.3




More information about the Kimchi-devel mailing list