initComponent: function() {
var me = this;
+ var vm = me.pveSelNode.data;
- var nodename = me.pveSelNode.data.node;
+ var nodename = vm.node;
if (!nodename) {
throw "no node name specified";
}
- var vmid = me.pveSelNode.data.vmid;
+ var vmid = vm.vmid;
if (!vmid) {
throw "no VM ID specified";
}
- var template = !!me.pveSelNode.data.template;
+ var template = !!vm.template;
- var running = !!me.pveSelNode.data.uptime;
+ var running = !!vm.uptime;
var caps = Ext.state.Manager.get('GuiCap');
me.statusStore = Ext.create('Proxmox.data.ObjectStore', {
url: '/api2/json' + base_url + '/status/current',
- interval: 1000
+ interval: 1000,
});
var vm_command = function(cmd, params) {
method: 'POST',
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
- }
+ },
});
};
handler: function() {
vm_command('resume');
},
- iconCls: 'fa fa-play'
+ iconCls: 'fa fa-play',
});
var startBtn = Ext.create('Ext.Button', {
handler: function() {
vm_command('start');
},
- iconCls: 'fa fa-play'
+ iconCls: 'fa fa-play',
});
var migrateBtn = Ext.create('Ext.Button', {
var win = Ext.create('PVE.window.Migrate', {
vmtype: 'qemu',
nodename: nodename,
- vmid: vmid
+ vmid: vmid,
});
win.show();
},
- iconCls: 'fa fa-send-o'
+ iconCls: 'fa fa-send-o',
});
var moreBtn = Ext.create('Proxmox.button.Button', {
hidden: caps.vms['VM.Clone'] ? false : true,
handler: function() {
PVE.window.Clone.wrap(nodename, vmid, template, 'qemu');
- }
+ },
},
{
text: gettext('Convert to template'),
method: 'POST',
failure: function(response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
- }
+ },
});
- }
+ },
},
{
iconCls: 'fa fa-heartbeat ',
hidden: !caps.nodes['Sys.Console'],
text: gettext('Manage HA'),
handler: function() {
- var ha = me.pveSelNode.data.hastate;
+ var ha = vm.hastate;
Ext.create('PVE.ha.VMResourceEdit', {
vmid: vmid,
- isCreate: (!ha || ha === 'unmanaged')
+ isCreate: (!ha || ha === 'unmanaged'),
}).show();
- }
+ },
},
{
text: gettext('Remove'),
handler: function() {
Ext.create('PVE.window.SafeDestroy', {
url: base_url,
- item: { type: 'VM', id: vmid }
+ item: { type: 'VM', id: vmid },
}).show();
},
- iconCls: 'fa fa-trash-o'
- }
- ]}
+ iconCls: 'fa fa-trash-o',
+ },
+ ]},
});
var shutdownBtn = Ext.create('PVE.button.Split', {
items: [{
text: gettext('Reboot'),
disabled: !caps.vms['VM.PowerMgmt'],
+ tooltip: Ext.String.format(gettext('Shutdown, apply pending changes and reboot {0}'), 'VM'),
confirmMsg: Proxmox.Utils.format_task_description('qmreboot', vmid),
handler: function() {
vm_command("reboot");
},
- iconCls: 'fa fa-refresh'
- },{
+ iconCls: 'fa fa-refresh',
+ }, {
text: gettext('Pause'),
disabled: !caps.vms['VM.PowerMgmt'],
confirmMsg: Proxmox.Utils.format_task_description('qmpause', vmid),
handler: function() {
vm_command("suspend");
},
- iconCls: 'fa fa-pause'
- },{
+ iconCls: 'fa fa-pause',
+ }, {
text: gettext('Hibernate'),
disabled: !caps.vms['VM.PowerMgmt'],
confirmMsg: Proxmox.Utils.format_task_description('qmsuspend', vmid),
handler: function() {
vm_command("suspend", { todisk: 1 });
},
- iconCls: 'fa fa-download'
- },{
+ iconCls: 'fa fa-download',
+ }, {
text: gettext('Stop'),
disabled: !caps.vms['VM.PowerMgmt'],
dangerous: true,
handler: function() {
vm_command("stop", { timeout: 30 });
},
- iconCls: 'fa fa-stop'
- },{
+ iconCls: 'fa fa-stop',
+ }, {
text: gettext('Reset'),
disabled: !caps.vms['VM.PowerMgmt'],
+ tooltip: Ext.String.format(gettext('Reset {0} immediately'), 'VM'),
confirmMsg: Proxmox.Utils.format_task_description('qmreset', vmid),
handler: function() {
vm_command("reset");
},
- iconCls: 'fa fa-bolt'
- }]
+ iconCls: 'fa fa-bolt',
+ }],
},
- iconCls: 'fa fa-power-off'
+ iconCls: 'fa fa-power-off',
});
- var vm = me.pveSelNode.data;
-
var consoleBtn = Ext.create('PVE.button.ConsoleButton', {
disabled: !caps.vms['VM.Console'],
hidden: template,
consoleType: 'kvm',
consoleName: vm.name,
nodename: nodename,
- vmid: vmid
+ vmid: vmid,
});
var statusTxt = Ext.create('Ext.toolbar.TextItem', {
data: {
- lock: undefined
+ lock: undefined,
},
tpl: [
'<tpl if="lock">',
'<i class="fa fa-lg fa-lock"></i> ({lock})',
- '</tpl>'
- ]
+ '</tpl>',
+ ],
});
Ext.apply(me, {
items: [
{
title: gettext('Summary'),
- xtype: 'pveQemuSummary',
+ xtype: 'pveGuestSummary',
iconCls: 'fa fa-book',
- itemId: 'summary'
- }
- ]
+ itemId: 'summary',
+ },
+ ],
});
if (caps.vms['VM.Console'] && !template) {
xtype: 'pveNoVncConsole',
vmid: vmid,
consoleType: 'kvm',
- nodename: nodename
+ nodename: nodename,
});
}
title: gettext('Hardware'),
itemId: 'hardware',
iconCls: 'fa fa-desktop',
- xtype: 'PVE.qemu.HardwareView'
+ xtype: 'PVE.qemu.HardwareView',
},
{
title: 'Cloud-Init',
itemId: 'cloudinit',
iconCls: 'fa fa-cloud',
- xtype: 'pveCiPanel'
+ xtype: 'pveCiPanel',
},
{
title: gettext('Options'),
iconCls: 'fa fa-gear',
itemId: 'options',
- xtype: 'PVE.qemu.Options'
+ xtype: 'PVE.qemu.Options',
},
{
title: gettext('Task History'),
xtype: 'proxmoxNodeTasks',
iconCls: 'fa fa-list',
nodename: nodename,
- vmidFilter: vmid
- }
+ vmidFilter: vmid,
+ },
);
if (caps.vms['VM.Monitor'] && !template) {
title: gettext('Monitor'),
iconCls: 'fa fa-eye',
itemId: 'monitor',
- xtype: 'pveQemuMonitor'
+ xtype: 'pveQemuMonitor',
});
}
title: gettext('Backup'),
iconCls: 'fa fa-floppy-o',
xtype: 'pveBackupView',
- itemId: 'backup'
+ itemId: 'backup',
},
{
title: gettext('Replication'),
iconCls: 'fa fa-retweet',
xtype: 'pveReplicaView',
- itemId: 'replication'
+ itemId: 'replication',
});
}
- if ((caps.vms['VM.Snapshot'] || caps.vms['VM.Snapshot.Rollback']) && !template) {
+ if ((caps.vms['VM.Snapshot'] || caps.vms['VM.Snapshot.Rollback'] ||
+ caps.vms['VM.Audit']) && !template) {
me.items.push({
title: gettext('Snapshots'),
iconCls: 'fa fa-history',
- xtype: 'pveQemuSnapshotTree',
- itemId: 'snapshot'
+ type: 'qemu',
+ xtype: 'pveGuestSnapshotTree',
+ itemId: 'snapshot',
});
}
allow_iface: true,
base_url: base_url + '/firewall/rules',
list_refs_url: base_url + '/firewall/refs',
- itemId: 'firewall'
+ itemId: 'firewall',
},
{
xtype: 'pveFirewallOptions',
title: gettext('Options'),
base_url: base_url + '/firewall/options',
fwtype: 'vm',
- itemId: 'firewall-options'
+ itemId: 'firewall-options',
},
{
xtype: 'pveFirewallAliases',
groups: ['firewall'],
iconCls: 'fa fa-external-link',
base_url: base_url + '/firewall/aliases',
- itemId: 'firewall-aliases'
+ itemId: 'firewall-aliases',
},
{
xtype: 'pveIPSet',
iconCls: 'fa fa-list-ol',
base_url: base_url + '/firewall/ipset',
list_refs_url: base_url + '/firewall/refs',
- itemId: 'firewall-ipset'
+ itemId: 'firewall-ipset',
},
{
title: gettext('Log'),
onlineHelp: 'chapter_pve_firewall',
itemId: 'firewall-fwlog',
xtype: 'proxmoxLogView',
- url: '/api2/extjs' + base_url + '/firewall/log'
- }
+ url: '/api2/extjs' + base_url + '/firewall/log',
+ },
);
}
title: gettext('Permissions'),
iconCls: 'fa fa-unlock',
itemId: 'permissions',
- path: '/vms/' + vmid
+ path: '/vms/' + vmid,
});
}
me.callParent();
+ var prevQMPStatus = 'unknown';
me.mon(me.statusStore, 'load', function(s, records, success) {
var status;
var qmpstatus;
statusTxt.update({ lock: lock });
- startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'running' || template);
+ let guest_running = status === 'running' &&
+ !(qmpstatus === "shutdown" || qmpstatus === "prelaunch");
+ startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || template || guest_running);
+
shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
me.down('#removeBtn').setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped');
consoleBtn.setDisabled(template);
+
+ let wasStopped = ['prelaunch', 'stopped', 'suspended'].indexOf(prevQMPStatus) !== -1;
+ if (wasStopped && qmpstatus === 'running') {
+ let con = me.down('#console');
+ if (con) {
+ con.reload();
+ }
+ }
+
+ prevQMPStatus = qmpstatus;
});
me.on('afterrender', function() {
me.on('destroy', function() {
me.statusStore.stopUpdate();
});
- }
+ },
});