]>
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.pveLXCConfig',
5 onlineHelp
: 'chapter_pct',
7 userCls
: 'proxmox-tags-full',
9 initComponent: function() {
11 var vm
= me
.pveSelNode
.data
;
13 var nodename
= vm
.node
;
15 throw "no node name specified";
20 throw "no VM ID specified";
23 var template
= !!vm
.template
;
25 var running
= !!vm
.uptime
;
27 var caps
= Ext
.state
.Manager
.get('GuiCap');
29 var base_url
= '/nodes/' + nodename
+ '/lxc/' + vmid
;
31 me
.statusStore
= Ext
.create('Proxmox.data.ObjectStore', {
32 url
: '/api2/json' + base_url
+ '/status/current',
36 var vm_command = function(cmd
, params
) {
37 Proxmox
.Utils
.API2Request({
39 url
: base_url
+ "/status/" + cmd
,
42 failure: function(response
, opts
) {
43 Ext
.Msg
.alert('Error', response
.htmlStatus
);
48 var startBtn
= Ext
.create('Ext.Button', {
49 text
: gettext('Start'),
50 disabled
: !caps
.vms
['VM.PowerMgmt'] || running
,
55 iconCls
: 'fa fa-play',
58 var shutdownBtn
= Ext
.create('PVE.button.Split', {
59 text
: gettext('Shutdown'),
60 disabled
: !caps
.vms
['VM.PowerMgmt'] || !running
,
62 confirmMsg
: Proxmox
.Utils
.format_task_description('vzshutdown', vmid
),
64 vm_command('shutdown');
68 text
: gettext('Reboot'),
69 disabled
: !caps
.vms
['VM.PowerMgmt'],
70 confirmMsg
: Proxmox
.Utils
.format_task_description('vzreboot', vmid
),
71 tooltip
: Ext
.String
.format(gettext('Reboot {0}'), 'CT'),
75 iconCls
: 'fa fa-refresh',
78 text
: gettext('Stop'),
79 disabled
: !caps
.vms
['VM.PowerMgmt'],
80 confirmMsg
: Proxmox
.Utils
.format_task_description('vzstop', vmid
),
81 tooltip
: Ext
.String
.format(gettext('Stop {0} immediately'), 'CT'),
86 iconCls
: 'fa fa-stop',
89 iconCls
: 'fa fa-power-off',
92 var migrateBtn
= Ext
.create('Ext.Button', {
93 text
: gettext('Migrate'),
94 disabled
: !caps
.vms
['VM.Migrate'],
95 hidden
: PVE
.data
.ResourceStore
.getNodes().length
< 2,
97 var win
= Ext
.create('PVE.window.Migrate', {
104 iconCls
: 'fa fa-send-o',
107 var moreBtn
= Ext
.create('Proxmox.button.Button', {
108 text
: gettext('More'),
112 text
: gettext('Clone'),
113 iconCls
: 'fa fa-fw fa-clone',
114 hidden
: !caps
.vms
['VM.Clone'],
115 handler: function() {
116 PVE
.window
.Clone
.wrap(nodename
, vmid
, template
, 'lxc');
120 text
: gettext('Convert to template'),
122 xtype
: 'pveMenuItem',
123 iconCls
: 'fa fa-fw fa-file-o',
124 hidden
: !caps
.vms
['VM.Allocate'],
125 confirmMsg
: Proxmox
.Utils
.format_task_description('vztemplate', vmid
),
126 handler: function() {
127 Proxmox
.Utils
.API2Request({
128 url
: base_url
+ '/template',
131 failure: function(response
, opts
) {
132 Ext
.Msg
.alert('Error', response
.htmlStatus
);
138 iconCls
: 'fa fa-heartbeat ',
139 hidden
: !caps
.nodes
['Sys.Console'],
140 text
: gettext('Manage HA'),
141 handler: function() {
143 Ext
.create('PVE.ha.VMResourceEdit', {
146 isCreate
: !ha
|| ha
=== 'unmanaged',
151 text
: gettext('Remove'),
152 disabled
: !caps
.vms
['VM.Allocate'],
154 handler: function() {
155 Ext
.create('PVE.window.SafeDestroyGuest', {
157 item
: { type
: 'CT', id
: vmid
},
158 taskName
: 'vzdestroy',
161 iconCls
: 'fa fa-trash-o',
167 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
168 disabled
: !caps
.vms
['VM.Console'],
170 consoleName
: vm
.name
,
176 var statusTxt
= Ext
.create('Ext.toolbar.TextItem', {
182 '<i class="fa fa-lg fa-lock"></i> ({lock})',
187 let tagsContainer
= Ext
.create('PVE.panel.TagEditContainer', {
190 change: function(tags
) {
191 Proxmox
.Utils
.API2Request({
192 url
: base_url
+ '/config',
197 success: function() {
198 me
.statusStore
.load();
200 failure: function(response
) {
201 Ext
.Msg
.alert('Error', response
.htmlStatus
);
202 me
.statusStore
.load();
210 title
: Ext
.String
.format(gettext("Container {0} on node '{1}'"), vm
.text
, nodename
),
213 tbar
: [statusTxt
, tagsContainer
, '->', startBtn
, shutdownBtn
, migrateBtn
, consoleBtn
, moreBtn
],
214 defaults
: { statusStore
: me
.statusStore
},
217 title
: gettext('Summary'),
218 xtype
: 'pveGuestSummary',
219 iconCls
: 'fa fa-book',
225 if (caps
.vms
['VM.Console'] && !template
) {
228 title
: gettext('Console'),
230 iconCls
: 'fa fa-terminal',
231 xtype
: 'pveNoVncConsole',
242 title
: gettext('Resources'),
244 expandedOnInit
: true,
245 iconCls
: 'fa fa-cube',
246 xtype
: 'pveLxcRessourceView',
249 title
: gettext('Network'),
250 iconCls
: 'fa fa-exchange',
252 xtype
: 'pveLxcNetworkView',
255 title
: gettext('DNS'),
256 iconCls
: 'fa fa-globe',
261 title
: gettext('Options'),
263 iconCls
: 'fa fa-gear',
264 xtype
: 'pveLxcOptions',
267 title
: gettext('Task History'),
269 iconCls
: 'fa fa-list-alt',
270 xtype
: 'proxmoxNodeTasks',
278 if (caps
.vms
['VM.Backup']) {
280 title
: gettext('Backup'),
281 iconCls
: 'fa fa-floppy-o',
282 xtype
: 'pveBackupView',
286 title
: gettext('Replication'),
287 iconCls
: 'fa fa-retweet',
288 xtype
: 'pveReplicaView',
289 itemId
: 'replication',
293 if ((caps
.vms
['VM.Snapshot'] || caps
.vms
['VM.Snapshot.Rollback'] ||
294 caps
.vms
['VM.Audit']) && !template
) {
296 title
: gettext('Snapshots'),
297 iconCls
: 'fa fa-history',
298 xtype
: 'pveGuestSnapshotTree',
304 if (caps
.vms
['VM.Console']) {
307 xtype
: 'pveFirewallRules',
308 title
: gettext('Firewall'),
309 iconCls
: 'fa fa-shield',
311 base_url
: base_url
+ '/firewall/rules',
312 list_refs_url
: base_url
+ '/firewall/refs',
316 xtype
: 'pveFirewallOptions',
317 groups
: ['firewall'],
318 iconCls
: 'fa fa-gear',
319 onlineHelp
: 'pve_firewall_vm_container_configuration',
320 title
: gettext('Options'),
321 base_url
: base_url
+ '/firewall/options',
323 itemId
: 'firewall-options',
326 xtype
: 'pveFirewallAliases',
327 title
: gettext('Alias'),
328 groups
: ['firewall'],
329 iconCls
: 'fa fa-external-link',
330 base_url
: base_url
+ '/firewall/aliases',
331 itemId
: 'firewall-aliases',
335 title
: gettext('IPSet'),
336 groups
: ['firewall'],
337 iconCls
: 'fa fa-list-ol',
338 base_url
: base_url
+ '/firewall/ipset',
339 list_refs_url
: base_url
+ '/firewall/refs',
340 itemId
: 'firewall-ipset',
343 title
: gettext('Log'),
344 groups
: ['firewall'],
345 iconCls
: 'fa fa-list',
346 onlineHelp
: 'chapter_pve_firewall',
347 itemId
: 'firewall-fwlog',
348 xtype
: 'proxmoxLogView',
349 url
: '/api2/extjs' + base_url
+ '/firewall/log',
354 if (caps
.vms
['Permissions.Modify']) {
357 title
: gettext('Permissions'),
358 itemId
: 'permissions',
359 iconCls
: 'fa fa-unlock',
360 path
: '/vms/' + vmid
,
366 var prevStatus
= 'unknown';
367 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
375 rec
= s
.data
.get('status');
376 status
= rec
? rec
.data
.value
: 'unknown';
377 rec
= s
.data
.get('template');
378 template
= rec
? rec
.data
.value
: false;
379 rec
= s
.data
.get('lock');
380 lock
= rec
? rec
.data
.value
: undefined;
383 statusTxt
.update({ lock
: lock
});
385 rec
= s
.data
.get('tags');
386 tagsContainer
.loadTags(rec
?.data
?.value
);
388 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
389 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
390 me
.down('#removeBtn').setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
391 consoleBtn
.setDisabled(template
);
393 if (prevStatus
=== 'stopped' && status
=== 'running') {
394 let con
= me
.down('#consolejs');
403 me
.on('afterrender', function() {
404 me
.statusStore
.startUpdate();
407 me
.on('destroy', function() {
408 me
.statusStore
.stopUpdate();