]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/Config.js
70734a7d9ba0a8413ee3dae779f3368057d333f3
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'],
50 var startBtn
= Ext
.create('Ext.Button', {
51 text
: gettext('Start'),
52 disabled
: !caps
.vms
['VM.PowerMgmt'],
58 var stopBtn
= Ext
.create('PVE.button.Button', {
59 text
: gettext('Stop'),
60 disabled
: !caps
.vms
['VM.PowerMgmt'],
61 confirmMsg
: Ext
.String
.format(gettext("Do you really want to stop VM {0}?"), vmid
),
63 vm_command("stop", { timeout
: 30 });
67 var migrateBtn
= Ext
.create('Ext.Button', {
68 text
: gettext('Migrate'),
69 disabled
: !caps
.vms
['VM.Migrate'],
71 var win
= Ext
.create('PVE.window.Migrate', {
80 var resetBtn
= Ext
.create('PVE.button.Button', {
81 text
: gettext('Reset'),
82 disabled
: !caps
.vms
['VM.PowerMgmt'],
83 confirmMsg
: Ext
.String
.format(gettext("Do you really want to reset VM {0}?"), vmid
),
89 var shutdownBtn
= Ext
.create('PVE.button.Button', {
90 text
: gettext('Shutdown'),
91 disabled
: !caps
.vms
['VM.PowerMgmt'],
92 confirmMsg
: Ext
.String
.format(gettext("Do you really want to shutdown VM {0}?"), vmid
),
94 vm_command('shutdown');
98 var removeBtn
= Ext
.create('PVE.button.Button', {
99 text
: gettext('Remove'),
100 disabled
: !caps
.vms
['VM.Allocate'],
102 confirmMsg
: Ext
.String
.format(gettext('Are you sure you want to remove VM {0}? This will permanently erase all VM data.'), vmid
),
103 handler: function() {
104 PVE
.Utils
.API2Request({
108 failure: function(response
, opts
) {
109 Ext
.Msg
.alert('Error', response
.htmlStatus
);
115 var vmname
= me
.pveSelNode
.data
.name
;
117 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
118 disabled
: !caps
.vms
['VM.Console'],
125 var descr
= vmid
+ " (" + (vmname
? "'" + vmname
+ "' " : "'VM " + vmid
+ "'") + ")";
128 title
: Ext
.String
.format(gettext("Virtual Machine {0} on node {1}"), descr
, "'" + nodename
+ "'"),
130 tbar
: [ resumeBtn
, startBtn
, shutdownBtn
, stopBtn
, resetBtn
,
131 removeBtn
, migrateBtn
, consoleBtn
],
132 defaults
: { statusStore
: me
.statusStore
},
135 title
: gettext('Summary'),
136 xtype
: 'pveQemuSummary',
140 title
: gettext('Hardware'),
142 xtype
: 'PVE.qemu.HardwareView'
145 title
: gettext('Options'),
147 xtype
: 'PVE.qemu.Options'
150 title
: gettext('Task History'),
152 xtype
: 'pveNodeTasks',
158 if (caps.vms['VM.Monitor'] && !template) {
160 title: gettext('Monitor'),
162 xtype: 'pveQemuMonitor'
166 if (caps.vms['VM.Backup']) {
168 title: gettext('Backup'),
169 xtype: 'pveBackupView',
174 if (caps.vms['VM.Snapshot']) {
176 title: gettext('Snapshots'),
177 xtype: 'pveQemuSnapshotTree',
182 if (caps.vms['VM.Console'] && !template) {
184 title: gettext('Console'),
186 xtype: 'pveNoVncConsole',
193 if (caps.vms['VM.Console']) {
196 xtype: 'pveFirewallPanel',
197 title: gettext('Firewall'),
198 base_url: base_url + '/firewall',
200 phstateid: me.hstateid,
206 if (caps.vms['Permissions.Modify']) {
209 title: gettext('Permissions'),
210 itemId: 'permissions',
217 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
223 me
.workspace
.checkVmMigration(me
.pveSelNode
);
224 status
= qmpstatus
= 'unknown';
226 var rec
= s
.data
.get('status');
227 status
= rec
? rec
.data
.value
: 'unknown';
228 rec
= s
.data
.get('qmpstatus');
229 qmpstatus
= rec
? rec
.data
.value
: 'unknown';
230 rec
= s
.data
.get('template');
232 template
= rec
.data
.value
;
234 spice
= s
.data
.get('spice') ? true : false;
238 if (qmpstatus
=== 'prelaunch' || qmpstatus
=== 'paused') {
239 startBtn
.setVisible(false);
240 resumeBtn
.setVisible(true);
242 startBtn
.setVisible(true);
243 resumeBtn
.setVisible(false);
246 consoleBtn
.setEnableSpice(spice
);
248 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
249 resetBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running' || template
);
250 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
251 stopBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'stopped');
252 removeBtn
.setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
255 me
.on('afterrender', function() {
256 me
.statusStore
.startUpdate();
259 me
.on('destroy', function() {
260 me
.statusStore
.stopUpdate();