From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 76B9596C4F for ; Tue, 16 Apr 2024 14:21:12 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 189B71A6C6 for ; Tue, 16 Apr 2024 14:21:11 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 16 Apr 2024 14:21:09 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id BC2CE450BE for ; Tue, 16 Apr 2024 14:21:09 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pve-devel@lists.proxmox.com Date: Tue, 16 Apr 2024 14:20:48 +0200 Message-Id: <20240416122054.733817-14-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240416122054.733817-1-f.gruenbichler@proxmox.com> References: <20240416122054.733817-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.094 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_2 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_4 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v2 manager 4/4] ui: add pool limits and usage X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Apr 2024 12:21:12 -0000 Signed-off-by: Fabian Grünbichler --- Notes: this is very "bare", obviously we'd want - a nicer grid/.. display of usage - a way to edit the limits I am not yet sure how to integrate this nicely, and wanted to get feedback on the rest first. v2: - fold in change I forgot to include in patch: (== vs ===, ? 1 : 0 vs just using the comparison result) add edit window www/manager6/pool/StatusView.js | 141 +++++++++++++++++++++++++++++++- 1 file changed, 140 insertions(+), 1 deletion(-) diff --git a/www/manager6/pool/StatusView.js b/www/manager6/pool/StatusView.js index 3d46b3b1a..293ee1443 100644 --- a/www/manager6/pool/StatusView.js +++ b/www/manager6/pool/StatusView.js @@ -1,12 +1,103 @@ +var labelWidth = 200; + +Ext.define('PVE.pool.LimitInputPanel', { + extend: 'Proxmox.panel.InputPanel', + alias: 'widget.pvePoolLimitInputPanel', + + onGetValues: function(values) { + let ret = PVE.Parser.printPropertyString(values, 'type'); + if (ret === '') { + return { 'delete': 'limits' }; + } + return { limits: ret }; + }, + + items: [ + { + xtype: 'proxmoxintegerfield', + name: 'mem-config', + minValue: 0, + value: '0', + step: 32, + fieldLabel: gettext('Memory Config Limit') + ' (MiB)', + labelWidth: labelWidth, + allowBlank: false, + }, + { + xtype: 'proxmoxintegerfield', + name: 'mem-run', + minValue: 0, + value: '0', + step: 32, + fieldLabel: gettext('Memory Running Limit') + ' (MiB)', + labelWidth: labelWidth, + allowBlank: false, + }, + { + xtype: 'proxmoxintegerfield', + name: 'cpu-config', + minValue: 0, + value: '0', + fieldLabel: gettext('CPU Config Limit'), + labelWidth: labelWidth, + allowBlank: false, + }, + { + xtype: 'proxmoxintegerfield', + name: 'cpu-run', + minValue: 0, + value: '0', + fieldLabel: gettext('CPU Running Limit'), + labelWidth: labelWidth, + allowBlank: false, + }, + ], +}); + +Ext.define('PVE.pool.EditLimits', { + extend: 'Proxmox.window.Edit', + + width: 640, + height: 480, + + initComponent: function() { + var me = this; + + if (!me.pool) { + throw "no pool specified"; + } + + me.url = '/pools/'; + me.method = 'PUT'; + me.extraRequestParams = { poolid: me.pool }; + me.autoLoad = true; + + Ext.apply(me, { + subject: gettext('Pool Limits'), + items: Ext.create('PVE.pool.LimitInputPanel'), + }); + + me.callParent(); + + me.load({ + success: function(response) { + me.poolconfig = response.result.data[0]; + let limits = me.poolconfig.limits; + me.setValues(PVE.Parser.parsePropertyString(limits)); + }, + }); + }, +}); + Ext.define('PVE.pool.StatusView', { extend: 'Proxmox.grid.ObjectGrid', alias: ['widget.pvePoolStatusView'], - disabled: true, title: gettext('Status'), cwidth1: 150, interval: 30000, //height: 195, + initComponent: function() { var me = this; @@ -15,17 +106,65 @@ Ext.define('PVE.pool.StatusView', { throw "no pool specified"; } + var reload = function() { + me.rstore.load(); + }; + var rows = { comment: { header: gettext('Comment'), renderer: Ext.String.htmlEncode, required: true, }, + usage: { + header: gettext('Usage'), + required: false, + renderer: value => { + if (value === null) { + return '-'; + } else { + let rendered = ''; + let over = false; + for (const [first, second] of Object.entries(value)) { + if (first === 'over') { + over = second === 1; + } else { + for (const [kind, usage] of Object.entries(second)) { + if (rendered === '') { + rendered = `${first}-${kind}=${usage}`; + } else { + rendered = rendered + `, ${first}-${kind}=${usage}`; + } + } + } + } + if (over) { + rendered = rendered + "\nover limit"; + } + return rendered; + } + }, + }, + limits: { + header: gettext('Resource Limits'), + required: false, + }, }; Ext.apply(me, { url: "/api2/json/pools/?poolid=" + pool, rows: rows, + tbar: [ + { + text: gettext('Edit Limits'), + iconCls: 'pve-itype-icon-qemu', + handler: function() { + var win = Ext.create('PVE.pool.EditLimits', { pool: pool }); + win.on('destroy', reload); + win.show(); + }, + }, + ], }); me.callParent(); -- 2.39.2