]>
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 caps
= Ext
.state
.Manager
.get('GuiCap');
24 var base_url
= '/nodes/' + nodename
+ "/qemu/" + vmid
;
26 me
.statusStore
= Ext
.create('PVE.data.ObjectStore', {
27 url
: '/api2/json' + base_url
+ '/status/current',
31 var vm_command = function(cmd
, params
) {
32 PVE
.Utils
.API2Request({
34 url
: base_url
+ '/status/' + cmd
,
37 failure: function(response
, opts
) {
38 Ext
.Msg
.alert('Error', response
.htmlStatus
);
43 var resumeBtn
= Ext
.create('Ext.Button', {
44 text
: gettext('Resume'),
45 disabled
: !caps
.vms
['VM.PowerMgmt'],
53 var startBtn
= Ext
.create('Ext.Button', {
54 text
: gettext('Start'),
55 disabled
: !caps
.vms
['VM.PowerMgmt'],
62 var migrateBtn
= Ext
.create('Ext.Button', {
63 text
: gettext('Migrate'),
64 disabled
: !caps
.vms
['VM.Migrate'],
66 var win
= Ext
.create('PVE.window.Migrate', {
73 iconCls
: 'fa fa-send-o'
76 var cloneBtn
= Ext
.create('PVE.button.Split', {
77 text
: gettext('Clone'),
78 iconCls
: 'fa fa-fw fa-clone',
79 hidden
: caps
.vms
['VM.Clone'] ? false : true,
81 PVE
.window
.Clone
.wrap(nodename
, vmid
, template
);
85 text
: gettext('Convert to template'),
87 iconCls
: 'fa fa-fw fa-file-o',
88 hidden
: caps
.vms
['VM.Allocate'] ? false : true,
89 confirmMsg
: PVE
.Utils
.format_task_description('qmtemplate', vmid
),
91 PVE
.Utils
.API2Request({
92 url
: base_url
+ '/template',
95 failure: function(response
, opts
) {
96 Ext
.Msg
.alert('Error', response
.htmlStatus
);
104 var shutdownBtn
= Ext
.create('PVE.button.Split', {
105 text
: gettext('Shutdown'),
106 disabled
: !caps
.vms
['VM.PowerMgmt'],
107 confirmMsg
: PVE
.Utils
.format_task_description('qmshutdown', vmid
),
108 handler: function() {
109 vm_command('shutdown');
113 text
: gettext('Stop'),
114 disabled
: !caps
.vms
['VM.PowerMgmt'],
116 confirmMsg
: PVE
.Utils
.format_task_description('qmstop', vmid
),
117 handler: function() {
118 vm_command("stop", { timeout
: 30 });
120 iconCls
: 'fa fa-stop'
122 text
: gettext('Reset'),
123 disabled
: !caps
.vms
['VM.PowerMgmt'],
124 confirmMsg
: PVE
.Utils
.format_task_description('qmreset', vmid
),
125 handler: function() {
128 iconCls
: 'fa fa-bolt'
131 iconCls
: 'fa fa-power-off'
134 var removeBtn
= Ext
.create('PVE.button.Button', {
135 text
: gettext('Remove'),
136 disabled
: !caps
.vms
['VM.Allocate'],
137 handler: function() {
138 Ext
.create('PVE.window.SafeDestroy', {
140 item
: { type
: 'VM', id
: vmid
}
143 iconCls
: 'fa fa-trash-o'
146 var vmname
= me
.pveSelNode
.data
.name
;
148 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
149 disabled
: !caps
.vms
['VM.Console'],
154 iconCls
: 'fa fa-terminal'
157 var descr
= vmid
+ " (" + (vmname
? "'" + vmname
+ "' " : "'VM " + vmid
+ "'") + ")";
160 title
: Ext
.String
.format(gettext("Virtual Machine {0} on node {1}"), descr
, "'" + nodename
+ "'"),
162 tbar
: [ resumeBtn
, startBtn
, shutdownBtn
,
163 removeBtn
, migrateBtn
, cloneBtn
, consoleBtn
],
164 defaults
: { statusStore
: me
.statusStore
},
167 title
: gettext('Summary'),
168 xtype
: 'pveQemuSummary',
169 iconCls
: 'fa fa-book',
175 if (caps
.vms
['VM.Console'] && !template
) {
177 title
: gettext('Console'),
179 iconCls
: 'fa fa-terminal',
180 xtype
: 'pveNoVncConsole',
189 title
: gettext('Hardware'),
191 iconCls
: 'fa fa-desktop',
192 xtype
: 'PVE.qemu.HardwareView'
195 title
: gettext('Options'),
196 iconCls
: 'fa fa-gear',
198 xtype
: 'PVE.qemu.Options'
201 title
: gettext('Task History'),
203 xtype
: 'pveNodeTasks',
204 iconCls
: 'fa fa-list',
209 if (caps
.vms
['VM.Monitor'] && !template
) {
211 title
: gettext('Monitor'),
212 iconCls
: 'fa fa-eye',
214 xtype
: 'pveQemuMonitor'
218 if (caps
.vms
['VM.Backup']) {
220 title
: gettext('Backup'),
221 iconCls
: 'fa fa-floppy-o',
222 xtype
: 'pveBackupView',
226 title
: gettext('Replication'),
227 iconCls
: 'fa fa-retweet',
228 xtype
: 'pveReplicaView',
229 itemId
: 'replication'
233 if (caps
.vms
['VM.Snapshot'] && !template
) {
235 title
: gettext('Snapshots'),
236 iconCls
: 'fa fa-history',
237 xtype
: 'pveQemuSnapshotTree',
242 if (caps
.vms
['VM.Console']) {
245 xtype
: 'pveFirewallRules',
246 title
: gettext('Firewall'),
247 iconCls
: 'fa fa-shield',
249 base_url
: base_url
+ '/firewall/rules',
250 list_refs_url
: base_url
+ '/firewall/refs',
254 xtype
: 'pveFirewallOptions',
255 groups
: ['firewall'],
256 iconCls
: 'fa fa-gear',
257 onlineHelp
: 'pve_firewall_vm_container_configuration',
258 title
: gettext('Options'),
259 base_url
: base_url
+ '/firewall/options',
261 itemId
: 'firewall-options'
264 xtype
: 'pveFirewallAliases',
265 title
: gettext('Alias'),
266 groups
: ['firewall'],
267 iconCls
: 'fa fa-external-link',
268 base_url
: base_url
+ '/firewall/aliases',
269 itemId
: 'firewall-aliases'
273 title
: gettext('IPSet'),
274 groups
: ['firewall'],
275 iconCls
: 'fa fa-list-ol',
276 base_url
: base_url
+ '/firewall/ipset',
277 list_refs_url
: base_url
+ '/firewall/refs',
278 itemId
: 'firewall-ipset'
281 title
: gettext('Log'),
282 groups
: ['firewall'],
283 iconCls
: 'fa fa-list',
284 onlineHelp
: 'chapter_pve_firewall',
285 itemId
: 'firewall-fwlog',
287 url
: '/api2/extjs' + base_url
+ '/firewall/log'
292 if (caps
.vms
['Permissions.Modify']) {
295 title
: gettext('Permissions'),
296 iconCls
: 'fa fa-unlock',
297 itemId
: 'permissions',
304 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
310 me
.workspace
.checkVmMigration(me
.pveSelNode
);
311 status
= qmpstatus
= 'unknown';
313 var rec
= s
.data
.get('status');
314 status
= rec
? rec
.data
.value
: 'unknown';
315 rec
= s
.data
.get('qmpstatus');
316 qmpstatus
= rec
? rec
.data
.value
: 'unknown';
317 rec
= s
.data
.get('template');
318 template
= rec
.data
.value
|| false;
320 spice
= s
.data
.get('spice') ? true : false;
324 if (qmpstatus
=== 'prelaunch' || qmpstatus
=== 'paused') {
325 startBtn
.setVisible(false);
326 resumeBtn
.setVisible(true);
328 startBtn
.setVisible(true);
329 resumeBtn
.setVisible(false);
332 consoleBtn
.setEnableSpice(spice
);
334 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
335 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
336 removeBtn
.setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
337 consoleBtn
.setDisabled(template
);
340 me
.on('afterrender', function() {
341 me
.statusStore
.startUpdate();
344 me
.on('destroy', function() {
345 me
.statusStore
.stopUpdate();