]>
git.proxmox.com Git - pve-manager-legacy.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'],
63 var migrateBtn
= Ext
.create('Ext.Button', {
64 text
: gettext('Migrate'),
65 disabled
: !caps
.vms
['VM.Migrate'],
66 hidden
: PVE
.data
.ResourceStore
.getNodes().length
< 2,
68 var win
= Ext
.create('PVE.window.Migrate', {
75 iconCls
: 'fa fa-send-o'
78 var cloneBtn
= Ext
.create('PVE.button.Split', {
79 text
: gettext('Clone'),
80 iconCls
: 'fa fa-fw fa-clone',
81 hidden
: caps
.vms
['VM.Clone'] ? false : true,
83 PVE
.window
.Clone
.wrap(nodename
, vmid
, template
);
87 text
: gettext('Convert to template'),
89 iconCls
: 'fa fa-fw fa-file-o',
90 hidden
: caps
.vms
['VM.Allocate'] ? false : true,
91 confirmMsg
: PVE
.Utils
.format_task_description('qmtemplate', vmid
),
93 PVE
.Utils
.API2Request({
94 url
: base_url
+ '/template',
97 failure: function(response
, opts
) {
98 Ext
.Msg
.alert('Error', response
.htmlStatus
);
106 var shutdownBtn
= Ext
.create('PVE.button.Split', {
107 text
: gettext('Shutdown'),
108 disabled
: !caps
.vms
['VM.PowerMgmt'],
110 confirmMsg
: PVE
.Utils
.format_task_description('qmshutdown', vmid
),
111 handler: function() {
112 vm_command('shutdown');
116 text
: gettext('Stop'),
117 disabled
: !caps
.vms
['VM.PowerMgmt'],
119 confirmMsg
: PVE
.Utils
.format_task_description('qmstop', vmid
),
120 handler: function() {
121 vm_command("stop", { timeout
: 30 });
123 iconCls
: 'fa fa-stop'
125 text
: gettext('Reset'),
126 disabled
: !caps
.vms
['VM.PowerMgmt'],
127 confirmMsg
: PVE
.Utils
.format_task_description('qmreset', vmid
),
128 handler: function() {
131 iconCls
: 'fa fa-bolt'
134 iconCls
: 'fa fa-power-off'
137 var removeBtn
= Ext
.create('PVE.button.Button', {
138 text
: gettext('Remove'),
139 disabled
: !caps
.vms
['VM.Allocate'],
140 handler: function() {
141 Ext
.create('PVE.window.SafeDestroy', {
143 item
: { type
: 'VM', id
: vmid
}
146 iconCls
: 'fa fa-trash-o'
149 var vmname
= me
.pveSelNode
.data
.name
;
151 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
152 disabled
: !caps
.vms
['VM.Console'],
158 iconCls
: 'fa fa-terminal'
161 var descr
= vmid
+ " (" + (vmname
? "'" + vmname
+ "' " : "'VM " + vmid
+ "'") + ")";
164 title
: Ext
.String
.format(gettext("Virtual Machine {0} on node {1}"), descr
, "'" + nodename
+ "'"),
166 tbar
: [ resumeBtn
, startBtn
, shutdownBtn
,
167 removeBtn
, migrateBtn
, cloneBtn
, consoleBtn
],
168 defaults
: { statusStore
: me
.statusStore
},
171 title
: gettext('Summary'),
172 xtype
: 'pveQemuSummary',
173 iconCls
: 'fa fa-book',
179 if (caps
.vms
['VM.Console'] && !template
) {
181 title
: gettext('Console'),
183 iconCls
: 'fa fa-terminal',
184 xtype
: 'pveNoVncConsole',
193 title
: gettext('Hardware'),
195 iconCls
: 'fa fa-desktop',
196 xtype
: 'PVE.qemu.HardwareView'
199 title
: gettext('Options'),
200 iconCls
: 'fa fa-gear',
202 xtype
: 'PVE.qemu.Options'
205 title
: gettext('Task History'),
207 xtype
: 'pveNodeTasks',
208 iconCls
: 'fa fa-list',
213 if (caps
.vms
['VM.Monitor'] && !template
) {
215 title
: gettext('Monitor'),
216 iconCls
: 'fa fa-eye',
218 xtype
: 'pveQemuMonitor'
222 if (caps
.vms
['VM.Backup']) {
224 title
: gettext('Backup'),
225 iconCls
: 'fa fa-floppy-o',
226 xtype
: 'pveBackupView',
230 title
: gettext('Replication'),
231 iconCls
: 'fa fa-retweet',
232 xtype
: 'pveReplicaView',
233 itemId
: 'replication'
237 if (caps
.vms
['VM.Snapshot'] && !template
) {
239 title
: gettext('Snapshots'),
240 iconCls
: 'fa fa-history',
241 xtype
: 'pveQemuSnapshotTree',
246 if (caps
.vms
['VM.Console']) {
249 xtype
: 'pveFirewallRules',
250 title
: gettext('Firewall'),
251 iconCls
: 'fa fa-shield',
253 base_url
: base_url
+ '/firewall/rules',
254 list_refs_url
: base_url
+ '/firewall/refs',
258 xtype
: 'pveFirewallOptions',
259 groups
: ['firewall'],
260 iconCls
: 'fa fa-gear',
261 onlineHelp
: 'pve_firewall_vm_container_configuration',
262 title
: gettext('Options'),
263 base_url
: base_url
+ '/firewall/options',
265 itemId
: 'firewall-options'
268 xtype
: 'pveFirewallAliases',
269 title
: gettext('Alias'),
270 groups
: ['firewall'],
271 iconCls
: 'fa fa-external-link',
272 base_url
: base_url
+ '/firewall/aliases',
273 itemId
: 'firewall-aliases'
277 title
: gettext('IPSet'),
278 groups
: ['firewall'],
279 iconCls
: 'fa fa-list-ol',
280 base_url
: base_url
+ '/firewall/ipset',
281 list_refs_url
: base_url
+ '/firewall/refs',
282 itemId
: 'firewall-ipset'
285 title
: gettext('Log'),
286 groups
: ['firewall'],
287 iconCls
: 'fa fa-list',
288 onlineHelp
: 'chapter_pve_firewall',
289 itemId
: 'firewall-fwlog',
291 url
: '/api2/extjs' + base_url
+ '/firewall/log'
296 if (caps
.vms
['Permissions.Modify']) {
299 title
: gettext('Permissions'),
300 iconCls
: 'fa fa-unlock',
301 itemId
: 'permissions',
308 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
314 status
= qmpstatus
= 'unknown';
316 var rec
= s
.data
.get('status');
317 status
= rec
? rec
.data
.value
: 'unknown';
318 rec
= s
.data
.get('qmpstatus');
319 qmpstatus
= rec
? rec
.data
.value
: 'unknown';
320 rec
= s
.data
.get('template');
321 template
= rec
.data
.value
|| false;
323 spice
= s
.data
.get('spice') ? true : false;
331 if (qmpstatus
=== 'prelaunch' || qmpstatus
=== 'paused' || qmpstatus
=== 'suspended') {
332 startBtn
.setVisible(false);
333 resumeBtn
.setVisible(true);
335 startBtn
.setVisible(true);
336 resumeBtn
.setVisible(false);
339 consoleBtn
.setEnableSpice(spice
);
341 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
342 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
343 removeBtn
.setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
344 consoleBtn
.setDisabled(template
);
347 me
.on('afterrender', function() {
348 me
.statusStore
.startUpdate();
351 me
.on('destroy', function() {
352 me
.statusStore
.stopUpdate();