]>
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('PVE.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
,
54 var stopBtn
= Ext
.create('Ext.menu.Item',{
55 text
: gettext('Stop'),
56 disabled
: !caps
.vms
['VM.PowerMgmt'],
57 confirmMsg
: Proxmox
.Utils
.format_task_description('vzstop', vmid
),
65 var shutdownBtn
= Ext
.create('PVE.button.Split', {
66 text
: gettext('Shutdown'),
67 disabled
: !caps
.vms
['VM.PowerMgmt'] || !running
,
68 confirmMsg
: Proxmox
.Utils
.format_task_description('vzshutdown', vmid
),
70 vm_command('shutdown');
75 iconCls
: 'fa fa-power-off'
78 var migrateBtn
= Ext
.create('Ext.Button', {
79 text
: gettext('Migrate'),
80 disabled
: !caps
.vms
['VM.Migrate'],
81 hidden
: PVE
.data
.ResourceStore
.getNodes().length
< 2,
83 var win
= Ext
.create('PVE.window.Migrate', {
90 iconCls
: 'fa fa-send-o'
93 var moreBtn
= Ext
.create('Proxmox.button.Button', {
94 text
: gettext('More'),
97 iconCls
: 'fa fa-heartbeat ',
98 hidden
: !caps
.nodes
['Sys.Console'],
99 text
: gettext('Manage HA'),
100 handler: function() {
101 var ha
= me
.pveSelNode
.data
.hastate
;
102 Ext
.create('PVE.ha.VMResourceEdit', {
105 isCreate
: (!ha
|| ha
=== 'unmanaged')
110 text
: gettext('Remove'),
111 disabled
: !caps
.vms
['VM.Allocate'],
113 handler: function() {
114 Ext
.create('PVE.window.SafeDestroy', {
116 item
: { type
: 'CT', id
: vmid
}
119 iconCls
: 'fa fa-trash-o'
124 var vm
= me
.pveSelNode
.data
;
126 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
127 disabled
: !caps
.vms
['VM.Console'],
129 consoleName
: vm
.name
,
135 title
: Ext
.String
.format(gettext("Container {0} on node '{1}'"), vm
.text
, nodename
),
137 tbar
: [ startBtn
, shutdownBtn
, migrateBtn
, consoleBtn
, moreBtn
],
138 defaults
: { statusStore
: me
.statusStore
},
141 title
: gettext('Summary'),
142 xtype
: 'pveLxcSummary',
143 iconCls
: 'fa fa-book',
149 if (caps
.vms
['VM.Console']) {
152 title
: gettext('Console'),
154 iconCls
: 'fa fa-terminal',
155 xtype
: 'pveNoVncConsole',
161 title
: gettext('Console (JS)'),
163 iconCls
: 'fa fa-terminal',
164 xtype
: 'pveNoVncConsole',
175 title
: gettext('Resources'),
177 expandedOnInit
: true,
178 iconCls
: 'fa fa-cube',
179 xtype
: 'pveLxcRessourceView'
182 title
: gettext('Network'),
183 iconCls
: 'fa fa-exchange',
185 xtype
: 'pveLxcNetworkView'
188 title
: gettext('DNS'),
189 iconCls
: 'fa fa-globe',
194 title
: gettext('Options'),
196 iconCls
: 'fa fa-gear',
197 xtype
: 'pveLxcOptions'
200 title
: gettext('Task History'),
202 iconCls
: 'fa fa-list',
203 xtype
: 'proxmoxNodeTasks',
209 if (caps
.vms
['VM.Backup']) {
211 title
: gettext('Backup'),
212 iconCls
: 'fa fa-floppy-o',
213 xtype
: 'pveBackupView',
217 title
: gettext('Replication'),
218 iconCls
: 'fa fa-retweet',
219 xtype
: 'pveReplicaView',
220 itemId
: 'replication'
224 if (caps
.vms
['VM.Snapshot'] || caps
.vms
['VM.Snapshot.Rollback']) {
226 title
: gettext('Snapshots'),
227 iconCls
: 'fa fa-history',
228 xtype
: 'pveLxcSnapshotTree',
233 if (caps
.vms
['VM.Console']) {
236 xtype
: 'pveFirewallRules',
237 title
: gettext('Firewall'),
238 iconCls
: 'fa fa-shield',
240 base_url
: base_url
+ '/firewall/rules',
241 list_refs_url
: base_url
+ '/firewall/refs',
245 xtype
: 'pveFirewallOptions',
246 groups
: ['firewall'],
247 iconCls
: 'fa fa-gear',
248 onlineHelp
: 'pve_firewall_vm_container_configuration',
249 title
: gettext('Options'),
250 base_url
: base_url
+ '/firewall/options',
252 itemId
: 'firewall-options'
255 xtype
: 'pveFirewallAliases',
256 title
: gettext('Alias'),
257 groups
: ['firewall'],
258 iconCls
: 'fa fa-external-link',
259 base_url
: base_url
+ '/firewall/aliases',
260 itemId
: 'firewall-aliases'
264 title
: gettext('IPSet'),
265 groups
: ['firewall'],
266 iconCls
: 'fa fa-list-ol',
267 base_url
: base_url
+ '/firewall/ipset',
268 list_refs_url
: base_url
+ '/firewall/refs',
269 itemId
: 'firewall-ipset'
272 title
: gettext('Log'),
273 groups
: ['firewall'],
274 iconCls
: 'fa fa-list',
275 onlineHelp
: 'chapter_pve_firewall',
276 itemId
: 'firewall-fwlog',
278 url
: '/api2/extjs' + base_url
+ '/firewall/log'
283 if (caps
.vms
['Permissions.Modify']) {
286 title
: gettext('Permissions'),
287 itemId
: 'permissions',
288 iconCls
: 'fa fa-unlock',
295 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
300 var rec
= s
.data
.get('status');
301 status
= rec
? rec
.data
.value
: 'unknown';
302 rec
= s
.data
.get('template');
303 template
= rec
.data
.value
|| false;
305 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
306 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
307 stopBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'stopped');
308 me
.down('#removeBtn').setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
309 consoleBtn
.setDisabled(template
);
312 me
.on('afterrender', function() {
313 me
.statusStore
.startUpdate();
316 me
.on('destroy', function() {
317 me
.statusStore
.stopUpdate();