]>
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('Stop'),
147 disabled
: !caps
.vms
['VM.PowerMgmt'],
149 confirmMsg
: Proxmox
.Utils
.format_task_description('qmstop', vmid
),
150 handler: function() {
151 vm_command("stop", { timeout
: 30 });
153 iconCls
: 'fa fa-stop'
155 text
: gettext('Reset'),
156 disabled
: !caps
.vms
['VM.PowerMgmt'],
157 confirmMsg
: Proxmox
.Utils
.format_task_description('qmreset', vmid
),
158 handler: function() {
161 iconCls
: 'fa fa-bolt'
164 iconCls
: 'fa fa-power-off'
167 var vm
= me
.pveSelNode
.data
;
169 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
170 disabled
: !caps
.vms
['VM.Console'],
173 consoleName
: vm
.name
,
178 var statusTxt
= Ext
.create('Ext.toolbar.TextItem', {
184 '<i class="fa fa-lg fa-lock"></i> ({lock})',
190 title
: Ext
.String
.format(gettext("Virtual Machine {0} on node '{1}'"), vm
.text
, nodename
),
193 tbar
: [ statusTxt
, '->', resumeBtn
, startBtn
, shutdownBtn
, migrateBtn
, consoleBtn
, moreBtn
],
194 defaults
: { statusStore
: me
.statusStore
},
197 title
: gettext('Summary'),
198 xtype
: 'pveQemuSummary',
199 iconCls
: 'fa fa-book',
205 if (caps
.vms
['VM.Console'] && !template
) {
207 title
: gettext('Console'),
209 iconCls
: 'fa fa-terminal',
210 xtype
: 'pveNoVncConsole',
219 title
: gettext('Hardware'),
221 iconCls
: 'fa fa-desktop',
222 xtype
: 'PVE.qemu.HardwareView'
227 iconCls
: 'fa fa-cloud',
231 title
: gettext('Options'),
232 iconCls
: 'fa fa-gear',
234 xtype
: 'PVE.qemu.Options'
237 title
: gettext('Task History'),
239 xtype
: 'proxmoxNodeTasks',
240 iconCls
: 'fa fa-list',
246 if (caps
.vms
['VM.Monitor'] && !template
) {
248 title
: gettext('Monitor'),
249 iconCls
: 'fa fa-eye',
251 xtype
: 'pveQemuMonitor'
255 if (caps
.vms
['VM.Backup']) {
257 title
: gettext('Backup'),
258 iconCls
: 'fa fa-floppy-o',
259 xtype
: 'pveBackupView',
263 title
: gettext('Replication'),
264 iconCls
: 'fa fa-retweet',
265 xtype
: 'pveReplicaView',
266 itemId
: 'replication'
270 if ((caps
.vms
['VM.Snapshot'] || caps
.vms
['VM.Snapshot.Rollback']) && !template
) {
272 title
: gettext('Snapshots'),
273 iconCls
: 'fa fa-history',
274 xtype
: 'pveQemuSnapshotTree',
279 if (caps
.vms
['VM.Console']) {
282 xtype
: 'pveFirewallRules',
283 title
: gettext('Firewall'),
284 iconCls
: 'fa fa-shield',
286 base_url
: base_url
+ '/firewall/rules',
287 list_refs_url
: base_url
+ '/firewall/refs',
291 xtype
: 'pveFirewallOptions',
292 groups
: ['firewall'],
293 iconCls
: 'fa fa-gear',
294 onlineHelp
: 'pve_firewall_vm_container_configuration',
295 title
: gettext('Options'),
296 base_url
: base_url
+ '/firewall/options',
298 itemId
: 'firewall-options'
301 xtype
: 'pveFirewallAliases',
302 title
: gettext('Alias'),
303 groups
: ['firewall'],
304 iconCls
: 'fa fa-external-link',
305 base_url
: base_url
+ '/firewall/aliases',
306 itemId
: 'firewall-aliases'
310 title
: gettext('IPSet'),
311 groups
: ['firewall'],
312 iconCls
: 'fa fa-list-ol',
313 base_url
: base_url
+ '/firewall/ipset',
314 list_refs_url
: base_url
+ '/firewall/refs',
315 itemId
: 'firewall-ipset'
318 title
: gettext('Log'),
319 groups
: ['firewall'],
320 iconCls
: 'fa fa-list',
321 onlineHelp
: 'chapter_pve_firewall',
322 itemId
: 'firewall-fwlog',
323 xtype
: 'proxmoxLogView',
324 url
: '/api2/extjs' + base_url
+ '/firewall/log'
329 if (caps
.vms
['Permissions.Modify']) {
332 title
: gettext('Permissions'),
333 iconCls
: 'fa fa-unlock',
334 itemId
: 'permissions',
341 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
349 status
= qmpstatus
= 'unknown';
351 var rec
= s
.data
.get('status');
352 status
= rec
? rec
.data
.value
: 'unknown';
353 rec
= s
.data
.get('qmpstatus');
354 qmpstatus
= rec
? rec
.data
.value
: 'unknown';
355 rec
= s
.data
.get('template');
356 template
= rec
.data
.value
|| false;
357 rec
= s
.data
.get('lock');
358 lock
= rec
? rec
.data
.value
: undefined;
360 spice
= s
.data
.get('spice') ? true : false;
361 xtermjs
= s
.data
.get('serial') ? true : false;
369 if (qmpstatus
=== 'prelaunch' || qmpstatus
=== 'paused' || qmpstatus
=== 'suspended') {
370 startBtn
.setVisible(false);
371 resumeBtn
.setVisible(true);
373 startBtn
.setVisible(true);
374 resumeBtn
.setVisible(false);
377 consoleBtn
.setEnableSpice(spice
);
378 consoleBtn
.setEnableXtermJS(xtermjs
);
380 statusTxt
.update({ lock
: lock
});
382 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
383 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
384 me
.down('#removeBtn').setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
385 consoleBtn
.setDisabled(template
);
388 me
.on('afterrender', function() {
389 me
.statusStore
.startUpdate();
392 me
.on('destroy', function() {
393 me
.statusStore
.stopUpdate();