]>
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 initComponent: function() {
8 var nodename
= me
.pveSelNode
.data
.node
;
10 throw "no node name specified";
13 var vmid
= me
.pveSelNode
.data
.vmid
;
15 throw "no VM ID specified";
18 var template
= me
.pveSelNode
.data
.template
;
20 var caps
= Ext
.state
.Manager
.get('GuiCap');
22 var base_url
= '/nodes/' + nodename
+ "/qemu/" + vmid
;
24 me
.statusStore
= Ext
.create('PVE.data.ObjectStore', {
25 url
: '/api2/json' + base_url
+ '/status/current',
29 var vm_command = function(cmd
, params
) {
30 PVE
.Utils
.API2Request({
32 url
: base_url
+ '/status/' + cmd
,
35 failure: function(response
, opts
) {
36 Ext
.Msg
.alert('Error', response
.htmlStatus
);
41 var resumeBtn
= Ext
.create('Ext.Button', {
42 text
: gettext('Resume'),
43 disabled
: !caps
.vms
['VM.PowerMgmt'],
51 var startBtn
= Ext
.create('Ext.Button', {
52 text
: gettext('Start'),
53 disabled
: !caps
.vms
['VM.PowerMgmt'],
60 var migrateBtn
= Ext
.create('Ext.Button', {
61 text
: gettext('Migrate'),
62 disabled
: !caps
.vms
['VM.Migrate'],
64 var win
= Ext
.create('PVE.window.Migrate', {
71 iconCls
: 'fa fa-send-o'
74 var resetBtn
= Ext
.create('PVE.button.Button', {
75 text
: gettext('Reset'),
76 disabled
: !caps
.vms
['VM.PowerMgmt'],
77 confirmMsg
: PVE
.Utils
.format_task_description('qmreset', vmid
),
84 var shutdownBtn
= Ext
.create('PVE.button.Split', {
85 text
: gettext('Shutdown'),
86 disabled
: !caps
.vms
['VM.PowerMgmt'],
87 confirmMsg
: PVE
.Utils
.format_task_description('qmshutdown', vmid
),
89 vm_command('shutdown');
93 text
: gettext('Stop'),
94 disabled
: !caps
.vms
['VM.PowerMgmt'],
96 confirmMsg
: PVE
.Utils
.format_task_description('qmstop', vmid
),
98 vm_command("stop", { timeout
: 30 });
100 iconCls
: 'fa fa-stop'
103 iconCls
: 'fa fa-power-off'
106 var removeBtn
= Ext
.create('PVE.button.Button', {
107 text
: gettext('Remove'),
108 disabled
: !caps
.vms
['VM.Allocate'],
109 handler: function() {
110 Ext
.create('PVE.window.SafeDestroy', {
112 item
: { type
: 'VM', id
: vmid
}
115 iconCls
: 'fa fa-trash-o'
118 var vmname
= me
.pveSelNode
.data
.name
;
120 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
121 disabled
: !caps
.vms
['VM.Console'],
126 iconCls
: 'fa fa-terminal'
129 var descr
= vmid
+ " (" + (vmname
? "'" + vmname
+ "' " : "'VM " + vmid
+ "'") + ")";
132 title
: Ext
.String
.format(gettext("Virtual Machine {0} on node {1}"), descr
, "'" + nodename
+ "'"),
134 tbar
: [ resumeBtn
, startBtn
, shutdownBtn
, resetBtn
,
135 removeBtn
, migrateBtn
, consoleBtn
],
136 defaults
: { statusStore
: me
.statusStore
},
139 title
: gettext('Summary'),
140 xtype
: 'pveQemuSummary',
141 iconCls
: 'fa fa-book',
147 if (caps
.vms
['VM.Console'] && !template
) {
149 title
: gettext('Console'),
151 iconCls
: 'fa fa-terminal',
152 xtype
: 'pveNoVncConsole',
161 title
: gettext('Hardware'),
163 iconCls
: 'fa fa-desktop',
164 xtype
: 'PVE.qemu.HardwareView'
167 title
: gettext('Options'),
168 iconCls
: 'fa fa-gear',
170 xtype
: 'PVE.qemu.Options'
173 title
: gettext('Task History'),
175 xtype
: 'pveNodeTasks',
176 iconCls
: 'fa fa-list',
181 if (caps
.vms
['VM.Monitor'] && !template
) {
183 title
: gettext('Monitor'),
184 iconCls
: 'fa fa-eye',
186 xtype
: 'pveQemuMonitor'
190 if (caps
.vms
['VM.Backup']) {
192 title
: gettext('Backup'),
193 iconCls
: 'fa fa-floppy-o',
194 xtype
: 'pveBackupView',
199 if (caps
.vms
['VM.Snapshot'] && !template
) {
201 title
: gettext('Snapshots'),
202 iconCls
: 'fa fa-history',
203 xtype
: 'pveQemuSnapshotTree',
208 if (caps
.vms
['VM.Console']) {
211 xtype
: 'pveFirewallRules',
212 title
: gettext('Firewall'),
213 iconCls
: 'fa fa-shield',
215 base_url
: base_url
+ '/firewall/rules',
216 list_refs_url
: base_url
+ '/refs',
220 xtype
: 'pveFirewallOptions',
221 groups
: ['firewall'],
222 iconCls
: 'fa fa-gear',
223 title
: gettext('Options'),
224 base_url
: base_url
+ '/firewall/options',
226 itemId
: 'firewall-options'
229 xtype
: 'pveFirewallAliases',
230 title
: gettext('Alias'),
231 groups
: ['firewall'],
232 iconCls
: 'fa fa-external-link',
233 base_url
: base_url
+ '/firewall/aliases',
234 itemId
: 'firewall-aliases'
238 title
: gettext('IPSet'),
239 groups
: ['firewall'],
240 iconCls
: 'fa fa-list-ol',
241 base_url
: base_url
+ '/firewall/ipset',
242 list_refs_url
: base_url
+ '/refs',
243 itemId
: 'firewall-ipset'
246 title
: gettext('Log'),
247 groups
: ['firewall'],
248 iconCls
: 'fa fa-list',
249 itemId
: 'firewall-fwlog',
251 url
: '/api2/extjs' + base_url
+ '/firewall/log'
256 if (caps
.vms
['Permissions.Modify']) {
259 title
: gettext('Permissions'),
260 iconCls
: 'fa fa-unlock',
261 itemId
: 'permissions',
268 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
274 me
.workspace
.checkVmMigration(me
.pveSelNode
);
275 status
= qmpstatus
= 'unknown';
277 var rec
= s
.data
.get('status');
278 status
= rec
? rec
.data
.value
: 'unknown';
279 rec
= s
.data
.get('qmpstatus');
280 qmpstatus
= rec
? rec
.data
.value
: 'unknown';
281 rec
= s
.data
.get('template');
282 template
= rec
.data
.value
|| false;
284 spice
= s
.data
.get('spice') ? true : false;
288 if (qmpstatus
=== 'prelaunch' || qmpstatus
=== 'paused') {
289 startBtn
.setVisible(false);
290 resumeBtn
.setVisible(true);
292 startBtn
.setVisible(true);
293 resumeBtn
.setVisible(false);
296 consoleBtn
.setEnableSpice(spice
);
298 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
299 resetBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running' || template
);
300 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
301 removeBtn
.setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
302 consoleBtn
.setDisabled(template
);
305 me
.on('afterrender', function() {
306 me
.statusStore
.startUpdate();
309 me
.on('destroy', function() {
310 me
.statusStore
.stopUpdate();