]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/CmdMenu.js
1 Ext
.define('PVE.qemu.CmdMenu', {
2 extend
: 'Ext.menu.Menu',
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 vmname
= me
.pveSelNode
.data
.name
;
20 var vm_command = function(cmd
, params
) {
21 Proxmox
.Utils
.API2Request({
23 url
: '/nodes/' + nodename
+ '/qemu/' + vmid
+ "/status/" + cmd
,
25 failure: function(response
, opts
) {
26 Ext
.Msg
.alert('Error', response
.htmlStatus
);
31 var caps
= Ext
.state
.Manager
.get('GuiCap');
35 var suspended
= false;
36 var standalone
= PVE
.data
.ResourceStore
.getNodes().length
< 2;
38 switch (me
.pveSelNode
.data
.status
) {
54 me
.title
= "VM " + vmid
;
58 text
: gettext('Start'),
59 iconCls
: 'fa fa-fw fa-play',
60 hidden
: running
|| suspended
,
61 disabled
: running
|| suspended
,
67 text
: gettext('Pause'),
68 iconCls
: 'fa fa-fw fa-pause',
69 hidden
: stopped
|| suspended
,
70 disabled
: stopped
|| suspended
,
72 var msg
= Proxmox
.Utils
.format_task_description('qmpause', vmid
);
73 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
77 vm_command('suspend');
82 text
: gettext('Hibernate'),
83 iconCls
: 'fa fa-fw fa-stop',
84 hidden
: stopped
|| suspended
,
85 disabled
: stopped
|| suspended
,
86 tooltip
: gettext('Suspend to disk'),
88 var msg
= Proxmox
.Utils
.format_task_description('qmsuspend', vmid
);
89 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
93 vm_command('suspend', { todisk
: 1 });
98 text
: gettext('Resume'),
99 iconCls
: 'fa fa-fw fa-play',
101 handler: function() {
102 vm_command('resume');
106 text
: gettext('Shutdown'),
107 iconCls
: 'fa fa-fw fa-power-off',
108 disabled
: stopped
|| suspended
,
109 handler: function() {
110 var msg
= Proxmox
.Utils
.format_task_description('qmshutdown', vmid
);
111 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
116 vm_command('shutdown');
121 text
: gettext('Stop'),
122 iconCls
: 'fa fa-fw fa-stop',
124 tooltip
: Ext
.String
.format(gettext('Stop {0} immediately'), 'VM'),
125 handler: function() {
126 var msg
= Proxmox
.Utils
.format_task_description('qmstop', vmid
);
127 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
137 xtype
: 'menuseparator',
138 hidden
: (standalone
|| !caps
.vms
['VM.Migrate']) && !caps
.vms
['VM.Allocate'] && !caps
.vms
['VM.Clone']
141 text
: gettext('Migrate'),
142 iconCls
: 'fa fa-fw fa-send-o',
143 hidden
: standalone
|| !caps
.vms
['VM.Migrate'],
144 handler: function() {
145 var win
= Ext
.create('PVE.window.Migrate', {
154 text
: gettext('Clone'),
155 iconCls
: 'fa fa-fw fa-clone',
156 hidden
: !caps
.vms
['VM.Clone'],
157 handler: function() {
158 PVE
.window
.Clone
.wrap(nodename
, vmid
, me
.isTemplate
, 'qemu');
162 text
: gettext('Convert to template'),
163 iconCls
: 'fa fa-fw fa-file-o',
164 hidden
: !caps
.vms
['VM.Allocate'],
165 handler: function() {
166 var msg
= Proxmox
.Utils
.format_task_description('qmtemplate', vmid
);
167 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
172 Proxmox
.Utils
.API2Request({
173 url
: '/nodes/' + nodename
+ '/qemu/' + vmid
+ '/template',
175 failure: function(response
, opts
) {
176 Ext
.Msg
.alert('Error', response
.htmlStatus
);
182 { xtype
: 'menuseparator' },
184 text
: gettext('Console'),
185 iconCls
: 'fa fa-fw fa-terminal',
186 handler: function() {
187 Proxmox
.Utils
.API2Request({
188 url
: '/nodes/' + nodename
+ '/qemu/' + vmid
+ '/status/current',
189 failure: function(response
, opts
) {
190 Ext
.Msg
.alert('Error', response
.htmlStatus
);
192 success: function(response
, opts
) {
193 var allowSpice
= response
.result
.data
.spice
;
194 var allowXtermjs
= response
.result
.data
.serial
;
197 xtermjs
: allowXtermjs
199 PVE
.Utils
.openDefaultConsoleWindow(consoles
, 'kvm', vmid
, nodename
, vmname
);