]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/lxc/Config.js
1 Ext
.define('PVE.lxc.Config', {
2 extend
: 'PVE.panel.Config',
3 alias
: 'widget.PVE.lxc.Config',
5 onlineHelp
: 'chapter_pct',
7 initComponent: function() {
10 var nodename
= me
.pveSelNode
.data
.node
;
12 throw "no node name specified";
15 var vmid
= me
.pveSelNode
.data
.vmid
;
17 throw "no VM ID specified";
20 var template
= !!me
.pveSelNode
.data
.template
;
22 var running
= !!me
.pveSelNode
.data
.uptime
;
24 var caps
= Ext
.state
.Manager
.get('GuiCap');
26 var base_url
= '/nodes/' + nodename
+ '/lxc/' + vmid
;
28 me
.statusStore
= Ext
.create('Proxmox.data.ObjectStore', {
29 url
: '/api2/json' + base_url
+ '/status/current',
33 var vm_command = function(cmd
, params
) {
34 Proxmox
.Utils
.API2Request({
36 url
: base_url
+ "/status/" + cmd
,
39 failure: function(response
, opts
) {
40 Ext
.Msg
.alert('Error', response
.htmlStatus
);
45 var startBtn
= Ext
.create('Ext.Button', {
46 text
: gettext('Start'),
47 disabled
: !caps
.vms
['VM.PowerMgmt'] || running
,
55 var shutdownBtn
= Ext
.create('PVE.button.Split', {
56 text
: gettext('Shutdown'),
57 disabled
: !caps
.vms
['VM.PowerMgmt'] || !running
,
59 confirmMsg
: Proxmox
.Utils
.format_task_description('vzshutdown', vmid
),
61 vm_command('shutdown');
65 text
: gettext('Reboot'),
66 disabled
: !caps
.vms
['VM.PowerMgmt'],
67 confirmMsg
: Proxmox
.Utils
.format_task_description('vzreboot', vmid
),
68 tooltip
: Ext
.String
.format(gettext('Reboot {0}'), 'CT'),
72 iconCls
: 'fa fa-refresh'
75 text
: gettext('Stop'),
76 disabled
: !caps
.vms
['VM.PowerMgmt'],
77 confirmMsg
: Proxmox
.Utils
.format_task_description('vzstop', vmid
),
78 tooltip
: Ext
.String
.format(gettext('Stop {0} immediately'), 'CT'),
86 iconCls
: 'fa fa-power-off'
89 var migrateBtn
= Ext
.create('Ext.Button', {
90 text
: gettext('Migrate'),
91 disabled
: !caps
.vms
['VM.Migrate'],
92 hidden
: PVE
.data
.ResourceStore
.getNodes().length
< 2,
94 var win
= Ext
.create('PVE.window.Migrate', {
101 iconCls
: 'fa fa-send-o'
104 var moreBtn
= Ext
.create('Proxmox.button.Button', {
105 text
: gettext('More'),
108 text
: gettext('Clone'),
109 iconCls
: 'fa fa-fw fa-clone',
110 hidden
: caps
.vms
['VM.Clone'] ? false : true,
111 handler: function() {
112 PVE
.window
.Clone
.wrap(nodename
, vmid
, template
, 'lxc');
116 text
: gettext('Convert to template'),
118 xtype
: 'pveMenuItem',
119 iconCls
: 'fa fa-fw fa-file-o',
120 hidden
: caps
.vms
['VM.Allocate'] ? false : true,
121 confirmMsg
: Proxmox
.Utils
.format_task_description('vztemplate', vmid
),
122 handler: function() {
123 Proxmox
.Utils
.API2Request({
124 url
: base_url
+ '/template',
127 failure: function(response
, opts
) {
128 Ext
.Msg
.alert('Error', response
.htmlStatus
);
134 iconCls
: 'fa fa-heartbeat ',
135 hidden
: !caps
.nodes
['Sys.Console'],
136 text
: gettext('Manage HA'),
137 handler: function() {
138 var ha
= me
.pveSelNode
.data
.hastate
;
139 Ext
.create('PVE.ha.VMResourceEdit', {
142 isCreate
: (!ha
|| ha
=== 'unmanaged')
147 text
: gettext('Remove'),
148 disabled
: !caps
.vms
['VM.Allocate'],
150 handler: function() {
151 Ext
.create('PVE.window.SafeDestroy', {
153 item
: { type
: 'CT', id
: vmid
}
156 iconCls
: 'fa fa-trash-o'
161 var vm
= me
.pveSelNode
.data
;
163 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
164 disabled
: !caps
.vms
['VM.Console'],
166 consoleName
: vm
.name
,
172 var statusTxt
= Ext
.create('Ext.toolbar.TextItem', {
178 '<i class="fa fa-lg fa-lock"></i> ({lock})',
185 title
: Ext
.String
.format(gettext("Container {0} on node '{1}'"), vm
.text
, nodename
),
188 tbar
: [ statusTxt
, '->', startBtn
, shutdownBtn
, migrateBtn
, consoleBtn
, moreBtn
],
189 defaults
: { statusStore
: me
.statusStore
},
192 title
: gettext('Summary'),
193 xtype
: 'pveGuestSummary',
194 iconCls
: 'fa fa-book',
200 if (caps
.vms
['VM.Console'] && !template
) {
203 title
: gettext('Console'),
205 iconCls
: 'fa fa-terminal',
206 xtype
: 'pveNoVncConsole',
217 title
: gettext('Resources'),
219 expandedOnInit
: true,
220 iconCls
: 'fa fa-cube',
221 xtype
: 'pveLxcRessourceView'
224 title
: gettext('Network'),
225 iconCls
: 'fa fa-exchange',
227 xtype
: 'pveLxcNetworkView'
230 title
: gettext('DNS'),
231 iconCls
: 'fa fa-globe',
236 title
: gettext('Options'),
238 iconCls
: 'fa fa-gear',
239 xtype
: 'pveLxcOptions'
242 title
: gettext('Task History'),
244 iconCls
: 'fa fa-list',
245 xtype
: 'proxmoxNodeTasks',
251 if (caps
.vms
['VM.Backup']) {
253 title
: gettext('Backup'),
254 iconCls
: 'fa fa-floppy-o',
255 xtype
: 'pveBackupView',
259 title
: gettext('Replication'),
260 iconCls
: 'fa fa-retweet',
261 xtype
: 'pveReplicaView',
262 itemId
: 'replication'
266 if ((caps
.vms
['VM.Snapshot'] || caps
.vms
['VM.Snapshot.Rollback']) && !template
) {
268 title
: gettext('Snapshots'),
269 iconCls
: 'fa fa-history',
270 xtype
: 'pveLxcSnapshotTree',
275 if (caps
.vms
['VM.Console']) {
278 xtype
: 'pveFirewallRules',
279 title
: gettext('Firewall'),
280 iconCls
: 'fa fa-shield',
282 base_url
: base_url
+ '/firewall/rules',
283 list_refs_url
: base_url
+ '/firewall/refs',
287 xtype
: 'pveFirewallOptions',
288 groups
: ['firewall'],
289 iconCls
: 'fa fa-gear',
290 onlineHelp
: 'pve_firewall_vm_container_configuration',
291 title
: gettext('Options'),
292 base_url
: base_url
+ '/firewall/options',
294 itemId
: 'firewall-options'
297 xtype
: 'pveFirewallAliases',
298 title
: gettext('Alias'),
299 groups
: ['firewall'],
300 iconCls
: 'fa fa-external-link',
301 base_url
: base_url
+ '/firewall/aliases',
302 itemId
: 'firewall-aliases'
306 title
: gettext('IPSet'),
307 groups
: ['firewall'],
308 iconCls
: 'fa fa-list-ol',
309 base_url
: base_url
+ '/firewall/ipset',
310 list_refs_url
: base_url
+ '/firewall/refs',
311 itemId
: 'firewall-ipset'
314 title
: gettext('Log'),
315 groups
: ['firewall'],
316 iconCls
: 'fa fa-list',
317 onlineHelp
: 'chapter_pve_firewall',
318 itemId
: 'firewall-fwlog',
319 xtype
: 'proxmoxLogView',
320 url
: '/api2/extjs' + base_url
+ '/firewall/log'
325 if (caps
.vms
['Permissions.Modify']) {
328 title
: gettext('Permissions'),
329 itemId
: 'permissions',
330 iconCls
: 'fa fa-unlock',
337 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
343 var rec
= s
.data
.get('status');
344 status
= rec
? rec
.data
.value
: 'unknown';
345 rec
= s
.data
.get('template');
346 template
= rec
.data
.value
|| false;
347 rec
= s
.data
.get('lock');
348 lock
= rec
? rec
.data
.value
: undefined;
351 statusTxt
.update({ lock
: lock
});
353 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
354 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
355 me
.down('#removeBtn').setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
356 consoleBtn
.setDisabled(template
);
359 me
.on('afterrender', function() {
360 me
.statusStore
.startUpdate();
363 me
.on('destroy', function() {
364 me
.statusStore
.stopUpdate();