]>
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.SafeDestroyGuest', {
155 item
: { type
: 'CT', id
: vmid
},
156 taskName
: 'vzdestroy',
159 iconCls
: 'fa fa-trash-o',
165 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
166 disabled
: !caps
.vms
['VM.Console'],
168 consoleName
: vm
.name
,
174 var statusTxt
= Ext
.create('Ext.toolbar.TextItem', {
180 '<i class="fa fa-lg fa-lock"></i> ({lock})',
187 title
: Ext
.String
.format(gettext("Container {0} on node '{1}'"), vm
.text
, nodename
),
190 tbar
: [statusTxt
, '->', startBtn
, shutdownBtn
, migrateBtn
, consoleBtn
, moreBtn
],
191 defaults
: { statusStore
: me
.statusStore
},
194 title
: gettext('Summary'),
195 xtype
: 'pveGuestSummary',
196 iconCls
: 'fa fa-book',
202 if (caps
.vms
['VM.Console'] && !template
) {
205 title
: gettext('Console'),
207 iconCls
: 'fa fa-terminal',
208 xtype
: 'pveNoVncConsole',
219 title
: gettext('Resources'),
221 expandedOnInit
: true,
222 iconCls
: 'fa fa-cube',
223 xtype
: 'pveLxcRessourceView',
226 title
: gettext('Network'),
227 iconCls
: 'fa fa-exchange',
229 xtype
: 'pveLxcNetworkView',
232 title
: gettext('DNS'),
233 iconCls
: 'fa fa-globe',
238 title
: gettext('Options'),
240 iconCls
: 'fa fa-gear',
241 xtype
: 'pveLxcOptions',
244 title
: gettext('Task History'),
246 iconCls
: 'fa fa-list-alt',
247 xtype
: 'proxmoxNodeTasks',
255 if (caps
.vms
['VM.Backup']) {
257 title
: gettext('Backup'),
258 iconCls
: 'fa fa-floppy-o',
259 xtype
: 'pveBackupView',
263 title
: gettext('Replication'),
264 iconCls
: 'fa fa-retweet',
265 xtype
: 'pveReplicaView',
266 itemId
: 'replication',
270 if ((caps
.vms
['VM.Snapshot'] || caps
.vms
['VM.Snapshot.Rollback'] ||
271 caps
.vms
['VM.Audit']) && !template
) {
273 title
: gettext('Snapshots'),
274 iconCls
: 'fa fa-history',
275 xtype
: 'pveGuestSnapshotTree',
281 if (caps
.vms
['VM.Console']) {
284 xtype
: 'pveFirewallRules',
285 title
: gettext('Firewall'),
286 iconCls
: 'fa fa-shield',
288 base_url
: base_url
+ '/firewall/rules',
289 list_refs_url
: base_url
+ '/firewall/refs',
293 xtype
: 'pveFirewallOptions',
294 groups
: ['firewall'],
295 iconCls
: 'fa fa-gear',
296 onlineHelp
: 'pve_firewall_vm_container_configuration',
297 title
: gettext('Options'),
298 base_url
: base_url
+ '/firewall/options',
300 itemId
: 'firewall-options',
303 xtype
: 'pveFirewallAliases',
304 title
: gettext('Alias'),
305 groups
: ['firewall'],
306 iconCls
: 'fa fa-external-link',
307 base_url
: base_url
+ '/firewall/aliases',
308 itemId
: 'firewall-aliases',
312 title
: gettext('IPSet'),
313 groups
: ['firewall'],
314 iconCls
: 'fa fa-list-ol',
315 base_url
: base_url
+ '/firewall/ipset',
316 list_refs_url
: base_url
+ '/firewall/refs',
317 itemId
: 'firewall-ipset',
320 title
: gettext('Log'),
321 groups
: ['firewall'],
322 iconCls
: 'fa fa-list',
323 onlineHelp
: 'chapter_pve_firewall',
324 itemId
: 'firewall-fwlog',
325 xtype
: 'proxmoxLogView',
326 url
: '/api2/extjs' + base_url
+ '/firewall/log',
331 if (caps
.vms
['Permissions.Modify']) {
334 title
: gettext('Permissions'),
335 itemId
: 'permissions',
336 iconCls
: 'fa fa-unlock',
337 path
: '/vms/' + vmid
,
343 var prevStatus
= 'unknown';
344 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
350 var rec
= s
.data
.get('status');
351 status
= rec
? rec
.data
.value
: 'unknown';
352 rec
= s
.data
.get('template');
353 template
= rec
? rec
.data
.value
: false;
354 rec
= s
.data
.get('lock');
355 lock
= rec
? rec
.data
.value
: undefined;
358 statusTxt
.update({ lock
: lock
});
360 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
361 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
362 me
.down('#removeBtn').setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
363 consoleBtn
.setDisabled(template
);
365 if (prevStatus
=== 'stopped' && status
=== 'running') {
366 let con
= me
.down('#consolejs');
375 me
.on('afterrender', function() {
376 me
.statusStore
.startUpdate();
379 me
.on('destroy', function() {
380 me
.statusStore
.stopUpdate();