]>
git.proxmox.com Git - pve-manager.git/blob - www/manager/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 caps
= Ext
.state
.Manager
.get('GuiCap');
20 me
.statusStore
= Ext
.create('PVE.data.ObjectStore', {
21 url
: "/api2/json/nodes/" + nodename
+ "/qemu/" + vmid
+ "/status/current",
25 var vm_command = function(cmd
, params
) {
26 PVE
.Utils
.API2Request({
28 url
: '/nodes/' + nodename
+ '/qemu/' + vmid
+ "/status/" + cmd
,
31 failure: function(response
, opts
) {
32 Ext
.Msg
.alert('Error', response
.htmlStatus
);
37 var startBtn
= Ext
.create('Ext.Button', {
38 text
: gettext('Start'),
39 disabled
: !caps
.vms
['VM.PowerMgmt'],
45 var stopBtn
= Ext
.create('PVE.button.Button', {
46 text
: gettext('Stop'),
47 disabled
: !caps
.vms
['VM.PowerMgmt'],
48 confirmMsg
: Ext
.String
.format(gettext("Do you really want to stop VM {0}?"), vmid
),
50 vm_command("stop", { timeout
: 30 });
54 var migrateBtn
= Ext
.create('Ext.Button', {
55 text
: gettext('Migrate'),
56 disabled
: !caps
.vms
['VM.Migrate'],
58 var win
= Ext
.create('PVE.window.Migrate', {
67 var resetBtn
= Ext
.create('PVE.button.Button', {
68 text
: gettext('Reset'),
69 disabled
: !caps
.vms
['VM.PowerMgmt'],
70 confirmMsg
: Ext
.String
.format(gettext("Do you really want to reset VM {0}?"), vmid
),
76 var shutdownBtn
= Ext
.create('PVE.button.Button', {
77 text
: gettext('Shutdown'),
78 disabled
: !caps
.vms
['VM.PowerMgmt'],
79 confirmMsg
: Ext
.String
.format(gettext("Do you really want to shutdown VM {0}?"), vmid
),
81 vm_command('shutdown', { timeout
: 30 });
85 var removeBtn
= Ext
.create('PVE.button.Button', {
86 text
: gettext('Remove'),
87 disabled
: !caps
.vms
['VM.Allocate'],
88 confirmMsg
: Ext
.String
.format(gettext('Are you sure you want to remove VM {0}? This will permanently erase all VM data.'), vmid
),
90 PVE
.Utils
.API2Request({
91 url
: '/nodes/' + nodename
+ '/qemu/' + vmid
,
94 failure: function(response
, opts
) {
95 Ext
.Msg
.alert('Error', response
.htmlStatus
);
101 var vmname
= me
.pveSelNode
.data
.name
;
103 var consoleBtn
= Ext
.create('Ext.Button', {
104 text
: gettext('Console'),
105 disabled
: !caps
.vms
['VM.Console'],
106 handler: function() {
107 PVE
.Utils
.openConoleWindow('kvm', vmid
, nodename
, vmname
);
111 var descr
= vmid
+ " (" + (vmname
? "'" + vmname
+ "' " : "'VM " + vmid
+ "'") + ")";
114 title
: Ext
.String
.format(gettext("Virtual Machine {0} on node {1}"), descr
, "'" + nodename
+ "'"),
116 tbar
: [ startBtn
, shutdownBtn
, stopBtn
, resetBtn
,
117 removeBtn
, migrateBtn
, consoleBtn
],
118 defaults
: { statusStore
: me
.statusStore
},
121 title
: gettext('Summary'),
122 xtype
: 'pveQemuSummary',
126 title
: gettext('Hardware'),
128 xtype
: 'PVE.qemu.HardwareView'
131 title
: gettext('Options'),
133 xtype
: 'PVE.qemu.Options'
138 if (caps
.vms
['VM.Monitor']) {
140 title
: gettext('Monitor'),
142 xtype
: 'pveQemuMonitor'
146 if (caps
.vms
['VM.Backup']) {
148 title
: gettext('Backup'),
149 xtype
: 'pveBackupView',
154 if (caps
.vms
['Permissions.Modify']) {
157 title
: gettext('Permissions'),
158 itemId
: 'permissions',
165 me
.statusStore
.on('load', function(s
, records
, success
) {
168 me
.workspace
.checkVmMigration(me
.pveSelNode
);
171 var rec
= s
.data
.get('status');
172 status
= rec
? rec
.data
.value
: 'unknown';
175 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running');
176 resetBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
177 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
178 stopBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'stopped');
179 removeBtn
.setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
182 me
.on('afterrender', function() {
183 me
.statusStore
.startUpdate();
186 me
.on('destroy', function() {
187 me
.statusStore
.stopUpdate();