]>
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
),
66 var shutdownBtn
= Ext
.create('PVE.button.Split', {
67 text
: gettext('Shutdown'),
68 disabled
: !caps
.vms
['VM.PowerMgmt'] || !running
,
70 confirmMsg
: Proxmox
.Utils
.format_task_description('vzshutdown', vmid
),
72 vm_command('shutdown');
77 iconCls
: 'fa fa-power-off'
80 var migrateBtn
= Ext
.create('Ext.Button', {
81 text
: gettext('Migrate'),
82 disabled
: !caps
.vms
['VM.Migrate'],
83 hidden
: PVE
.data
.ResourceStore
.getNodes().length
< 2,
85 var win
= Ext
.create('PVE.window.Migrate', {
92 iconCls
: 'fa fa-send-o'
95 var moreBtn
= Ext
.create('Proxmox.button.Button', {
96 text
: gettext('More'),
99 text
: gettext('Clone'),
100 iconCls
: 'fa fa-fw fa-clone',
101 hidden
: caps
.vms
['VM.Clone'] ? false : true,
102 handler: function() {
103 PVE
.window
.Clone
.wrap(nodename
, vmid
, template
, 'lxc');
107 text
: gettext('Convert to template'),
109 xtype
: 'pveMenuItem',
110 iconCls
: 'fa fa-fw fa-file-o',
111 hidden
: caps
.vms
['VM.Allocate'] ? false : true,
112 confirmMsg
: Proxmox
.Utils
.format_task_description('vztemplate', vmid
),
113 handler: function() {
114 Proxmox
.Utils
.API2Request({
115 url
: base_url
+ '/template',
118 failure: function(response
, opts
) {
119 Ext
.Msg
.alert('Error', response
.htmlStatus
);
125 iconCls
: 'fa fa-heartbeat ',
126 hidden
: !caps
.nodes
['Sys.Console'],
127 text
: gettext('Manage HA'),
128 handler: function() {
129 var ha
= me
.pveSelNode
.data
.hastate
;
130 Ext
.create('PVE.ha.VMResourceEdit', {
133 isCreate
: (!ha
|| ha
=== 'unmanaged')
138 text
: gettext('Remove'),
139 disabled
: !caps
.vms
['VM.Allocate'],
141 handler: function() {
142 Ext
.create('PVE.window.SafeDestroy', {
144 item
: { type
: 'CT', id
: vmid
}
147 iconCls
: 'fa fa-trash-o'
152 var vm
= me
.pveSelNode
.data
;
154 var consoleBtn
= Ext
.create('PVE.button.ConsoleButton', {
155 disabled
: !caps
.vms
['VM.Console'],
157 consoleName
: vm
.name
,
164 title
: Ext
.String
.format(gettext("Container {0} on node '{1}'"), vm
.text
, nodename
),
166 tbar
: [ startBtn
, shutdownBtn
, migrateBtn
, consoleBtn
, moreBtn
],
167 defaults
: { statusStore
: me
.statusStore
},
170 title
: gettext('Summary'),
171 xtype
: 'pveLxcSummary',
172 iconCls
: 'fa fa-book',
178 if (caps
.vms
['VM.Console'] && !template
) {
181 title
: gettext('Console'),
183 iconCls
: 'fa fa-terminal',
184 xtype
: 'pveNoVncConsole',
195 title
: gettext('Resources'),
197 expandedOnInit
: true,
198 iconCls
: 'fa fa-cube',
199 xtype
: 'pveLxcRessourceView'
202 title
: gettext('Network'),
203 iconCls
: 'fa fa-exchange',
205 xtype
: 'pveLxcNetworkView'
208 title
: gettext('DNS'),
209 iconCls
: 'fa fa-globe',
214 title
: gettext('Options'),
216 iconCls
: 'fa fa-gear',
217 xtype
: 'pveLxcOptions'
220 title
: gettext('Task History'),
222 iconCls
: 'fa fa-list',
223 xtype
: 'proxmoxNodeTasks',
229 if (caps
.vms
['VM.Backup']) {
231 title
: gettext('Backup'),
232 iconCls
: 'fa fa-floppy-o',
233 xtype
: 'pveBackupView',
237 title
: gettext('Replication'),
238 iconCls
: 'fa fa-retweet',
239 xtype
: 'pveReplicaView',
240 itemId
: 'replication'
244 if ((caps
.vms
['VM.Snapshot'] || caps
.vms
['VM.Snapshot.Rollback']) && !template
) {
246 title
: gettext('Snapshots'),
247 iconCls
: 'fa fa-history',
248 xtype
: 'pveLxcSnapshotTree',
253 if (caps
.vms
['VM.Console']) {
256 xtype
: 'pveFirewallRules',
257 title
: gettext('Firewall'),
258 iconCls
: 'fa fa-shield',
260 base_url
: base_url
+ '/firewall/rules',
261 list_refs_url
: base_url
+ '/firewall/refs',
265 xtype
: 'pveFirewallOptions',
266 groups
: ['firewall'],
267 iconCls
: 'fa fa-gear',
268 onlineHelp
: 'pve_firewall_vm_container_configuration',
269 title
: gettext('Options'),
270 base_url
: base_url
+ '/firewall/options',
272 itemId
: 'firewall-options'
275 xtype
: 'pveFirewallAliases',
276 title
: gettext('Alias'),
277 groups
: ['firewall'],
278 iconCls
: 'fa fa-external-link',
279 base_url
: base_url
+ '/firewall/aliases',
280 itemId
: 'firewall-aliases'
284 title
: gettext('IPSet'),
285 groups
: ['firewall'],
286 iconCls
: 'fa fa-list-ol',
287 base_url
: base_url
+ '/firewall/ipset',
288 list_refs_url
: base_url
+ '/firewall/refs',
289 itemId
: 'firewall-ipset'
292 title
: gettext('Log'),
293 groups
: ['firewall'],
294 iconCls
: 'fa fa-list',
295 onlineHelp
: 'chapter_pve_firewall',
296 itemId
: 'firewall-fwlog',
297 xtype
: 'proxmoxLogView',
298 url
: '/api2/extjs' + base_url
+ '/firewall/log'
303 if (caps
.vms
['Permissions.Modify']) {
306 title
: gettext('Permissions'),
307 itemId
: 'permissions',
308 iconCls
: 'fa fa-unlock',
315 me
.mon(me
.statusStore
, 'load', function(s
, records
, success
) {
320 var rec
= s
.data
.get('status');
321 status
= rec
? rec
.data
.value
: 'unknown';
322 rec
= s
.data
.get('template');
323 template
= rec
.data
.value
|| false;
325 startBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'running' || template
);
326 shutdownBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
!== 'running');
327 stopBtn
.setDisabled(!caps
.vms
['VM.PowerMgmt'] || status
=== 'stopped');
328 me
.down('#removeBtn').setDisabled(!caps
.vms
['VM.Allocate'] || status
!== 'stopped');
329 consoleBtn
.setDisabled(template
);
332 me
.on('afterrender', function() {
333 me
.statusStore
.startUpdate();
336 me
.on('destroy', function() {
337 me
.statusStore
.stopUpdate();