]>
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
) {
50 me
.title
= "VM " + vmid
;
54 text
: gettext('Start'),
55 iconCls
: 'fa fa-fw fa-play',
56 disabled
: running
|| suspended
,
62 text
: gettext('Suspend'),
63 iconCls
: 'fa fa-fw fa-pause',
65 disabled
: stopped
|| suspended
,
67 var msg
= Proxmox
.Utils
.format_task_description('qmsuspend', vmid
);
68 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
72 vm_command('suspend');
77 text
: gettext('Resume'),
78 iconCls
: 'fa fa-fw fa-play',
85 text
: gettext('Shutdown'),
86 iconCls
: 'fa fa-fw fa-power-off',
87 disabled
: stopped
|| suspended
,
89 var msg
= Proxmox
.Utils
.format_task_description('qmshutdown', vmid
);
90 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
95 vm_command('shutdown');
100 text
: gettext('Stop'),
101 iconCls
: 'fa fa-fw fa-stop',
103 handler: function() {
104 var msg
= Proxmox
.Utils
.format_task_description('qmstop', vmid
);
105 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
115 xtype
: 'menuseparator',
116 hidden
: (standalone
|| !caps
.vms
['VM.Migrate']) && !caps
.vms
['VM.Allocate'] && !caps
.vms
['VM.Clone']
119 text
: gettext('Migrate'),
120 iconCls
: 'fa fa-fw fa-send-o',
121 hidden
: standalone
|| !caps
.vms
['VM.Migrate'],
122 handler: function() {
123 var win
= Ext
.create('PVE.window.Migrate', {
132 text
: gettext('Clone'),
133 iconCls
: 'fa fa-fw fa-clone',
134 hidden
: !caps
.vms
['VM.Clone'],
135 handler: function() {
136 PVE
.window
.Clone
.wrap(nodename
, vmid
, me
.isTemplate
, 'qemu');
140 text
: gettext('Convert to template'),
141 iconCls
: 'fa fa-fw fa-file-o',
142 hidden
: !caps
.vms
['VM.Allocate'],
143 handler: function() {
144 var msg
= Proxmox
.Utils
.format_task_description('qmtemplate', vmid
);
145 Ext
.Msg
.confirm(gettext('Confirm'), msg
, function(btn
) {
150 Proxmox
.Utils
.API2Request({
151 url
: '/nodes/' + nodename
+ '/qemu/' + vmid
+ '/template',
153 failure: function(response
, opts
) {
154 Ext
.Msg
.alert('Error', response
.htmlStatus
);
160 { xtype
: 'menuseparator' },
162 text
: gettext('Console'),
163 iconCls
: 'fa fa-fw fa-terminal',
164 handler: function() {
165 Proxmox
.Utils
.API2Request({
166 url
: '/nodes/' + nodename
+ '/qemu/' + vmid
+ '/status/current',
167 failure: function(response
, opts
) {
168 Ext
.Msg
.alert('Error', response
.htmlStatus
);
170 success: function(response
, opts
) {
171 var allowSpice
= response
.result
.data
.spice
;
172 var allowXtermjs
= response
.result
.data
.serial
;
175 xtermjs
: allowXtermjs
177 PVE
.Utils
.openDefaultConsoleWindow(consoles
, 'kvm', vmid
, nodename
, vmname
);