]>
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.html',
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 caps
= Ext
.state
.Manager
.get('GuiCap');
24 var base_url
= '/nodes/' + nodename
+ '/lxc/' + vmid
;
26 me
.statusStore
= Ext
.create('PVE.data.ObjectStore', {
27 url
: '/api2/json' + base_url
+ '/status/current',
31 var vm_command = function(cmd
, params
) {
32 PVE
.Utils
.API2Request({
34 url
: base_url
+ "/status/" + cmd
,
37 failure: function(response
, opts
) {
38 Ext
.Msg
.alert('Error', response
.htmlStatus
);
43 var startBtn
= Ext
.create('Ext.Button', {
44 text
: gettext('Start'),
45 disabled
: !caps
.vms
['VM.PowerMgmt'],
52 var umountBtn
= Ext
.create('Ext.Button', {
53 text
: gettext('Unmount'),
61 var stopBtn
= Ext
.create('Ext.menu.Item',{
62 text
: gettext('Stop'),
63 disabled
: !caps
.vms
['VM.PowerMgmt'],
64 confirmMsg
: PVE
.Utils
.format_task_description('vzstop', vmid
),
72 var shutdownBtn
= Ext
.create('PVE.button.Split', {
73 text
: gettext('Shutdown'),
74 disabled
: !caps
.vms
['VM.PowerMgmt'],
75 confirmMsg
: PVE
.Utils
.format_task_description('vzshutdown', vmid
),
77 vm_command('shutdown');
82 iconCls
: 'fa fa-power-off'
85 var migrateBtn
= Ext
.create('Ext.Button', {
86 text
: gettext('Migrate'),
87 disabled
: !caps
.vms
['VM.Migrate'],
89 var win
= Ext
.create('PVE.window.Migrate', {
96 iconCls
: 'fa fa-send-o'
99 var removeBtn
= Ext
.create('PVE.button.Button', {
100 text
: gettext('Remove'),
101 disabled
: !caps
.vms
['VM.Allocate'],
102 handler: function() {
103 Ext
.create('PVE.window.SafeDestroy', {
105 item
: { type
: 'CT', id
: vmid
}
108 iconCls
: 'fa fa-trash-o'
111 var vmname
= me
.pveSelNode
.data
.name
;
113 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
114 disabled
: !caps
.vms
['VM.Console'],
119 iconCls
: 'fa fa-terminal'
122 var descr
= vmid
+ " (" + (vmname
? "'" + vmname
+ "' " : "'CT " + vmid
+ "'") + ")";
125 title
: Ext
.String
.format(gettext("Container {0} on node {1}"), descr
, "'" + nodename
+ "'"),
127 tbar
: [ startBtn
, shutdownBtn
, umountBtn
, removeBtn
,
128 migrateBtn
, consoleBtn
],
129 defaults
: { statusStore
: me
.statusStore
},
132 title
: gettext('Summary'),
133 xtype
: 'pveLxcSummary',
134 iconCls
: 'fa fa-book',
140 if (caps
.vms
['VM.Console']) {
142 title
: gettext('Console'),
144 iconCls
: 'fa fa-terminal',
145 xtype
: 'pveNoVncConsole',
154 title
: gettext('Resources'),
156 onlineHelp
: 'chapter-pct.html#_configuration',
157 expandedOnInit
: true,
158 iconCls
: 'fa fa-cube',
159 xtype
: 'pveLxcRessourceView'
162 title
: gettext('Network'),
163 iconCls
: 'fa fa-exchange',
164 onlineHelp
: 'chapter-pct.html#_container_network',
166 xtype
: 'pveLxcNetworkView'
169 title
: gettext('DNS'),
170 iconCls
: 'fa fa-globe',
171 onlineHelp
: 'chapter-pct.html#_container_network',
176 title
: gettext('Options'),
178 onlineHelp
: 'chapter-pct.html#_options',
179 iconCls
: 'fa fa-gear',
180 xtype
: 'pveLxcOptions'
183 title
: gettext('Task History'),
185 iconCls
: 'fa fa-list',
186 xtype
: 'pveNodeTasks',
191 if (caps
.vms
['VM.Backup']) {
193 title
: gettext('Backup'),
194 iconCls
: 'fa fa-floppy-o',
195 onlineHelp
: 'chapter-vzdump.html',
196 xtype
: 'pveBackupView',
201 if (caps
.vms
['VM.Snapshot']) {
203 title
: gettext('Snapshots'),
204 iconCls
: 'fa fa-history',
205 onlineHelp
: 'chapter-pct.html#_snapshots',
206 xtype
: 'pveLxcSnapshotTree',
211 if (caps
.vms
['VM.Console']) {
214 xtype
: 'pveFirewallRules',
215 title
: gettext('Firewall'),
216 onlineHelp
: 'chapter-pve-firewall.html',
217 iconCls
: 'fa fa-shield',
219 base_url
: base_url
+ '/firewall/rules',
220 list_refs_url
: base_url
+ '/firewall/refs',
224 xtype
: 'pveFirewallOptions',
225 groups
: ['firewall'],
226 iconCls
: 'fa fa-gear',
227 onlineHelp
: 'chapter-pve-firewall.html#_vm_container_configuration',
228 title
: gettext('Options'),
229 base_url
: base_url
+ '/firewall/options',
231 itemId
: 'firewall-options'
234 xtype
: 'pveFirewallAliases',
235 title
: gettext('Alias'),
236 groups
: ['firewall'],
237 iconCls
: 'fa fa-external-link',
238 onlineHelp
: 'chapter-pve-firewall.html#_ip_aliases',
239 base_url
: base_url
+ '/firewall/aliases',
240 itemId
: 'firewall-aliases'
244 title
: gettext('IPSet'),
245 groups
: ['firewall'],
246 iconCls
: 'fa fa-list-ol',
247 onlineHelp
: 'chapter-pve-firewall.html#_ip_sets',
248 base_url
: base_url
+ '/firewall/ipset',
249 list_refs_url
: base_url
+ '/firewall/refs',
250 itemId
: 'firewall-ipset'
253 title
: gettext('Log'),
254 groups
: ['firewall'],
255 iconCls
: 'fa fa-list',
256 onlineHelp
: 'chapter-pve-firewall.html',
257 itemId
: 'firewall-fwlog',
259 url
: '/api2/extjs' + base_url
+ '/firewall/log'
264 if (caps
.vms
['Permissions.Modify']) {
267 title
: gettext('Permissions'),
268 itemId
: 'permissions',
269 iconCls
: 'fa fa-unlock',
270 onlineHelp
: 'chapter-pveum.html',
277 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
280 me
.workspace
.checkVmMigration(me
.pveSelNode
);
283 var rec
= s
.data
.get('status');
284 status
= rec
? rec
.data
.value
: 'unknown';
285 rec
= s
.data
.get('template');
286 template
= rec
.data
.value
|| false;
288 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
289 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
290 stopBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'stopped');
291 removeBtn
.setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
292 consoleBtn
.setDisabled(template
);
294 if (status
=== 'mounted') {
295 umountBtn
.setDisabled(false);
296 umountBtn
.setVisible(true);
297 stopBtn
.setDisabled(true);
299 umountBtn
.setDisabled(true);
300 umountBtn
.setVisible(false);
301 stopBtn
.setDisabled(false);
305 me
.on('afterrender', function() {
306 me
.statusStore
.startUpdate();
309 me
.on('destroy', function() {
310 me
.statusStore
.stopUpdate();