]>
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('PVE.data.ObjectStore', {
29 url
: '/api2/json' + base_url
+ '/status/current',
33 var vm_command = function(cmd
, params
) {
34 PVE
.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
);
92 text
: gettext('Convert to template'),
95 iconCls
: 'fa fa-fw fa-file-o',
96 hidden
: caps
.vms
['VM.Allocate'] ? false : true,
97 confirmMsg
: PVE
.Utils
.format_task_description('qmtemplate', vmid
),
99 PVE
.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
: PVE
.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
: PVE
.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
: PVE
.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
,
179 title
: Ext
.String
.format(gettext("Virtual Machine {0} on node '{1}'"), vm
.text
, nodename
),
181 tbar
: [ resumeBtn
, startBtn
, shutdownBtn
, migrateBtn
, consoleBtn
, moreBtn
],
182 defaults
: { statusStore
: me
.statusStore
},
185 title
: gettext('Summary'),
186 xtype
: 'pveQemuSummary',
187 iconCls
: 'fa fa-book',
193 if (caps
.vms
['VM.Console'] && !template
) {
195 title
: gettext('Console'),
197 iconCls
: 'fa fa-terminal',
198 xtype
: 'pveNoVncConsole',
207 title
: gettext('Hardware'),
209 iconCls
: 'fa fa-desktop',
210 xtype
: 'PVE.qemu.HardwareView'
213 title
: gettext('Options'),
214 iconCls
: 'fa fa-gear',
216 xtype
: 'PVE.qemu.Options'
219 title
: gettext('Task History'),
221 xtype
: 'proxmoxNodeTasks',
222 iconCls
: 'fa fa-list',
228 if (caps
.vms
['VM.Monitor'] && !template
) {
230 title
: gettext('Monitor'),
231 iconCls
: 'fa fa-eye',
233 xtype
: 'pveQemuMonitor'
237 if (caps
.vms
['VM.Backup']) {
239 title
: gettext('Backup'),
240 iconCls
: 'fa fa-floppy-o',
241 xtype
: 'pveBackupView',
245 title
: gettext('Replication'),
246 iconCls
: 'fa fa-retweet',
247 xtype
: 'pveReplicaView',
248 itemId
: 'replication'
252 if ((caps
.vms
['VM.Snapshot'] || caps
.vms
['VM.Snapshot.Rollback']) && !template
) {
254 title
: gettext('Snapshots'),
255 iconCls
: 'fa fa-history',
256 xtype
: 'pveQemuSnapshotTree',
261 if (caps
.vms
['VM.Console']) {
264 xtype
: 'pveFirewallRules',
265 title
: gettext('Firewall'),
266 iconCls
: 'fa fa-shield',
268 base_url
: base_url
+ '/firewall/rules',
269 list_refs_url
: base_url
+ '/firewall/refs',
273 xtype
: 'pveFirewallOptions',
274 groups
: ['firewall'],
275 iconCls
: 'fa fa-gear',
276 onlineHelp
: 'pve_firewall_vm_container_configuration',
277 title
: gettext('Options'),
278 base_url
: base_url
+ '/firewall/options',
280 itemId
: 'firewall-options'
283 xtype
: 'pveFirewallAliases',
284 title
: gettext('Alias'),
285 groups
: ['firewall'],
286 iconCls
: 'fa fa-external-link',
287 base_url
: base_url
+ '/firewall/aliases',
288 itemId
: 'firewall-aliases'
292 title
: gettext('IPSet'),
293 groups
: ['firewall'],
294 iconCls
: 'fa fa-list-ol',
295 base_url
: base_url
+ '/firewall/ipset',
296 list_refs_url
: base_url
+ '/firewall/refs',
297 itemId
: 'firewall-ipset'
300 title
: gettext('Log'),
301 groups
: ['firewall'],
302 iconCls
: 'fa fa-list',
303 onlineHelp
: 'chapter_pve_firewall',
304 itemId
: 'firewall-fwlog',
306 url
: '/api2/extjs' + base_url
+ '/firewall/log'
311 if (caps
.vms
['Permissions.Modify']) {
314 title
: gettext('Permissions'),
315 iconCls
: 'fa fa-unlock',
316 itemId
: 'permissions',
323 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
329 status
= qmpstatus
= 'unknown';
331 var rec
= s
.data
.get('status');
332 status
= rec
? rec
.data
.value
: 'unknown';
333 rec
= s
.data
.get('qmpstatus');
334 qmpstatus
= rec
? rec
.data
.value
: 'unknown';
335 rec
= s
.data
.get('template');
336 template
= rec
.data
.value
|| false;
338 spice
= s
.data
.get('spice') ? true : false;
346 if (qmpstatus
=== 'prelaunch' || qmpstatus
=== 'paused' || qmpstatus
=== 'suspended') {
347 startBtn
.setVisible(false);
348 resumeBtn
.setVisible(true);
350 startBtn
.setVisible(true);
351 resumeBtn
.setVisible(false);
354 consoleBtn
.setEnableSpice(spice
);
356 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
357 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
358 me
.down('#removeBtn').setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
359 consoleBtn
.setDisabled(template
);
362 me
.on('afterrender', function() {
363 me
.statusStore
.startUpdate();
366 me
.on('destroy', function() {
367 me
.statusStore
.stopUpdate();