* Copyright (C) 2013 Samuel Mannehed for Cendio AB
* Licensed under MPL 2.0 (see LICENSE.txt)
*
- * See README.md for usage and integration instructions.
+ * This is a modified version of the original 'ui.js' file, used
+ * for the proxmox console.
*/
"use strict";
var UI = {
rfb_state : 'loaded',
+pveAllowMigratedVMTest: false, // set to true after a succesful conection
pveCommandsOpen: false,
settingsOpen : false,
connSettingsOpen : false,
}, 5000);
},
+pve_detect_migrated_vm: function() {
+ if (!(UI.consoletype === 'kvm' || UI.consoletype === 'lxc')) {
+ return;
+ }
+
+ // try to detect migrated VM
+ UI.API2Request({
+ url: '/cluster/resources',
+ method: 'GET',
+ success: function(result) {
+ var list = result.data;
+ list.every(function(item) {
+ if ((item.type === 'qemu' || item.type === 'lxc') &&
+ (item.vmid == UI.vmid)) {
+ var url = "?" + UI.urlEncode({
+ console: UI.consoletype,
+ novnc: 1,
+ vmid: UI.vmid,
+ vmname: UI.vmname,
+ node: item.node
+ });
+ location.href = url;
+ return false; // break
+ }
+ return true;
+ });
+ }
+ });
+},
+
pve_vm_command: function(cmd, params, reload) {
var baseUrl;
if (UI.consoletype === 'kvm') {
baseUrl = '/nodes/' + UI.nodename + '/qemu/' + UI.vmid;
- } else if (UI.consoletype === 'openvz') {
- baseUrl = '/nodes/' + UI.nodename + '/openvz/' + UI.vmid;
+ } else if (UI.consoletype === 'lxc') {
+ baseUrl = '/nodes/' + UI.nodename + '/lxc/' + UI.vmid;
} else {
throw "unknown VM type";
}
{
text: gettext('Start'),
handler: UI.pveCmdStart,
- enable: { kvm: 1, openvz: 1 }
+ enable: { kvm: 1, lxc: 1 }
},
{
text: gettext('Shutdown'),
handler: UI.pveCmdShutdown,
- enable: { kvm: 1, openvz: 1 }
+ enable: { kvm: 1, lxc: 1 }
},
{
text: gettext('Stop'),
handler: UI.pveCmdStop,
- enable: { kvm: 1, openvz: 1 }
+ enable: { kvm: 1, lxc: 1 }
},
{
text: gettext('Reset'),
el.style.width = "100%";
el.style.minWidth = "150px";
cmdpanel.appendChild(el);
- console.log("ADD: " + btn.text);
}
});
if (UI.vmname) {
title += " ('" + UI.vmname + "')";
}
- } else if (UI.consoletype === 'openvz') {
- var baseUrl = '/nodes/' + UI.nodename + '/openvz/' + UI.vmid;
+ } else if (UI.consoletype === 'lxc') {
+ var baseUrl = '/nodes/' + UI.nodename + '/lxc/' + UI.vmid;
url = baseUrl + '/vncproxy';
wsurl = baseUrl + '/vncwebsocket';
title = "CT " + UI.vmid;
});
UI.updateSetting('host', window.location.hostname);
- UI.updateSetting('port', window.location.port);
+ UI.updateSetting('port', window.location.port || 443);
UI.updateSetting('password', param.ticket);
UI.updateSetting('encrypt', true);
UI.updateSetting('true_color', true);
break;
case 'normal':
klass = "noVNC_status_normal";
+ UI.pveAllowMigratedVMTest = true;
break;
case 'disconnected':
$D('noVNC_logo').style.display = "block";
- // Fall through
+ if (UI.pveAllowMigratedVMTest) {
+ UI.pveAllowMigratedVMTest = false;
+ UI.pve_detect_migrated_vm();
+ }
+ // Fall through
case 'loaded':
klass = "noVNC_status_normal";
break;