]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/Config.js
1 Ext
.define('PVE.qemu.Config', {
2 extend
: 'PVE.panel.Config',
3 alias
: 'widget.PVE.qemu.Config',
5 onlineHelp
: 'chapter_virtual_machines',
7 initComponent: function() {
10 var nodename
= me
.pveSelNode
.data
.node
;
12 throw "no node name specified";
15 var vmid
= me
.pveSelNode
.data
.vmid
;
17 throw "no VM ID specified";
20 var template
= !!me
.pveSelNode
.data
.template
;
22 var running
= !!me
.pveSelNode
.data
.uptime
;
24 var caps
= Ext
.state
.Manager
.get('GuiCap');
26 var base_url
= '/nodes/' + nodename
+ "/qemu/" + vmid
;
28 me
.statusStore
= Ext
.create('Proxmox.data.ObjectStore', {
29 url
: '/api2/json' + base_url
+ '/status/current',
33 var vm_command = function(cmd
, params
) {
34 Proxmox
.Utils
.API2Request({
36 url
: base_url
+ '/status/' + cmd
,
39 failure: function(response
, opts
) {
40 Ext
.Msg
.alert('Error', response
.htmlStatus
);
45 var resumeBtn
= Ext
.create('Ext.Button', {
46 text
: gettext('Resume'),
47 disabled
: !caps
.vms
['VM.PowerMgmt'],
55 var startBtn
= Ext
.create('Ext.Button', {
56 text
: gettext('Start'),
57 disabled
: !caps
.vms
['VM.PowerMgmt'] || running
,
65 var migrateBtn
= Ext
.create('Ext.Button', {
66 text
: gettext('Migrate'),
67 disabled
: !caps
.vms
['VM.Migrate'],
68 hidden
: PVE
.data
.ResourceStore
.getNodes().length
< 2,
70 var win
= Ext
.create('PVE.window.Migrate', {
77 iconCls
: 'fa fa-send-o'
80 var moreBtn
= Ext
.create('Proxmox.button.Button', {
81 text
: gettext('More'),
84 text
: gettext('Clone'),
85 iconCls
: 'fa fa-fw fa-clone',
86 hidden
: caps
.vms
['VM.Clone'] ? false : true,
88 PVE
.window
.Clone
.wrap(nodename
, vmid
, template
, 'qemu');
92 text
: gettext('Convert to template'),
95 iconCls
: 'fa fa-fw fa-file-o',
96 hidden
: caps
.vms
['VM.Allocate'] ? false : true,
97 confirmMsg
: Proxmox
.Utils
.format_task_description('qmtemplate', vmid
),
99 Proxmox
.Utils
.API2Request({
100 url
: base_url
+ '/template',
103 failure: function(response
, opts
) {
104 Ext
.Msg
.alert('Error', response
.htmlStatus
);
110 iconCls
: 'fa fa-heartbeat ',
111 hidden
: !caps
.nodes
['Sys.Console'],
112 text
: gettext('Manage HA'),
113 handler: function() {
114 var ha
= me
.pveSelNode
.data
.hastate
;
115 Ext
.create('PVE.ha.VMResourceEdit', {
117 isCreate
: (!ha
|| ha
=== 'unmanaged')
122 text
: gettext('Remove'),
124 disabled
: !caps
.vms
['VM.Allocate'],
125 handler: function() {
126 Ext
.create('PVE.window.SafeDestroy', {
128 item
: { type
: 'VM', id
: vmid
}
131 iconCls
: 'fa fa-trash-o'
136 var shutdownBtn
= Ext
.create('PVE.button.Split', {
137 text
: gettext('Shutdown'),
138 disabled
: !caps
.vms
['VM.PowerMgmt'] || !running
,
140 confirmMsg
: Proxmox
.Utils
.format_task_description('qmshutdown', vmid
),
141 handler: function() {
142 vm_command('shutdown');
146 text
: gettext('Reboot'),
147 disabled
: !caps
.vms
['VM.PowerMgmt'],
148 tooltip
: Ext
.String
.format(gettext('Shutdown, apply pending changes and reboot {0}'), 'VM'),
149 confirmMsg
: Proxmox
.Utils
.format_task_description('qmreboot', vmid
),
150 handler: function() {
151 vm_command("reboot");
153 iconCls
: 'fa fa-refresh'
155 text
: gettext('Pause'),
156 disabled
: !caps
.vms
['VM.PowerMgmt'],
157 confirmMsg
: Proxmox
.Utils
.format_task_description('qmpause', vmid
),
158 handler: function() {
159 vm_command("suspend");
161 iconCls
: 'fa fa-pause'
163 text
: gettext('Hibernate'),
164 disabled
: !caps
.vms
['VM.PowerMgmt'],
165 confirmMsg
: Proxmox
.Utils
.format_task_description('qmsuspend', vmid
),
166 tooltip
: gettext('Suspend to disk'),
167 handler: function() {
168 vm_command("suspend", { todisk
: 1 });
170 iconCls
: 'fa fa-download'
172 text
: gettext('Stop'),
173 disabled
: !caps
.vms
['VM.PowerMgmt'],
175 tooltip
: Ext
.String
.format(gettext('Stop {0} immediately'), 'VM'),
176 confirmMsg
: Proxmox
.Utils
.format_task_description('qmstop', vmid
),
177 handler: function() {
178 vm_command("stop", { timeout
: 30 });
180 iconCls
: 'fa fa-stop'
182 text
: gettext('Reset'),
183 disabled
: !caps
.vms
['VM.PowerMgmt'],
184 tooltip
: Ext
.String
.format(gettext('Reset {0} immediately'), 'VM'),
185 confirmMsg
: Proxmox
.Utils
.format_task_description('qmreset', vmid
),
186 handler: function() {
189 iconCls
: 'fa fa-bolt'
192 iconCls
: 'fa fa-power-off'
195 var vm
= me
.pveSelNode
.data
;
197 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
198 disabled
: !caps
.vms
['VM.Console'],
201 consoleName
: vm
.name
,
206 var statusTxt
= Ext
.create('Ext.toolbar.TextItem', {
212 '<i class="fa fa-lg fa-lock"></i> ({lock})',
218 title
: Ext
.String
.format(gettext("Virtual Machine {0} on node '{1}'"), vm
.text
, nodename
),
221 tbar
: [ statusTxt
, '->', resumeBtn
, startBtn
, shutdownBtn
, migrateBtn
, consoleBtn
, moreBtn
],
222 defaults
: { statusStore
: me
.statusStore
},
225 title
: gettext('Summary'),
226 xtype
: 'pveGuestSummary',
227 iconCls
: 'fa fa-book',
233 if (caps
.vms
['VM.Console'] && !template
) {
235 title
: gettext('Console'),
237 iconCls
: 'fa fa-terminal',
238 xtype
: 'pveNoVncConsole',
247 title
: gettext('Hardware'),
249 iconCls
: 'fa fa-desktop',
250 xtype
: 'PVE.qemu.HardwareView'
255 iconCls
: 'fa fa-cloud',
259 title
: gettext('Options'),
260 iconCls
: 'fa fa-gear',
262 xtype
: 'PVE.qemu.Options'
265 title
: gettext('Task History'),
267 xtype
: 'proxmoxNodeTasks',
268 iconCls
: 'fa fa-list',
274 if (caps
.vms
['VM.Monitor'] && !template
) {
276 title
: gettext('Monitor'),
277 iconCls
: 'fa fa-eye',
279 xtype
: 'pveQemuMonitor'
283 if (caps
.vms
['VM.Backup']) {
285 title
: gettext('Backup'),
286 iconCls
: 'fa fa-floppy-o',
287 xtype
: 'pveBackupView',
291 title
: gettext('Replication'),
292 iconCls
: 'fa fa-retweet',
293 xtype
: 'pveReplicaView',
294 itemId
: 'replication'
298 if ((caps
.vms
['VM.Snapshot'] || caps
.vms
['VM.Snapshot.Rollback']) && !template
) {
300 title
: gettext('Snapshots'),
301 iconCls
: 'fa fa-history',
302 xtype
: 'pveQemuSnapshotTree',
307 if (caps
.vms
['VM.Console']) {
310 xtype
: 'pveFirewallRules',
311 title
: gettext('Firewall'),
312 iconCls
: 'fa fa-shield',
314 base_url
: base_url
+ '/firewall/rules',
315 list_refs_url
: base_url
+ '/firewall/refs',
319 xtype
: 'pveFirewallOptions',
320 groups
: ['firewall'],
321 iconCls
: 'fa fa-gear',
322 onlineHelp
: 'pve_firewall_vm_container_configuration',
323 title
: gettext('Options'),
324 base_url
: base_url
+ '/firewall/options',
326 itemId
: 'firewall-options'
329 xtype
: 'pveFirewallAliases',
330 title
: gettext('Alias'),
331 groups
: ['firewall'],
332 iconCls
: 'fa fa-external-link',
333 base_url
: base_url
+ '/firewall/aliases',
334 itemId
: 'firewall-aliases'
338 title
: gettext('IPSet'),
339 groups
: ['firewall'],
340 iconCls
: 'fa fa-list-ol',
341 base_url
: base_url
+ '/firewall/ipset',
342 list_refs_url
: base_url
+ '/firewall/refs',
343 itemId
: 'firewall-ipset'
346 title
: gettext('Log'),
347 groups
: ['firewall'],
348 iconCls
: 'fa fa-list',
349 onlineHelp
: 'chapter_pve_firewall',
350 itemId
: 'firewall-fwlog',
351 xtype
: 'proxmoxLogView',
352 url
: '/api2/extjs' + base_url
+ '/firewall/log'
357 if (caps
.vms
['Permissions.Modify']) {
360 title
: gettext('Permissions'),
361 iconCls
: 'fa fa-unlock',
362 itemId
: 'permissions',
369 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
377 status
= qmpstatus
= 'unknown';
379 var rec
= s
.data
.get('status');
380 status
= rec
? rec
.data
.value
: 'unknown';
381 rec
= s
.data
.get('qmpstatus');
382 qmpstatus
= rec
? rec
.data
.value
: 'unknown';
383 rec
= s
.data
.get('template');
384 template
= rec
.data
.value
|| false;
385 rec
= s
.data
.get('lock');
386 lock
= rec
? rec
.data
.value
: undefined;
388 spice
= s
.data
.get('spice') ? true : false;
389 xtermjs
= s
.data
.get('serial') ? true : false;
397 var resume
= (['prelaunch', 'paused', 'suspended'].indexOf(qmpstatus
) !== -1);
399 if (resume
|| lock
=== 'suspended') {
400 startBtn
.setVisible(false);
401 resumeBtn
.setVisible(true);
403 startBtn
.setVisible(true);
404 resumeBtn
.setVisible(false);
407 consoleBtn
.setEnableSpice(spice
);
408 consoleBtn
.setEnableXtermJS(xtermjs
);
410 statusTxt
.update({ lock
: lock
});
412 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
413 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
414 me
.down('#removeBtn').setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
415 consoleBtn
.setDisabled(template
);
418 me
.on('afterrender', function() {
419 me
.statusStore
.startUpdate();
422 me
.on('destroy', function() {
423 me
.statusStore
.stopUpdate();