]>
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'),
109 text
: gettext('Clone'),
110 iconCls
: 'fa fa-fw fa-clone',
111 hidden
: caps
.vms
['VM.Clone'] ? false : true,
112 handler: function() {
113 PVE
.window
.Clone
.wrap(nodename
, vmid
, template
, 'lxc');
117 text
: gettext('Convert to template'),
119 xtype
: 'pveMenuItem',
120 iconCls
: 'fa fa-fw fa-file-o',
121 hidden
: caps
.vms
['VM.Allocate'] ? false : true,
122 confirmMsg
: Proxmox
.Utils
.format_task_description('vztemplate', vmid
),
123 handler: function() {
124 Proxmox
.Utils
.API2Request({
125 url
: base_url
+ '/template',
128 failure: function(response
, opts
) {
129 Ext
.Msg
.alert('Error', response
.htmlStatus
);
135 iconCls
: 'fa fa-heartbeat ',
136 hidden
: !caps
.nodes
['Sys.Console'],
137 text
: gettext('Manage HA'),
138 handler: function() {
140 Ext
.create('PVE.ha.VMResourceEdit', {
143 isCreate
: (!ha
|| ha
=== 'unmanaged'),
148 text
: gettext('Remove'),
149 disabled
: !caps
.vms
['VM.Allocate'],
151 handler: function() {
152 Ext
.create('PVE.window.SafeDestroy', {
154 item
: { type
: 'CT', id
: vmid
},
157 iconCls
: 'fa fa-trash-o',
162 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
163 disabled
: !caps
.vms
['VM.Console'],
165 consoleName
: vm
.name
,
171 var statusTxt
= Ext
.create('Ext.toolbar.TextItem', {
177 '<i class="fa fa-lg fa-lock"></i> ({lock})',
184 title
: Ext
.String
.format(gettext("Container {0} on node '{1}'"), vm
.text
, nodename
),
187 tbar
: [ statusTxt
, '->', startBtn
, shutdownBtn
, migrateBtn
, consoleBtn
, moreBtn
],
188 defaults
: { statusStore
: me
.statusStore
},
191 title
: gettext('Summary'),
192 xtype
: 'pveGuestSummary',
193 iconCls
: 'fa fa-book',
199 if (caps
.vms
['VM.Console'] && !template
) {
202 title
: gettext('Console'),
204 iconCls
: 'fa fa-terminal',
205 xtype
: 'pveNoVncConsole',
216 title
: gettext('Resources'),
218 expandedOnInit
: true,
219 iconCls
: 'fa fa-cube',
220 xtype
: 'pveLxcRessourceView',
223 title
: gettext('Network'),
224 iconCls
: 'fa fa-exchange',
226 xtype
: 'pveLxcNetworkView',
229 title
: gettext('DNS'),
230 iconCls
: 'fa fa-globe',
235 title
: gettext('Options'),
237 iconCls
: 'fa fa-gear',
238 xtype
: 'pveLxcOptions',
241 title
: gettext('Task History'),
243 iconCls
: 'fa fa-list',
244 xtype
: 'proxmoxNodeTasks',
250 if (caps
.vms
['VM.Backup']) {
252 title
: gettext('Backup'),
253 iconCls
: 'fa fa-floppy-o',
254 xtype
: 'pveBackupView',
258 title
: gettext('Replication'),
259 iconCls
: 'fa fa-retweet',
260 xtype
: 'pveReplicaView',
261 itemId
: 'replication',
265 if ((caps
.vms
['VM.Snapshot'] || caps
.vms
['VM.Snapshot.Rollback'] ||
266 caps
.vms
['VM.Audit']) && !template
) {
268 title
: gettext('Snapshots'),
269 iconCls
: 'fa fa-history',
270 xtype
: 'pveGuestSnapshotTree',
276 if (caps
.vms
['VM.Console']) {
279 xtype
: 'pveFirewallRules',
280 title
: gettext('Firewall'),
281 iconCls
: 'fa fa-shield',
283 base_url
: base_url
+ '/firewall/rules',
284 list_refs_url
: base_url
+ '/firewall/refs',
288 xtype
: 'pveFirewallOptions',
289 groups
: ['firewall'],
290 iconCls
: 'fa fa-gear',
291 onlineHelp
: 'pve_firewall_vm_container_configuration',
292 title
: gettext('Options'),
293 base_url
: base_url
+ '/firewall/options',
295 itemId
: 'firewall-options',
298 xtype
: 'pveFirewallAliases',
299 title
: gettext('Alias'),
300 groups
: ['firewall'],
301 iconCls
: 'fa fa-external-link',
302 base_url
: base_url
+ '/firewall/aliases',
303 itemId
: 'firewall-aliases',
307 title
: gettext('IPSet'),
308 groups
: ['firewall'],
309 iconCls
: 'fa fa-list-ol',
310 base_url
: base_url
+ '/firewall/ipset',
311 list_refs_url
: base_url
+ '/firewall/refs',
312 itemId
: 'firewall-ipset',
315 title
: gettext('Log'),
316 groups
: ['firewall'],
317 iconCls
: 'fa fa-list',
318 onlineHelp
: 'chapter_pve_firewall',
319 itemId
: 'firewall-fwlog',
320 xtype
: 'proxmoxLogView',
321 url
: '/api2/extjs' + base_url
+ '/firewall/log',
326 if (caps
.vms
['Permissions.Modify']) {
329 title
: gettext('Permissions'),
330 itemId
: 'permissions',
331 iconCls
: 'fa fa-unlock',
332 path
: '/vms/' + vmid
,
338 var prevStatus
= 'unknown';
339 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
345 var rec
= s
.data
.get('status');
346 status
= rec
? rec
.data
.value
: 'unknown';
347 rec
= s
.data
.get('template');
348 template
= rec
.data
.value
|| false;
349 rec
= s
.data
.get('lock');
350 lock
= rec
? rec
.data
.value
: undefined;
353 statusTxt
.update({ lock
: lock
});
355 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
356 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
357 me
.down('#removeBtn').setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
358 consoleBtn
.setDisabled(template
);
360 if (prevStatus
=== 'stopped' && status
=== 'running') {
361 let con
= me
.down('#consolejs');
370 me
.on('afterrender', function() {
371 me
.statusStore
.startUpdate();
374 me
.on('destroy', function() {
375 me
.statusStore
.stopUpdate();