]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/lxc/Config.js
8ef66f399c9882acc3cdfd7f558820ece540b9f1
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
.Utils
.isStandaloneNode(),
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', {
189 canEdit
: !!caps
.vms
['VM.Config.Options'],
191 change: function(tags
) {
192 Proxmox
.Utils
.API2Request({
193 url
: base_url
+ '/config',
198 success: function() {
199 me
.statusStore
.load();
201 failure: function(response
) {
202 Ext
.Msg
.alert('Error', response
.htmlStatus
);
203 me
.statusStore
.load();
210 let vm_text
= `${vm.vmid} (${vm.name})`;
213 title
: Ext
.String
.format(gettext("Container {0} on node '{1}'"), vm_text
, nodename
),
216 tbar
: [statusTxt
, tagsContainer
, '->', startBtn
, shutdownBtn
, migrateBtn
, consoleBtn
, moreBtn
],
217 defaults
: { statusStore
: me
.statusStore
},
220 title
: gettext('Summary'),
221 xtype
: 'pveGuestSummary',
222 iconCls
: 'fa fa-book',
228 if (caps
.vms
['VM.Console'] && !template
) {
231 title
: gettext('Console'),
233 iconCls
: 'fa fa-terminal',
234 xtype
: 'pveNoVncConsole',
245 title
: gettext('Resources'),
247 expandedOnInit
: true,
248 iconCls
: 'fa fa-cube',
249 xtype
: 'pveLxcRessourceView',
252 title
: gettext('Network'),
253 iconCls
: 'fa fa-exchange',
255 xtype
: 'pveLxcNetworkView',
258 title
: gettext('DNS'),
259 iconCls
: 'fa fa-globe',
264 title
: gettext('Options'),
266 iconCls
: 'fa fa-gear',
267 xtype
: 'pveLxcOptions',
270 title
: gettext('Task History'),
272 iconCls
: 'fa fa-list-alt',
273 xtype
: 'proxmoxNodeTasks',
281 if (caps
.vms
['VM.Backup']) {
283 title
: gettext('Backup'),
284 iconCls
: 'fa fa-floppy-o',
285 xtype
: 'pveBackupView',
289 title
: gettext('Replication'),
290 iconCls
: 'fa fa-retweet',
291 xtype
: 'pveReplicaView',
292 itemId
: 'replication',
296 if ((caps
.vms
['VM.Snapshot'] || caps
.vms
['VM.Snapshot.Rollback'] ||
297 caps
.vms
['VM.Audit']) && !template
) {
299 title
: gettext('Snapshots'),
300 iconCls
: 'fa fa-history',
301 xtype
: 'pveGuestSnapshotTree',
307 if (caps
.vms
['VM.Audit']) {
310 xtype
: 'pveFirewallRules',
311 title
: gettext('Firewall'),
312 iconCls
: 'fa fa-shield',
314 base_url
: base_url
+ '/firewall/rules',
315 list_refs_url
: base_url
+ '/firewall/refs',
319 xtype
: 'pveFirewallOptions',
320 groups
: ['firewall'],
321 iconCls
: 'fa fa-gear',
322 onlineHelp
: 'pve_firewall_vm_container_configuration',
323 title
: gettext('Options'),
324 base_url
: base_url
+ '/firewall/options',
326 itemId
: 'firewall-options',
329 xtype
: 'pveFirewallAliases',
330 title
: gettext('Alias'),
331 groups
: ['firewall'],
332 iconCls
: 'fa fa-external-link',
333 base_url
: base_url
+ '/firewall/aliases',
334 itemId
: 'firewall-aliases',
338 title
: gettext('IPSet'),
339 groups
: ['firewall'],
340 iconCls
: 'fa fa-list-ol',
341 base_url
: base_url
+ '/firewall/ipset',
342 list_refs_url
: base_url
+ '/firewall/refs',
343 itemId
: 'firewall-ipset',
348 if (caps
.vms
['VM.Console']) {
351 title
: gettext('Log'),
352 groups
: ['firewall'],
353 iconCls
: 'fa fa-list',
354 onlineHelp
: 'chapter_pve_firewall',
355 itemId
: 'firewall-fwlog',
356 xtype
: 'proxmoxLogView',
357 url
: '/api2/extjs' + base_url
+ '/firewall/log',
358 log_select_timespan
: true,
364 if (caps
.vms
['Permissions.Modify']) {
367 title
: gettext('Permissions'),
368 itemId
: 'permissions',
369 iconCls
: 'fa fa-unlock',
370 path
: '/vms/' + vmid
,
376 var prevStatus
= 'unknown';
377 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
385 rec
= s
.data
.get('status');
386 status
= rec
? rec
.data
.value
: 'unknown';
387 rec
= s
.data
.get('template');
388 template
= rec
? rec
.data
.value
: false;
389 rec
= s
.data
.get('lock');
390 lock
= rec
? rec
.data
.value
: undefined;
393 statusTxt
.update({ lock
: lock
});
395 rec
= s
.data
.get('tags');
396 tagsContainer
.loadTags(rec
?.data
?.value
);
398 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
399 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
400 me
.down('#removeBtn').setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
401 consoleBtn
.setDisabled(template
);
403 if (prevStatus
=== 'stopped' && status
=== 'running') {
404 let con
= me
.down('#consolejs');
413 me
.on('afterrender', function() {
414 me
.statusStore
.startUpdate();
417 me
.on('destroy', function() {
418 me
.statusStore
.stopUpdate();