From: Stefan Hrdlicka <s.hrdlicka@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH V3 pve-manager 1/2] fix #2822: add lvm, lvmthin & zfs storage for all cluster nodes
Date: Tue, 19 Jul 2022 13:57:06 +0200 [thread overview]
Message-ID: <20220719115707.4006326-2-s.hrdlicka@proxmox.com> (raw)
In-Reply-To: <20220719115707.4006326-1-s.hrdlicka@proxmox.com>
This adds a dropdown box for LVM, LVMThin & ZFS storage options where a
cluster node needs to be chosen. As default the current node is
selected. It restricts the the storage to be only availabe on the
selected node.
Signed-off-by: Stefan Hrdlicka <s.hrdlicka@proxmox.com>
---
www/manager6/storage/Base.js | 40 +++++++++++++++++++++
www/manager6/storage/IScsiEdit.js | 54 ++++++++++++++++++++++-------
www/manager6/storage/LVMEdit.js | 27 +++++++++++++--
www/manager6/storage/LvmThinEdit.js | 42 +++++++++++++++++-----
www/manager6/storage/ZFSPoolEdit.js | 32 ++++++++++++++---
5 files changed, 166 insertions(+), 29 deletions(-)
diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
index 7f6d7a09..28c5c9d0 100644
--- a/www/manager6/storage/Base.js
+++ b/www/manager6/storage/Base.js
@@ -36,6 +36,7 @@ Ext.define('PVE.panel.StorageBase', {
{
xtype: 'pveNodeSelector',
name: 'nodes',
+ reference: 'storageNodeRestriction',
disabled: me.storageId === 'local',
fieldLabel: gettext('Nodes'),
emptyText: gettext('All') + ' (' + gettext('No restrictions') +')',
@@ -76,6 +77,45 @@ Ext.define('PVE.panel.StorageBase', {
},
});
+Ext.define('PVE.panel.StorageBaseWithNodeSelector', {
+ extend: 'PVE.form.NodeSelector',
+ xtype: 'pveScanNodeSelector',
+
+ name: 'node',
+ itemId: 'pveScanNodeSelector',
+ fieldLabel: gettext('Scan node'),
+ allowBlank: true,
+ disallowedNodes: undefined,
+ onlineValidator: true,
+ autoSelect: false,
+ submitValue: false,
+ autoEl: {
+ tag: 'div',
+ 'data-qtip': gettext('Scan for available storages on the selected node'),
+ },
+});
+
+Ext.define('PVE.storage.ComboBoxSetStoreNode', {
+ extend: 'Ext.form.field.ComboBox',
+ config: {
+ apiBaseUrl: '/api2/json/nodes/',
+ apiStoragePath: '',
+ },
+
+ setNodeName: function(value) {
+ let me = this;
+ if (value === null || value === '') {
+ value = Proxmox.NodeName;
+ }
+
+ let store = me.getStore();
+ let proxy = store.getProxy();
+ proxy.setUrl(me.apiBaseUrl + value + me.apiStoragePath);
+ this.clearValue();
+ },
+
+});
+
Ext.define('PVE.storage.BaseEdit', {
extend: 'Proxmox.window.Edit',
diff --git a/www/manager6/storage/IScsiEdit.js b/www/manager6/storage/IScsiEdit.js
index 2f35f882..272c42d9 100644
--- a/www/manager6/storage/IScsiEdit.js
+++ b/www/manager6/storage/IScsiEdit.js
@@ -1,5 +1,5 @@
Ext.define('PVE.storage.IScsiScan', {
- extend: 'Ext.form.field.ComboBox',
+ extend: 'PVE.storage.ComboBoxSetStoreNode',
alias: 'widget.pveIScsiScan',
queryParam: 'portal',
@@ -10,6 +10,9 @@ Ext.define('PVE.storage.IScsiScan', {
loadingText: gettext('Scanning...'),
width: 350,
},
+ config: {
+ apiStoragePath: '/scan/iscsi',
+ },
doRawQuery: function() {
// do nothing
},
@@ -42,7 +45,7 @@ Ext.define('PVE.storage.IScsiScan', {
fields: ['target', 'portal'],
proxy: {
type: 'proxmox',
- url: `/api2/json/nodes/${me.nodename}/scan/iscsi`,
+ url: me.apiBaseUrl + me.nodename + me.apiStoragePath,
},
});
store.sort('target', 'ASC');
@@ -77,8 +80,40 @@ Ext.define('PVE.storage.IScsiInputPanel', {
initComponent: function() {
var me = this;
- me.column1 = [
- {
+ me.column1 = [];
+ let target = null;
+ if (me.isCreate) {
+ target = Ext.createWidget('pveIScsiScan', {
+ readOnly: !me.isCreate,
+ name: 'target',
+ value: '',
+ fieldLabel: 'Target',
+ allowBlank: false,
+ });
+
+ me.column1.push({
+ xtype: 'pveScanNodeSelector',
+ preferredValue: '',
+ allowBlank: true,
+ autoSelect: false,
+ listeners: {
+ change: {
+ fn: function(field, value) {
+ target.setNodeName(value);
+ me.lookupReference('storageNodeRestriction').setValue(value);
+ },
+ },
+ },
+ });
+ } else {
+ target = Ext.createWidget('displayfield', {
+ name: 'target',
+ value: '',
+ fieldLabel: gettext('Target'),
+ allowBlank: false,
+ });
+ }
+ me.column1.push({
xtype: me.isCreate ? 'textfield' : 'displayfield',
name: 'portal',
value: '',
@@ -94,15 +129,8 @@ Ext.define('PVE.storage.IScsiInputPanel', {
},
},
},
- {
- readOnly: !me.isCreate,
- xtype: me.isCreate ? 'pveIScsiScan' : 'displayfield',
- name: 'target',
- value: '',
- fieldLabel: 'Target',
- allowBlank: false,
- },
- ];
+ );
+ me.column1.push(target);
me.column2 = [
{
diff --git a/www/manager6/storage/LVMEdit.js b/www/manager6/storage/LVMEdit.js
index 2a9cd283..e7f9344b 100644
--- a/www/manager6/storage/LVMEdit.js
+++ b/www/manager6/storage/LVMEdit.js
@@ -1,10 +1,20 @@
Ext.define('PVE.storage.VgSelector', {
- extend: 'Ext.form.field.ComboBox',
+ extend: 'PVE.storage.ComboBoxSetStoreNode',
alias: 'widget.pveVgSelector',
valueField: 'vg',
displayField: 'vg',
queryMode: 'local',
editable: false,
+ config: {
+ apiStoragePath: '/scan/lvm',
+ },
+
+ setNodeName: function(value) {
+ let me = this;
+ me.callParent([value]);
+ me.getStore().load();
+ },
+
initComponent: function() {
var me = this;
@@ -17,7 +27,7 @@ Ext.define('PVE.storage.VgSelector', {
fields: ['vg', 'size', 'free'],
proxy: {
type: 'proxmox',
- url: '/api2/json/nodes/' + me.nodename + '/scan/lvm',
+ url: me.apiBaseUrl + me.nodename + me.apiStoragePath,
},
});
@@ -103,11 +113,22 @@ Ext.define('PVE.storage.LVMInputPanel', {
});
if (me.isCreate) {
- var vgField = Ext.create('PVE.storage.VgSelector', {
+ let vgField = Ext.create('PVE.storage.VgSelector', {
name: 'vgname',
fieldLabel: gettext('Volume group'),
allowBlank: false,
});
+ me.column1.push({
+ xtype: 'pveScanNodeSelector',
+ listeners: {
+ change: {
+ fn: function(field, value) {
+ vgField.setNodeName(value);
+ me.lookupReference('storageNodeRestriction').setValue(value);
+ },
+ },
+ },
+ });
var baseField = Ext.createWidget('pveFileSelector', {
name: 'base',
diff --git a/www/manager6/storage/LvmThinEdit.js b/www/manager6/storage/LvmThinEdit.js
index 4eab7740..a109f7af 100644
--- a/www/manager6/storage/LvmThinEdit.js
+++ b/www/manager6/storage/LvmThinEdit.js
@@ -1,5 +1,5 @@
Ext.define('PVE.storage.TPoolSelector', {
- extend: 'Ext.form.field.ComboBox',
+ extend: 'PVE.storage.ComboBoxSetStoreNode',
alias: 'widget.pveTPSelector',
queryParam: 'vg',
@@ -7,6 +7,10 @@ Ext.define('PVE.storage.TPoolSelector', {
displayField: 'lv',
editable: false,
+ config: {
+ apiStoragePath: '/scan/lvmthin',
+ },
+
doRawQuery: function() {
// nothing
},
@@ -40,7 +44,7 @@ Ext.define('PVE.storage.TPoolSelector', {
fields: ['lv'],
proxy: {
type: 'proxmox',
- url: '/api2/json/nodes/' + me.nodename + '/scan/lvmthin',
+ url: me.apiBaseUrl + me.nodename + me.apiStoragePath,
},
});
@@ -58,13 +62,23 @@ Ext.define('PVE.storage.TPoolSelector', {
});
Ext.define('PVE.storage.BaseVGSelector', {
- extend: 'Ext.form.field.ComboBox',
+ extend: 'PVE.storage.ComboBoxSetStoreNode',
alias: 'widget.pveBaseVGSelector',
valueField: 'vg',
displayField: 'vg',
queryMode: 'local',
editable: false,
+ config: {
+ apiStoragePath: '/scan/lvm',
+ },
+
+ setNodeName: function(value) {
+ let me = this;
+ me.callParent([value]);
+ me.getStore().load();
+ },
+
initComponent: function() {
var me = this;
@@ -77,7 +91,7 @@ Ext.define('PVE.storage.BaseVGSelector', {
fields: ['vg', 'size', 'free'],
proxy: {
type: 'proxmox',
- url: '/api2/json/nodes/' + me.nodename + '/scan/lvm',
+ url: me.apiBaseUrl + me.nodename + me.apiStoragePath,
},
});
@@ -121,14 +135,12 @@ Ext.define('PVE.storage.LvmThinInputPanel', {
});
if (me.isCreate) {
- var vgField = Ext.create('PVE.storage.TPoolSelector', {
+ let vgField = Ext.create('PVE.storage.TPoolSelector', {
name: 'thinpool',
fieldLabel: gettext('Thin Pool'),
allowBlank: false,
});
-
- me.column1.push({
- xtype: 'pveBaseVGSelector',
+ let vgSelector = Ext.create('PVE.storage.BaseVGSelector', {
name: 'vgname',
fieldLabel: gettext('Volume group'),
listeners: {
@@ -140,6 +152,20 @@ Ext.define('PVE.storage.LvmThinInputPanel', {
},
},
});
+ me.column1.push({
+ xtype: 'pveScanNodeSelector',
+ listeners: {
+ change: {
+ fn: function(field, value) {
+ vgField.setNodeName(value);
+ vgSelector.setNodeName(value);
+ me.lookupReference('storageNodeRestriction').setValue(value);
+ },
+ },
+ },
+ });
+
+ me.column1.push(vgSelector);
me.column1.push(vgField);
}
diff --git a/www/manager6/storage/ZFSPoolEdit.js b/www/manager6/storage/ZFSPoolEdit.js
index 8e689f0c..1cb15b8b 100644
--- a/www/manager6/storage/ZFSPoolEdit.js
+++ b/www/manager6/storage/ZFSPoolEdit.js
@@ -1,5 +1,5 @@
Ext.define('PVE.storage.ZFSPoolSelector', {
- extend: 'Ext.form.field.ComboBox',
+ extend: 'PVE.storage.ComboBoxSetStoreNode',
alias: 'widget.pveZFSPoolSelector',
valueField: 'pool',
displayField: 'pool',
@@ -8,6 +8,16 @@ Ext.define('PVE.storage.ZFSPoolSelector', {
listConfig: {
loadingText: gettext('Scanning...'),
},
+ config: {
+ apiStoragePath: '/scan/zfs',
+ },
+
+ setNodeName: function(value) {
+ let me = this;
+ me.callParent([value]);
+ me.getStore().load();
+ },
+
initComponent: function() {
var me = this;
@@ -20,10 +30,9 @@ Ext.define('PVE.storage.ZFSPoolSelector', {
fields: ['pool', 'size', 'free'],
proxy: {
type: 'proxmox',
- url: '/api2/json/nodes/' + me.nodename + '/scan/zfs',
+ url: me.apiBaseUrl + me.nodename + me.apiStoragePath,
},
});
-
store.sort('pool', 'ASC');
Ext.apply(me, {
@@ -45,11 +54,24 @@ Ext.define('PVE.storage.ZFSPoolInputPanel', {
me.column1 = [];
if (me.isCreate) {
- me.column1.push(Ext.create('PVE.storage.ZFSPoolSelector', {
+ let zfsPoolSelector = Ext.create('PVE.storage.ZFSPoolSelector', {
name: 'pool',
fieldLabel: gettext('ZFS Pool'),
allowBlank: false,
- }));
+ });
+
+ me.column1.push({
+ xtype: 'pveScanNodeSelector',
+ listeners: {
+ change: {
+ fn: function(field, value) {
+ zfsPoolSelector.setNodeName(value);
+ me.lookupReference('storageNodeRestriction').setValue(value);
+ },
+ },
+ },
+ });
+ me.column1.push(zfsPoolSelector);
} else {
me.column1.push(Ext.createWidget('displayfield', {
name: 'pool',
--
2.30.2
next prev parent reply other threads:[~2022-07-19 11:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-19 11:57 [pve-devel] [PATCH V3 pve-manager 0/2] add iscsi, lvm, lvmthin & zfs storage on all cluster nodes (fix #2822) Stefan Hrdlicka
2022-07-19 11:57 ` Stefan Hrdlicka [this message]
2022-07-27 10:19 ` [pve-devel] [PATCH V3 pve-manager 1/2] fix #2822: add lvm, lvmthin & zfs storage for all cluster nodes Fiona Ebner
2022-08-01 14:30 ` Stefan Hrdlicka
2022-08-02 7:29 ` Fiona Ebner
2022-07-19 11:57 ` [pve-devel] [PATCH V3 pve-manager 2/2] cleanup: "var" to "let", fix some indentation in related files Stefan Hrdlicka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220719115707.4006326-2-s.hrdlicka@proxmox.com \
--to=s.hrdlicka@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox