]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/qemu/CmdMenu.js
df7b593d567b11784191345d695f24fb9232ae94
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('Resume'),
83 iconCls
: 'fa fa-fw fa-play',
90 text
: gettext('Shutdown'),
91 iconCls
: 'fa fa-fw fa-power-off',
92 disabled
: stopped
|| suspended
,
94 var msg
= Proxmox
.Utils
.format_task_description('qmshutdown', vmid
);
95 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
100 vm_command('shutdown');
105 text
: gettext('Stop'),
106 iconCls
: 'fa fa-fw fa-stop',
108 handler: function() {
109 var msg
= Proxmox
.Utils
.format_task_description('qmstop', vmid
);
110 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
120 xtype
: 'menuseparator',
121 hidden
: (standalone
|| !caps
.vms
['VM.Migrate']) && !caps
.vms
['VM.Allocate'] && !caps
.vms
['VM.Clone']
124 text
: gettext('Migrate'),
125 iconCls
: 'fa fa-fw fa-send-o',
126 hidden
: standalone
|| !caps
.vms
['VM.Migrate'],
127 handler: function() {
128 var win
= Ext
.create('PVE.window.Migrate', {
137 text
: gettext('Clone'),
138 iconCls
: 'fa fa-fw fa-clone',
139 hidden
: !caps
.vms
['VM.Clone'],
140 handler: function() {
141 PVE
.window
.Clone
.wrap(nodename
, vmid
, me
.isTemplate
, 'qemu');
145 text
: gettext('Convert to template'),
146 iconCls
: 'fa fa-fw fa-file-o',
147 hidden
: !caps
.vms
['VM.Allocate'],
148 handler: function() {
149 var msg
= Proxmox
.Utils
.format_task_description('qmtemplate', vmid
);
150 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
155 Proxmox
.Utils
.API2Request({
156 url
: '/nodes/' + nodename
+ '/qemu/' + vmid
+ '/template',
158 failure: function(response
, opts
) {
159 Ext
.Msg
.alert('Error', response
.htmlStatus
);
165 { xtype
: 'menuseparator' },
167 text
: gettext('Console'),
168 iconCls
: 'fa fa-fw fa-terminal',
169 handler: function() {
170 Proxmox
.Utils
.API2Request({
171 url
: '/nodes/' + nodename
+ '/qemu/' + vmid
+ '/status/current',
172 failure: function(response
, opts
) {
173 Ext
.Msg
.alert('Error', response
.htmlStatus
);
175 success: function(response
, opts
) {
176 var allowSpice
= response
.result
.data
.spice
;
177 var allowXtermjs
= response
.result
.data
.serial
;
180 xtermjs
: allowXtermjs
182 PVE
.Utils
.openDefaultConsoleWindow(consoles
, 'kvm', vmid
, nodename
, vmname
);