From e43f02cc51e8ddfe4b32d68b71ecce1563aedb36 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Mon, 19 Sep 2011 12:31:51 +0200 Subject: [PATCH] try to reconnect VNCConsole after migration --- www/manager/VNCConsole.js | 56 ++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/www/manager/VNCConsole.js b/www/manager/VNCConsole.js index 95ce28f3..56b7dea1 100644 --- a/www/manager/VNCConsole.js +++ b/www/manager/VNCConsole.js @@ -1,22 +1,52 @@ PVE_vnc_console_event = function(appletid, action, err) { //console.log("TESTINIT param1 " + appletid + " action " + action); - return; -/* - var el = Ext.get(appletid); - if (!el) - return; + if (action === "error") { + var compid = appletid.replace("-vncapp", ""); + var comp = Ext.getCmp(compid); - if (action === "close") { -// el.remove(); - } else if (action === "error") { -// console.log("TESTERROR: " + err); -// var compid = appletid.replace("-vncapp", ""); -// var comp = Ext.getCmp(compid); + if (!comp || !comp.vmid || !comp.toplevel) { + return; + } + + // try to detect migrated VM + PVE.Utils.API2Request({ + url: '/cluster/resources', + method: 'GET', + success: function(response) { + var list = response.result.data; + Ext.Array.each(list, function(item) { + if (item.type === 'qemu' && item.vmid == comp.vmid) { + if (item.node !== comp.nodename) { + //console.log("MOVED VM to node " + item.node); + comp.nodename = item.node; + comp.url = "/nodes/" + comp.nodename + "/" + item.type + "/" + comp.vmid + "/vncproxy"; + //console.log("NEW URL " + comp.url); + comp.reloadApplet(); + } + return false; // break + } + }); + } + }); } - //Ext.get('mytestid').remove(); -*/ + return; + /* + var el = Ext.get(appletid); + if (!el) + return; + + if (action === "close") { + // el.remove(); + } else if (action === "error") { + // console.log("TESTERROR: " + err); + // var compid = appletid.replace("-vncapp", ""); + // var comp = Ext.getCmp(compid); + } + + //Ext.get('mytestid').remove(); + */ };