]>
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() {
10 var nodename
= me
.pveSelNode
.data
.node
;
12 throw "no node name specified";
15 var vmid
= me
.pveSelNode
.data
.vmid
;
17 throw "no VM ID specified";
20 var template
= !!me
.pveSelNode
.data
.template
;
22 var running
= !!me
.pveSelNode
.data
.uptime
;
24 var caps
= Ext
.state
.Manager
.get('GuiCap');
26 var base_url
= '/nodes/' + nodename
+ '/lxc/' + vmid
;
28 me
.statusStore
= Ext
.create('Proxmox.data.ObjectStore', {
29 url
: '/api2/json' + base_url
+ '/status/current',
33 var vm_command = function(cmd
, params
) {
34 Proxmox
.Utils
.API2Request({
36 url
: base_url
+ "/status/" + cmd
,
39 failure: function(response
, opts
) {
40 Ext
.Msg
.alert('Error', response
.htmlStatus
);
45 var startBtn
= Ext
.create('Ext.Button', {
46 text
: gettext('Start'),
47 disabled
: !caps
.vms
['VM.PowerMgmt'] || running
,
55 var stopBtn
= Ext
.create('Ext.menu.Item',{
56 text
: gettext('Stop'),
57 disabled
: !caps
.vms
['VM.PowerMgmt'],
58 confirmMsg
: Proxmox
.Utils
.format_task_description('vzstop', vmid
),
59 tooltip
: Ext
.String
.format(gettext('Stop {0} immediately'), 'CT'),
67 var shutdownBtn
= Ext
.create('PVE.button.Split', {
68 text
: gettext('Shutdown'),
69 disabled
: !caps
.vms
['VM.PowerMgmt'] || !running
,
71 confirmMsg
: Proxmox
.Utils
.format_task_description('vzshutdown', vmid
),
73 vm_command('shutdown');
78 iconCls
: 'fa fa-power-off'
81 var migrateBtn
= Ext
.create('Ext.Button', {
82 text
: gettext('Migrate'),
83 disabled
: !caps
.vms
['VM.Migrate'],
84 hidden
: PVE
.data
.ResourceStore
.getNodes().length
< 2,
86 var win
= Ext
.create('PVE.window.Migrate', {
93 iconCls
: 'fa fa-send-o'
96 var moreBtn
= Ext
.create('Proxmox.button.Button', {
97 text
: gettext('More'),
100 text
: gettext('Clone'),
101 iconCls
: 'fa fa-fw fa-clone',
102 hidden
: caps
.vms
['VM.Clone'] ? false : true,
103 handler: function() {
104 PVE
.window
.Clone
.wrap(nodename
, vmid
, template
, 'lxc');
108 text
: gettext('Convert to template'),
110 xtype
: 'pveMenuItem',
111 iconCls
: 'fa fa-fw fa-file-o',
112 hidden
: caps
.vms
['VM.Allocate'] ? false : true,
113 confirmMsg
: Proxmox
.Utils
.format_task_description('vztemplate', vmid
),
114 handler: function() {
115 Proxmox
.Utils
.API2Request({
116 url
: base_url
+ '/template',
119 failure: function(response
, opts
) {
120 Ext
.Msg
.alert('Error', response
.htmlStatus
);
126 iconCls
: 'fa fa-heartbeat ',
127 hidden
: !caps
.nodes
['Sys.Console'],
128 text
: gettext('Manage HA'),
129 handler: function() {
130 var ha
= me
.pveSelNode
.data
.hastate
;
131 Ext
.create('PVE.ha.VMResourceEdit', {
134 isCreate
: (!ha
|| ha
=== 'unmanaged')
139 text
: gettext('Remove'),
140 disabled
: !caps
.vms
['VM.Allocate'],
142 handler: function() {
143 Ext
.create('PVE.window.SafeDestroy', {
145 item
: { type
: 'CT', id
: vmid
}
148 iconCls
: 'fa fa-trash-o'
153 var vm
= me
.pveSelNode
.data
;
155 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
156 disabled
: !caps
.vms
['VM.Console'],
158 consoleName
: vm
.name
,
164 var statusTxt
= Ext
.create('Ext.toolbar.TextItem', {
170 '<i class="fa fa-lg fa-lock"></i> ({lock})',
177 title
: Ext
.String
.format(gettext("Container {0} on node '{1}'"), vm
.text
, nodename
),
180 tbar
: [ statusTxt
, '->', startBtn
, shutdownBtn
, migrateBtn
, consoleBtn
, moreBtn
],
181 defaults
: { statusStore
: me
.statusStore
},
184 title
: gettext('Summary'),
185 xtype
: 'pveLxcSummary',
186 iconCls
: 'fa fa-book',
192 if (caps
.vms
['VM.Console'] && !template
) {
195 title
: gettext('Console'),
197 iconCls
: 'fa fa-terminal',
198 xtype
: 'pveNoVncConsole',
209 title
: gettext('Resources'),
211 expandedOnInit
: true,
212 iconCls
: 'fa fa-cube',
213 xtype
: 'pveLxcRessourceView'
216 title
: gettext('Network'),
217 iconCls
: 'fa fa-exchange',
219 xtype
: 'pveLxcNetworkView'
222 title
: gettext('DNS'),
223 iconCls
: 'fa fa-globe',
228 title
: gettext('Options'),
230 iconCls
: 'fa fa-gear',
231 xtype
: 'pveLxcOptions'
234 title
: gettext('Task History'),
236 iconCls
: 'fa fa-list',
237 xtype
: 'proxmoxNodeTasks',
243 if (caps
.vms
['VM.Backup']) {
245 title
: gettext('Backup'),
246 iconCls
: 'fa fa-floppy-o',
247 xtype
: 'pveBackupView',
251 title
: gettext('Replication'),
252 iconCls
: 'fa fa-retweet',
253 xtype
: 'pveReplicaView',
254 itemId
: 'replication'
258 if ((caps
.vms
['VM.Snapshot'] || caps
.vms
['VM.Snapshot.Rollback']) && !template
) {
260 title
: gettext('Snapshots'),
261 iconCls
: 'fa fa-history',
262 xtype
: 'pveLxcSnapshotTree',
267 if (caps
.vms
['VM.Console']) {
270 xtype
: 'pveFirewallRules',
271 title
: gettext('Firewall'),
272 iconCls
: 'fa fa-shield',
274 base_url
: base_url
+ '/firewall/rules',
275 list_refs_url
: base_url
+ '/firewall/refs',
279 xtype
: 'pveFirewallOptions',
280 groups
: ['firewall'],
281 iconCls
: 'fa fa-gear',
282 onlineHelp
: 'pve_firewall_vm_container_configuration',
283 title
: gettext('Options'),
284 base_url
: base_url
+ '/firewall/options',
286 itemId
: 'firewall-options'
289 xtype
: 'pveFirewallAliases',
290 title
: gettext('Alias'),
291 groups
: ['firewall'],
292 iconCls
: 'fa fa-external-link',
293 base_url
: base_url
+ '/firewall/aliases',
294 itemId
: 'firewall-aliases'
298 title
: gettext('IPSet'),
299 groups
: ['firewall'],
300 iconCls
: 'fa fa-list-ol',
301 base_url
: base_url
+ '/firewall/ipset',
302 list_refs_url
: base_url
+ '/firewall/refs',
303 itemId
: 'firewall-ipset'
306 title
: gettext('Log'),
307 groups
: ['firewall'],
308 iconCls
: 'fa fa-list',
309 onlineHelp
: 'chapter_pve_firewall',
310 itemId
: 'firewall-fwlog',
311 xtype
: 'proxmoxLogView',
312 url
: '/api2/extjs' + base_url
+ '/firewall/log'
317 if (caps
.vms
['Permissions.Modify']) {
320 title
: gettext('Permissions'),
321 itemId
: 'permissions',
322 iconCls
: 'fa fa-unlock',
329 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
335 var rec
= s
.data
.get('status');
336 status
= rec
? rec
.data
.value
: 'unknown';
337 rec
= s
.data
.get('template');
338 template
= rec
.data
.value
|| false;
339 rec
= s
.data
.get('lock');
340 lock
= rec
? rec
.data
.value
: undefined;
343 statusTxt
.update({ lock
: lock
});
345 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
346 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
347 stopBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'stopped');
348 me
.down('#removeBtn').setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
349 consoleBtn
.setDisabled(template
);
352 me
.on('afterrender', function() {
353 me
.statusStore
.startUpdate();
356 me
.on('destroy', function() {
357 me
.statusStore
.stopUpdate();