]>
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() {
9 var vm
= me
.pveSelNode
.data
;
11 var nodename
= vm
.node
;
13 throw "no node name specified";
18 throw "no VM ID specified";
21 var template
= !!vm
.template
;
23 var running
= !!vm
.uptime
;
25 var caps
= Ext
.state
.Manager
.get('GuiCap');
27 var base_url
= '/nodes/' + nodename
+ '/lxc/' + vmid
;
29 me
.statusStore
= Ext
.create('Proxmox.data.ObjectStore', {
30 url
: '/api2/json' + base_url
+ '/status/current',
34 var vm_command = function(cmd
, params
) {
35 Proxmox
.Utils
.API2Request({
37 url
: base_url
+ "/status/" + cmd
,
40 failure: function(response
, opts
) {
41 Ext
.Msg
.alert('Error', response
.htmlStatus
);
46 var startBtn
= Ext
.create('Ext.Button', {
47 text
: gettext('Start'),
48 disabled
: !caps
.vms
['VM.PowerMgmt'] || running
,
53 iconCls
: 'fa fa-play',
56 var shutdownBtn
= Ext
.create('PVE.button.Split', {
57 text
: gettext('Shutdown'),
58 disabled
: !caps
.vms
['VM.PowerMgmt'] || !running
,
60 confirmMsg
: Proxmox
.Utils
.format_task_description('vzshutdown', vmid
),
62 vm_command('shutdown');
66 text
: gettext('Reboot'),
67 disabled
: !caps
.vms
['VM.PowerMgmt'],
68 confirmMsg
: Proxmox
.Utils
.format_task_description('vzreboot', vmid
),
69 tooltip
: Ext
.String
.format(gettext('Reboot {0}'), 'CT'),
73 iconCls
: 'fa fa-refresh',
76 text
: gettext('Stop'),
77 disabled
: !caps
.vms
['VM.PowerMgmt'],
78 confirmMsg
: Proxmox
.Utils
.format_task_description('vzstop', vmid
),
79 tooltip
: Ext
.String
.format(gettext('Stop {0} immediately'), 'CT'),
84 iconCls
: 'fa fa-stop',
87 iconCls
: 'fa fa-power-off',
90 var migrateBtn
= Ext
.create('Ext.Button', {
91 text
: gettext('Migrate'),
92 disabled
: !caps
.vms
['VM.Migrate'],
93 hidden
: PVE
.data
.ResourceStore
.getNodes().length
< 2,
95 var win
= Ext
.create('PVE.window.Migrate', {
102 iconCls
: 'fa fa-send-o',
105 var moreBtn
= Ext
.create('Proxmox.button.Button', {
106 text
: gettext('More'),
110 text
: gettext('Clone'),
111 iconCls
: 'fa fa-fw fa-clone',
112 hidden
: !caps
.vms
['VM.Clone'],
113 handler: function() {
114 PVE
.window
.Clone
.wrap(nodename
, vmid
, template
, 'lxc');
118 text
: gettext('Convert to template'),
120 xtype
: 'pveMenuItem',
121 iconCls
: 'fa fa-fw fa-file-o',
122 hidden
: !caps
.vms
['VM.Allocate'],
123 confirmMsg
: Proxmox
.Utils
.format_task_description('vztemplate', vmid
),
124 handler: function() {
125 Proxmox
.Utils
.API2Request({
126 url
: base_url
+ '/template',
129 failure: function(response
, opts
) {
130 Ext
.Msg
.alert('Error', response
.htmlStatus
);
136 iconCls
: 'fa fa-heartbeat ',
137 hidden
: !caps
.nodes
['Sys.Console'],
138 text
: gettext('Manage HA'),
139 handler: function() {
141 Ext
.create('PVE.ha.VMResourceEdit', {
144 isCreate
: !ha
|| ha
=== 'unmanaged',
149 text
: gettext('Remove'),
150 disabled
: !caps
.vms
['VM.Allocate'],
152 handler: function() {
153 Ext
.create('PVE.window.SafeDestroy', {
155 item
: { type
: 'CT', id
: vmid
},
158 iconCls
: 'fa fa-trash-o',
164 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
165 disabled
: !caps
.vms
['VM.Console'],
167 consoleName
: vm
.name
,
173 var statusTxt
= Ext
.create('Ext.toolbar.TextItem', {
179 '<i class="fa fa-lg fa-lock"></i> ({lock})',
186 title
: Ext
.String
.format(gettext("Container {0} on node '{1}'"), vm
.text
, nodename
),
189 tbar
: [statusTxt
, '->', startBtn
, shutdownBtn
, migrateBtn
, consoleBtn
, moreBtn
],
190 defaults
: { statusStore
: me
.statusStore
},
193 title
: gettext('Summary'),
194 xtype
: 'pveGuestSummary',
195 iconCls
: 'fa fa-book',
201 if (caps
.vms
['VM.Console'] && !template
) {
204 title
: gettext('Console'),
206 iconCls
: 'fa fa-terminal',
207 xtype
: 'pveNoVncConsole',
218 title
: gettext('Resources'),
220 expandedOnInit
: true,
221 iconCls
: 'fa fa-cube',
222 xtype
: 'pveLxcRessourceView',
225 title
: gettext('Network'),
226 iconCls
: 'fa fa-exchange',
228 xtype
: 'pveLxcNetworkView',
231 title
: gettext('DNS'),
232 iconCls
: 'fa fa-globe',
237 title
: gettext('Options'),
239 iconCls
: 'fa fa-gear',
240 xtype
: 'pveLxcOptions',
243 title
: gettext('Task History'),
245 iconCls
: 'fa fa-list',
246 xtype
: 'proxmoxNodeTasks',
252 if (caps
.vms
['VM.Backup']) {
254 title
: gettext('Backup'),
255 iconCls
: 'fa fa-floppy-o',
256 xtype
: 'pveBackupView',
260 title
: gettext('Replication'),
261 iconCls
: 'fa fa-retweet',
262 xtype
: 'pveReplicaView',
263 itemId
: 'replication',
267 if ((caps
.vms
['VM.Snapshot'] || caps
.vms
['VM.Snapshot.Rollback'] ||
268 caps
.vms
['VM.Audit']) && !template
) {
270 title
: gettext('Snapshots'),
271 iconCls
: 'fa fa-history',
272 xtype
: 'pveGuestSnapshotTree',
278 if (caps
.vms
['VM.Console']) {
281 xtype
: 'pveFirewallRules',
282 title
: gettext('Firewall'),
283 iconCls
: 'fa fa-shield',
285 base_url
: base_url
+ '/firewall/rules',
286 list_refs_url
: base_url
+ '/firewall/refs',
290 xtype
: 'pveFirewallOptions',
291 groups
: ['firewall'],
292 iconCls
: 'fa fa-gear',
293 onlineHelp
: 'pve_firewall_vm_container_configuration',
294 title
: gettext('Options'),
295 base_url
: base_url
+ '/firewall/options',
297 itemId
: 'firewall-options',
300 xtype
: 'pveFirewallAliases',
301 title
: gettext('Alias'),
302 groups
: ['firewall'],
303 iconCls
: 'fa fa-external-link',
304 base_url
: base_url
+ '/firewall/aliases',
305 itemId
: 'firewall-aliases',
309 title
: gettext('IPSet'),
310 groups
: ['firewall'],
311 iconCls
: 'fa fa-list-ol',
312 base_url
: base_url
+ '/firewall/ipset',
313 list_refs_url
: base_url
+ '/firewall/refs',
314 itemId
: 'firewall-ipset',
317 title
: gettext('Log'),
318 groups
: ['firewall'],
319 iconCls
: 'fa fa-list',
320 onlineHelp
: 'chapter_pve_firewall',
321 itemId
: 'firewall-fwlog',
322 xtype
: 'proxmoxLogView',
323 url
: '/api2/extjs' + base_url
+ '/firewall/log',
328 if (caps
.vms
['Permissions.Modify']) {
331 title
: gettext('Permissions'),
332 itemId
: 'permissions',
333 iconCls
: 'fa fa-unlock',
334 path
: '/vms/' + vmid
,
340 var prevStatus
= 'unknown';
341 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
347 var rec
= s
.data
.get('status');
348 status
= rec
? rec
.data
.value
: 'unknown';
349 rec
= s
.data
.get('template');
350 template
= rec
.data
.value
|| false;
351 rec
= s
.data
.get('lock');
352 lock
= rec
? rec
.data
.value
: undefined;
355 statusTxt
.update({ lock
: lock
});
357 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
358 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
359 me
.down('#removeBtn').setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
360 consoleBtn
.setDisabled(template
);
362 if (prevStatus
=== 'stopped' && status
=== 'running') {
363 let con
= me
.down('#consolejs');
372 me
.on('afterrender', function() {
373 me
.statusStore
.startUpdate();
376 me
.on('destroy', function() {
377 me
.statusStore
.stopUpdate();