From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id A34281FF0E3 for ; Wed, 18 Nov 2026 21:33:59 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id B8BBE21D3B; Wed, 18 Nov 2026 21:28:13 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH v7 manager 39/43] ui: dc: san: add a guided setup for shared LVM on iSCSI Date: Wed, 18 Nov 2026 21:26:22 +0100 Message-ID: <20261118202646.3017286-40-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261118202646.3017286-1-t.lamprecht@proxmox.com> References: <20261118202646.3017286-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795033613451 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.163 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 7G2ZQ3JWUWHGWNUDPZR735KNLCU7RXUB X-Message-ID-Hash: 7G2ZQ3JWUWHGWNUDPZR735KNLCU7RXUB X-MailFrom: t.lamprecht@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Shared LVM on an iSCSI LUN needs an iSCSI storage with multipath, the right LUN as base volume and an LVM storage on top, in that order. Add a guided setup for it to the SAN view: connect to the target, with the initiator names of the nodes at hand for the access rules of the array, select a LUN, name the volume group and storage, and confirm. The setup starts from the SAN view and not from Datacenter > Storage > Add, as it creates a volume group and up to two storages, while an entry of the Add menu attaches one storage. Its menu is named Guided Setup, as in the documentation, so that it is not taken for an Add menu or button. Continuing from the target step creates or reuses the connection storage before the confirm step, so the target step says so. The menu needs Datastore.Allocate. It also needs Datastore.Audit or Datastore.AllocateSpace, as the setup reads the storage list and the LUNs of the connection storage. The LUN list comes from the node serving the web UI, and offers the LUNs of the connection storage, also one that the node reaches through several targets. A LUN that a storage uses cannot be selected, and a search field finds one by name, WWID or path. If the target is used by another storage that cannot be reused, the setup names it and says why. For a shared storage it matters whether the other nodes see the LUN as well. So the setup ends with the state of the LUN on each node of the storage, from the cluster-wide status. Nodes set up a new LUN with their next status updates, so for the first minute a node without the LUN shows as pending and not as missing. Co-authored-by: Dietmar Maurer Signed-off-by: Dietmar Maurer Signed-off-by: Thomas Lamprecht --- www/manager6/Makefile | 5 + www/manager6/dc/SAN.js | 25 +- www/manager6/storage/wizard/IScsi.js | 297 ++++++++++++++++++ www/manager6/storage/wizard/LunSelect.js | 204 ++++++++++++ www/manager6/storage/wizard/NodeIdentities.js | 94 ++++++ www/manager6/storage/wizard/Wizard.js | 183 +++++++++++ www/manager6/window/SANLunState.js | 115 +++++++ 7 files changed, 922 insertions(+), 1 deletion(-) create mode 100644 www/manager6/storage/wizard/IScsi.js create mode 100644 www/manager6/storage/wizard/LunSelect.js create mode 100644 www/manager6/storage/wizard/NodeIdentities.js create mode 100644 www/manager6/storage/wizard/Wizard.js create mode 100644 www/manager6/window/SANLunState.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index 4a6c8af72..09a02a9c4 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -137,6 +137,7 @@ JSSRC= \ window/Restore.js \ window/SafeDestroyGuest.js \ window/SafeDestroyStorage.js \ + window/SANLunState.js \ window/SANLunWipe.js \ window/Settings.js \ window/Snapshot.js \ @@ -385,6 +386,10 @@ JSSRC= \ storage/ZFSEdit.js \ storage/ZFSPoolEdit.js \ storage/ESXIEdit.js \ + storage/wizard/Wizard.js \ + storage/wizard/LunSelect.js \ + storage/wizard/NodeIdentities.js \ + storage/wizard/IScsi.js \ Workspace.js \ # end of JSSRC list diff --git a/www/manager6/dc/SAN.js b/www/manager6/dc/SAN.js index 12afa65df..72cb96291 100644 --- a/www/manager6/dc/SAN.js +++ b/www/manager6/dc/SAN.js @@ -50,9 +50,15 @@ Ext.define('PVE.dc.SANView', { initComponent: function () { let me = this; - let caps = Ext.state.Manager.get('GuiCap').dc; + let allCaps = Ext.state.Manager.get('GuiCap'); + let caps = allCaps.dc; let canModify = !!caps['Sys.Modify']; let canEdit = canModify && !!caps['Sys.Audit']; + // the setups also read the storage list and the LUNs of the connection storage + let storageCaps = allCaps.storage; + let canSetup = + !!storageCaps['Datastore.Allocate'] && + !!(storageCaps['Datastore.Audit'] || storageCaps['Datastore.AllocateSpace']); me.rstore = Ext.create('Proxmox.data.UpdateStore', { storeid: 'dc-san-status', model: 'pve-san-status', @@ -105,6 +111,23 @@ Ext.define('PVE.dc.SANView', { autoShow: true, apiCallDone: (success) => success && reload(), }); + let setupItem = (wizardType) => ({ + text: PVE.storage.wizard.subject(wizardType), + iconCls: 'fa fa-fw fa-building', + handler: () => + Ext.create('PVE.storage.wizard.SAN', { + wizardType, + autoShow: true, + reloadCallback: reload, + }), + }); + me.tbar = [ + { + text: gettext('Guided Setup'), + disabled: !canSetup, + menu: [setupItem('iscsi')], + }, + ]; me.items = [ { xtype: 'grid', diff --git a/www/manager6/storage/wizard/IScsi.js b/www/manager6/storage/wizard/IScsi.js new file mode 100644 index 000000000..d23cf3bb2 --- /dev/null +++ b/www/manager6/storage/wizard/IScsi.js @@ -0,0 +1,297 @@ +Ext.define('PVE.storage.wizard.IScsiTarget', { + extend: 'Proxmox.panel.InputPanel', + xtype: 'pveStorageWizardIScsiTarget', + onlineHelp: 'storage_open_iscsi', + + updateConnectionField: function () { + let me = this; + let target = me.down('field[name=target]').getValue(); + let storage = me.storages?.find( + (entry) => entry.type === 'iscsi' && entry.target === target, + ); + let field = me.down('field[name=connection]'); + if (storage) { + field.setValue(storage.storage); + } else if (field.readOnly) { + field.setValue(''); + } + field.setReadOnly(!!storage); + }, + + onSubmit: function () { + let me = this; + let wizard = me.up('window'); + let values = me.getValues(); + let params = { + type: 'iscsi', + storage: values.connection, + portal: values.portal, + target: values.target, + content: 'none', + 'managed-multipath': 1, + }; + let nodes = [] + .concat(values.nodes || []) + .filter(Boolean) + .join(','); + if (nodes) { + params.nodes = nodes; + } + let connected = function (connection) { + if (wizard.destroyed) { + return; + } + wizard.connection = connection; + // the step does not come back, the cluster status of its initiator names is not needed + me.down('pveStorageWizardNodeIdentities').rstore.stopUpdate(); + let tabs = wizard.down('#wizcontent'); + wizard.down('#luns').enable(); + tabs.setActiveTab(wizard.down('#luns')); + me.disable(); + }; + let fail = (response) => wizard.showError(response.htmlStatus); + Proxmox.Utils.API2Request({ + url: '/storage', + method: 'GET', + waitMsgTarget: wizard, + failure: fail, + success: function (response) { + if (wizard.destroyed) { + return; + } + me.storages = response.result.data; + me.updateConnectionField(); + let users = me.storages.filter((entry) => entry.target === values.target); + if (users.length) { + let base = users[0]; + let conflict; + if (users.length !== 1) { + conflict = Ext.String.format( + gettext( + 'Storages {0} use this target. The setup can only reuse a target that one storage uses.', + ), + users.map((entry) => entry.storage).join(', '), + ); + } else if (base.type !== 'iscsi') { + conflict = Ext.String.format( + gettext( + 'Storage "{0}" uses this target. The setup can only reuse an iSCSI storage.', + ), + base.storage, + ); + } else if (`${base.content ?? ''}` !== 'none') { + conflict = Ext.String.format( + gettext( + 'Storage "{0}" uses the LUNs of this target directly. If no guest uses them, clear Use LUNs directly in its edit dialog, otherwise use another target.', + ), + base.storage, + ); + } + if (conflict) { + wizard.showError(Ext.htmlEncode(conflict)); + return; + } + if (base.disable) { + wizard.showError( + Ext.htmlEncode( + Ext.String.format( + gettext( + 'Storage "{0}" connects to this target, but it is disabled. Enable that storage first.', + ), + base.storage, + ), + ), + ); + return; + } + let baseNodes = base.nodes ? base.nodes.split(',') : []; + if (baseNodes.length && !baseNodes.includes(Proxmox.NodeName)) { + wizard.showError( + Ext.htmlEncode( + Ext.String.format( + gettext( + 'Connection storage "{0}" is not available on node "{1}". Open the web UI on one of its nodes.', + ), + base.storage, + Proxmox.NodeName, + ), + ), + ); + return; + } + let selectedNodes = nodes ? nodes.split(',') : baseNodes; + if ( + baseNodes.length && + selectedNodes.some((node) => !baseNodes.includes(node)) + ) { + wizard.showError( + gettext( + 'The connection storage is not available on all selected nodes.', + ), + ); + return; + } + let connection = { + storage: base.storage, + target: base.target, + nodes: selectedNodes.join(','), + }; + if (!base['managed-multipath']) { + wizard.showError( + Ext.htmlEncode( + Ext.String.format( + gettext( + 'Enable Multipath in the edit dialog of storage "{0}" before using it here.', + ), + base.storage, + ), + ), + ); + return; + } + connected(connection); + return; + } + Proxmox.Utils.API2Request({ + url: '/storage', + method: 'POST', + params, + waitMsgTarget: wizard, + failure: fail, + success: () => + connected({ storage: params.storage, target: params.target, nodes }), + }); + }, + }); + }, + + initComponent: function () { + let me = this; + let common = PVE.panel.StorageBase.commonFields(true); + // wide enough for the longest label of the step + let labelWidth = 150; + me.items = [ + { + xtype: 'textfield', + name: 'portal', + fieldLabel: gettext('Portal'), + labelWidth, + allowBlank: false, + listeners: { + change: { + buffer: 500, + fn: function (field, value) { + let target = me.down('field[name=target]'); + target.setDisabled(!value); + target.setValue(''); + target.setPortal(value); + }, + }, + }, + }, + { + xtype: 'pveIScsiScan', + name: 'target', + fieldLabel: gettext('Target'), + labelWidth, + disabled: true, + showNodeSelector: false, + nodename: Proxmox.NodeName, + listeners: { change: () => me.updateConnectionField() }, + listConfig: { + width: 650, + emptyText: PVE.Utils.renderNotFound(gettext('iSCSI Target')), + columns: [ + { + text: gettext('Target'), + dataIndex: 'target', + flex: 1, + renderer: Ext.htmlEncode, + }, + { + text: gettext('Portals'), + dataIndex: 'portal', + width: 220, + renderer: Ext.htmlEncode, + }, + ], + }, + }, + { + ...common.id, + name: 'connection', + fieldLabel: gettext('Connection Storage'), + labelWidth, + }, + { + xtype: 'component', + margin: '0 0 10 0', + html: `${Ext.htmlEncode(gettext('Note:'))} ${Ext.htmlEncode( + gettext( + 'Next creates or reuses the connection storage before you select a LUN.', + ), + )}`, + }, + { xtype: 'pveStorageWizardNodeIdentities' }, + ]; + me.advancedItems = [ + { + ...common.nodes, + labelWidth, + validator: PVE.storage.wizard.validateNodes, + listeners: { + change: (field, value) => + me.down('pveStorageWizardNodeIdentities').setNodes(value), + }, + }, + ]; + me.callParent(); + me.on('afterrender', () => + Proxmox.Utils.API2Request({ + url: '/storage', + method: 'GET', + waitMsgTarget: me, + failure: function (response) { + if (!me.destroyed) { + me.up('window').showError(response.htmlStatus); + } + }, + success: function (response) { + if (!me.destroyed) { + me.storages = response.result.data; + me.updateConnectionField(); + } + }, + }), + ); + }, +}); + +PVE.storage.wizard.createIScsiLVM = function (wizard, values, lun) { + let connection = wizard.connection; + let fail = (response) => wizard.showError(response.htmlStatus); + Proxmox.Utils.API2Request({ + url: `/nodes/${Proxmox.NodeName}/storage/${encodeURIComponent(connection.storage)}/content`, + method: 'GET', + params: { content: 'images' }, + waitMsgTarget: wizard, + failure: fail, + success: function (response) { + if (wizard.destroyed) { + return; + } + let volume = response.result.data.find((entry) => + entry.volid.endsWith(`.dm-uuid-mpath-${lun.wwid}`), + ); + if (!volume) { + wizard.showError( + gettext( + 'The selected LUN has no multipath volume yet. Check Node > SAN, then retry.', + ), + ); + return; + } + wizard.addLVMStorage({ ...values, base: volume.volid }, fail); + }, + }); +}; diff --git a/www/manager6/storage/wizard/LunSelect.js b/www/manager6/storage/wizard/LunSelect.js new file mode 100644 index 000000000..e42779927 --- /dev/null +++ b/www/manager6/storage/wizard/LunSelect.js @@ -0,0 +1,204 @@ +Ext.define('PVE.storage.wizard.LunSelect', { + extend: 'Ext.panel.Panel', + xtype: 'pveStorageWizardLunSelect', + layout: { type: 'vbox', align: 'stretch' }, + + // as an input panel does, so that the wizard shows its help button for this step + listeners: { + activate: function () { + Ext.GlobalEvents.fireEvent('proxmoxShowHelp', this.onlineHelp); + }, + deactivate: function () { + Ext.GlobalEvents.fireEvent('proxmoxHideHelp', this.onlineHelp); + }, + }, + + getSelection: function () { + return this.down('grid').getSelection()[0]?.data; + }, + + reload: function () { + let me = this; + let wizard = me.up('window'); + let grid = me.down('grid'); + me.rstore.stopUpdate(); + let connection = wizard.connection; + // The scan names one target per LUN, also for a LUN reached through several. The content + // listing has the LUNs of the connection, and a LUN that shows up later is listed once the + // scan names the target of the connection for it. + let filter = { + id: 'connection', + filterFn: (rec) => + rec.get('iscsi-target') === connection.target || + (me.connectionWwids ?? []).includes(rec.get('wwid')), + }; + me.store.addFilter(filter); + Proxmox.Utils.API2Request({ + url: `/nodes/${Proxmox.NodeName}/storage/${encodeURIComponent(connection.storage)}/content`, + method: 'GET', + waitMsgTarget: grid, + failure: (response) => Ext.Msg.alert(gettext('Error'), response.htmlStatus), + success: function (response) { + if (!me.destroyed) { + me.connectionWwids = response.result.data + .map((entry) => entry.volid.match(/\.dm-uuid-mpath-(.+)$/)?.[1]) + .filter(Boolean); + me.store.addFilter(filter); + } + }, + callback: function () { + if (!me.destroyed && wizard.down('#wizcontent').getActiveTab() === me) { + me.rstore.startUpdate(); + } + }, + }); + }, + + initComponent: function () { + let me = this; + me.rstore = Ext.create('Proxmox.data.UpdateStore', { + storeid: 'san-wizard-luns', + model: 'pve-san-lun', + interval: 3000, + proxy: { type: 'proxmox', url: `/api2/json/nodes/${Proxmox.NodeName}/scan/san-luns` }, + }); + me.store = Ext.create('Proxmox.data.DiffStore', { + rstore: me.rstore, + sortAfterUpdate: true, + }); + let inUse = (row) => row['used-by-storage']; + let noLunsText = gettext('No LUNs found. Check connections and array access.'); + let updateSelection = function () { + let row = me.getSelection(); + me.down('#selection').setValue(row && !inUse(row) ? row.wwid : ''); + }; + me.items = [ + { + xtype: 'textfield', + itemId: 'selection', + hidden: true, + allowBlank: false, + submitValue: false, + }, + { + xtype: 'component', + cls: 'pmx-hint', + margin: '0 0 10 0', + html: gettext( + 'A LUN that is in use cannot be selected. A LUN with data that is no longer needed has to be wiped under Node > SAN first.', + ), + }, + { + xtype: 'grid', + flex: 1, + store: me.store, + emptyText: noLunsText, + viewConfig: { + enableTextSelection: true, + getRowClass: (rec) => (inUse(rec.data) ? 'x-item-disabled' : ''), + }, + listeners: { + beforeselect: (sm, rec) => !inUse(rec.data), + selectionchange: updateSelection, + }, + columns: [ + { + text: gettext('Name'), + dataIndex: 'display-name', + flex: 1, + minWidth: 260, + renderer: Ext.htmlEncode, + }, + { text: 'LUN', dataIndex: 'iscsi-lun', width: 60 }, + { + text: gettext('Model'), + dataIndex: 'model', + width: 160, + renderer: (value, md, rec) => + Ext.htmlEncode([rec.get('vendor'), value].filter(Boolean).join(' ')), + }, + { + text: gettext('State'), + dataIndex: 'state', + width: 140, + renderer: PVE.SANUtils.renderLunState, + }, + { + text: gettext('Multipath'), + dataIndex: 'multipath', + width: 170, + renderer: PVE.SANUtils.renderSanLunMultipath, + }, + { + text: gettext('Used By'), + dataIndex: 'used-by', + width: 130, + renderer: Ext.htmlEncode, + }, + { + text: gettext('Size'), + dataIndex: 'size', + width: 100, + renderer: Proxmox.Utils.render_size, + }, + { + text: gettext('Device'), + dataIndex: 'devpath', + width: 180, + hidden: true, + renderer: Ext.htmlEncode, + }, + ], + tbar: [ + { + text: gettext('Reload'), + iconCls: 'fa fa-refresh', + handler: () => me.reload(), + }, + '->', + { + xtype: 'tbtext', + html: Ext.htmlEncode(`${gettext('Scan node')}: ${Proxmox.NodeName}`), + }, + ' ', + gettext('Search') + ':', + ' ', + { + xtype: 'pveRecordSearchField', + emptyText: gettext('Name, WWID, Path'), + searchFields: ['name', 'wwid', 'devpath', 'path-search'], + listeners: { + // no hit for a search is no sign of a connection problem + searchchange: function (field, query) { + let grid = me.down('grid'); + if (grid?.rendered) { + grid.setEmptyText( + query ? gettext('No LUNs match the search.') : noLunsText, + ); + } + }, + }, + }, + ], + }, + ]; + me.callParent(); + Proxmox.Utils.monStoreErrors(me.down('grid'), me.rstore); + me.mon(me.rstore, 'load', updateSelection); + me.mon(me.store, 'refresh', () => PVE.SANUtils.deselectHidden(me.down('grid'))); + let search = me.down('pveRecordSearchField'); + me.on('activate', function () { + search.setTargetStore(me.store); + me.reload(); + }); + // The setup can update the selected row after this step, which the search must not hide. + me.on('deactivate', function () { + me.rstore.stopUpdate(); + search.setTargetStore(null); + }); + me.on('destroy', () => { + me.store.destroy(); + me.rstore.destroy(); + }); + }, +}); diff --git a/www/manager6/storage/wizard/NodeIdentities.js b/www/manager6/storage/wizard/NodeIdentities.js new file mode 100644 index 000000000..a0ef62fee --- /dev/null +++ b/www/manager6/storage/wizard/NodeIdentities.js @@ -0,0 +1,94 @@ +Ext.define('pve-san-node-identity', { + extend: 'Ext.data.Model', + idProperty: 'node', + fields: ['node', 'state', 'iscsi-initiator-name'], +}); + +Ext.define('PVE.storage.wizard.NodeIdentities', { + extend: 'Ext.grid.Panel', + xtype: 'pveStorageWizardNodeIdentities', + height: 220, + disableSelection: true, + viewConfig: { enableTextSelection: true }, + columns: [ + { text: gettext('Node'), dataIndex: 'node', width: 100, renderer: Ext.htmlEncode }, + { + text: gettext('State'), + dataIndex: 'state', + width: 175, + renderer: PVE.SANUtils.renderState, + }, + { + text: gettext('Initiator Name'), + dataIndex: 'iscsi-initiator-name', + flex: 1, + renderer: Ext.htmlEncode, + }, + ], + + // Lists only the given nodes, or all nodes for none, which Copy then follows. + setNodes: function (nodes) { + let me = this; + nodes = [].concat(nodes || []).filter(Boolean); + if (nodes.length) { + me.store.addFilter({ id: 'nodes', filterFn: (rec) => nodes.includes(rec.get('node')) }); + } else { + me.store.removeFilter('nodes'); + } + }, + + initComponent: function () { + let me = this; + me.rstore = Ext.create('Proxmox.data.UpdateStore', { + storeid: 'san-wizard-identities', + model: 'pve-san-node-identity', + interval: 5000, + proxy: { + type: 'proxmox', + url: '/api2/json/cluster/multipath/status', + reader: { + type: 'json', + rootProperty: 'data', + transform: (raw) => ({ + ...raw, + data: Object.entries(raw.data.nodes).map(([node, report]) => ({ + ...report, + node, + })), + }), + }, + }, + }); + me.store = Ext.create('Proxmox.data.DiffStore', { + rstore: me.rstore, + sorters: ['node'], + sortAfterUpdate: true, + }); + me.tbar = [ + { + xtype: 'tbtext', + text: gettext('Allow the initiator names of the nodes that will use the target.'), + }, + '->', + { + text: gettext('Copy Initiator Names'), + iconCls: 'fa fa-clipboard', + handler: () => + PVE.Utils.copyToClipboard( + me.store + .getRange() + .map((rec) => rec.get('iscsi-initiator-name')) + .filter(Boolean) + .join('\n'), + ), + }, + ]; + me.callParent(); + Proxmox.Utils.monStoreErrors(me, me.rstore); + me.on('afterrender', () => me.rstore.startUpdate()); + me.on('destroy', () => { + me.store.destroy(); + me.rstore.destroy(); + }); + }, +}); diff --git a/www/manager6/storage/wizard/Wizard.js b/www/manager6/storage/wizard/Wizard.js new file mode 100644 index 000000000..3b4d4b8eb --- /dev/null +++ b/www/manager6/storage/wizard/Wizard.js @@ -0,0 +1,183 @@ +Ext.ns('PVE.storage.wizard'); + +PVE.storage.wizard.subject = (type) => + Ext.String.format(gettext('LVM on {0}'), PVE.Utils.format_storage_type(type)); + +PVE.storage.wizard.validateNodes = function () { + let nodes = [].concat(this.getValue() || []).filter(Boolean); + return ( + !nodes.length || + nodes.includes(Proxmox.NodeName) || + Ext.String.format( + gettext('Must include node "{0}", which sets up the volume group.'), + Proxmox.NodeName, + ) + ); +}; + +Ext.define('PVE.storage.wizard.SAN', { + extend: 'PVE.window.Wizard', + width: 1050, + height: 620, + + showError: function (message) { + if (this.destroyed) { + return; + } + this.down('#submit').enable(); + Ext.Msg.alert(gettext('Error'), message); + }, + + volumeSettings: function () { + let me = this; + let value = (name) => me.down(`field[name=${name}]`).getValue(); + return { + storage: value('storage'), + vgname: value('vgname'), + 'snapshot-as-volume-chain': value('snapshot-as-volume-chain') ? 1 : 0, + nodes: me.connection.nodes, + }; + }, + + // Adds the LVM storage with the volume settings as the last request of a setup. Only the node + // serving the web UI looked at the LUN, so show its state on the other nodes afterwards. + addLVMStorage: function (values, failure) { + let me = this; + let params = { type: 'lvm', shared: 1, content: 'images,rootdir', ...values }; + if (!params.nodes) { + delete params.nodes; + } + Proxmox.Utils.API2Request({ + url: '/storage', + method: 'POST', + params, + waitMsgTarget: me, + failure, + success: function () { + // the storage is added, also if the setup got closed in the meantime + if (me.destroyed) { + return; + } + let wwid = me.down('#luns').getSelection().wwid; + me.close(); + Ext.create('PVE.window.SANLunState', { + wwid, + storage: values.storage, + nodes: params.nodes, + autoShow: true, + }); + }, + }); + }, + + multipathSummary: function (lun) { + // an explicit entry takes precedence, also for a LUN of the connection storage + if (lun.multipath === 'manual') { + return PVE.SANUtils.multipathText('manual'); + } + return PVE.SANUtils.multipathText('storage', this.connection.storage); + }, + + updateSummary: function () { + let me = this; + let values = me.volumeSettings(); + let lun = me.down('#luns').getSelection(); + let rows = [ + [gettext('Connection Storage'), me.connection.storage], + [gettext('Storage ID'), values.storage], + [gettext('Volume Group'), values.vgname], + ['WWID', lun.wwid], + [gettext('Multipath'), me.multipathSummary(lun)], + [gettext('Size'), Proxmox.Utils.format_size(lun.size)], + [gettext('Nodes'), values.nodes || gettext('All (No restrictions)')], + [ + gettext('Allow Snapshots as Volume-Chain'), + Proxmox.Utils.format_boolean(values['snapshot-as-volume-chain']), + ], + ]; + me.down('#summary') + .getStore() + .setData(rows.map(([key, value]) => ({ key, value }))); + }, + + finish: function () { + let me = this; + let values = me.volumeSettings(); + let lun = me.down('#luns').getSelection(); + me.down('#submit').disable(); + PVE.storage.wizard.createIScsiLVM(me, values, lun); + }, + + initComponent: function () { + let me = this; + me.subject = PVE.storage.wizard.subject(me.wizardType); + me.title = Proxmox.Utils.dialog_title(me.subject, true, true); + let common = PVE.panel.StorageBase.commonFields(true); + let settings = { + xtype: 'inputpanel', + title: gettext('Volume Group'), + onlineHelp: 'storage_multipath', + items: [ + { ...common.id, fieldLabel: gettext('Storage ID') }, + { + xtype: 'textfield', + name: 'vgname', + fieldLabel: gettext('Volume Group'), + allowBlank: false, + vtype: 'StorageId', + }, + PVE.panel.StorageBase.volumeChainField(true, 'lvm'), + ], + }; + me.items = [ + { xtype: 'pveStorageWizardIScsiTarget', title: gettext('Target'), itemId: 'target' }, + { + xtype: 'pveStorageWizardLunSelect', + title: 'LUN', + itemId: 'luns', + onlineHelp: 'storage_multipath', + }, + settings, + { + title: gettext('Confirm'), + layout: 'fit', + items: [ + { + xtype: 'grid', + itemId: 'summary', + store: { fields: ['key', 'value'] }, + columns: [ + { + text: gettext('Setting'), + dataIndex: 'key', + width: 280, + renderer: Ext.htmlEncode, + }, + { + text: gettext('Value'), + dataIndex: 'value', + flex: 1, + cellWrap: true, + renderer: Ext.htmlEncode, + }, + ], + }, + ], + listeners: { activate: () => me.updateSummary() }, + onSubmit: () => me.finish(), + }, + ]; + me.callParent(); + let tabs = me.down('#wizcontent'); + tabs.on('tabchange', function (tp, tab) { + if (tab === me.down('#luns')) { + me.down('#back').disable(); + } + me.down('#submit').setText( + tab === me.down('#target') ? gettext('Next') : gettext('Finish'), + ); + }); + me.down('#submit').setText(gettext('Next')); + me.on('destroy', () => me.reloadCallback?.()); + }, +}); diff --git a/www/manager6/window/SANLunState.js b/www/manager6/window/SANLunState.js new file mode 100644 index 000000000..6d5221329 --- /dev/null +++ b/www/manager6/window/SANLunState.js @@ -0,0 +1,115 @@ +Ext.define('pve-san-lun-node', { + extend: 'Ext.data.Model', + idProperty: 'node', + fields: ['node', 'state', 'paths-active', 'paths-total', 'paths-expected'], +}); + +// Shows the state of the LUN of a new storage on each of its nodes, from the cluster-wide status. +Ext.define('PVE.window.SANLunState', { + extend: 'Ext.window.Window', + + modal: true, + width: 550, + height: 400, + layout: { type: 'vbox', align: 'stretch' }, + bodyPadding: 10, + + initComponent: function () { + let me = this; + if (!me.wwid || !me.storage) { + throw 'no LUN or storage specified'; + } + me.title = Ext.String.format(gettext('Storage {0}: LUN State'), me.storage); + // The other nodes set up a new LUN with their next status updates. + let pendingUntil = Date.now() + 60000; + let rstore = Ext.create('Proxmox.data.UpdateStore', { + storeid: 'san-lun-state', + model: 'pve-san-lun-node', + interval: 3000, + proxy: { + type: 'proxmox', + url: '/api2/json/cluster/multipath/status', + reader: { + type: 'json', + rootProperty: 'data', + transform: function (raw) { + let lun = raw.data?.luns?.find((entry) => entry.wwid === me.wwid); + // other storages or entries of the LUN can expect it on more nodes + let wanted = me.nodes?.split(','); + let nodes = Object.entries(lun?.nodes ?? {}).filter( + ([node]) => !wanted || wanted.includes(node), + ); + return { ...raw, data: nodes.map(([node, state]) => ({ ...state, node })) }; + }, + }, + }, + }); + let store = Ext.create('Proxmox.data.DiffStore', { + rstore, + sorters: ['node'], + sortAfterUpdate: true, + }); + me.items = [ + { + xtype: 'component', + margin: '0 0 10 0', + html: Ext.htmlEncode( + Ext.String.format( + gettext( + 'Storage "{0}" was added. Guests on this storage cannot run on a node that stays on "Missing": check its access to the LUN on the array.', + ), + me.storage, + ), + ), + }, + { + xtype: 'grid', + flex: 1, + store, + disableSelection: true, + emptyText: gettext('No node reported this LUN yet.'), + columns: [ + { + text: gettext('Node'), + dataIndex: 'node', + flex: 1, + renderer: Ext.htmlEncode, + }, + { + text: gettext('State'), + dataIndex: 'state', + flex: 1, + renderer: function (value, metaData, rec) { + if (value === 'missing' && Date.now() < pendingUntil) { + let tip = gettext( + 'Not reported by the node yet; the SAN view shows that as "Missing".', + ); + metaData.tdAttr = `data-qtip="${Ext.htmlEncode(Ext.htmlEncode(tip))}"`; + return ` ${Ext.htmlEncode(gettext('Pending'))}`; + } + return PVE.SANUtils.renderState( + PVE.SANUtils.lunState(value, rec.get('paths-total')), + ); + }, + }, + { + text: gettext('Active Paths'), + dataIndex: 'paths-active', + width: 120, + renderer: (value, metaData, rec) => + value === undefined + ? '' + : Ext.htmlEncode(PVE.SANUtils.pathCount(rec.data)), + }, + ], + }, + ]; + me.callParent(); + Proxmox.Utils.monStoreErrors(me.down('grid'), rstore); + me.on('destroy', function () { + store.destroy(); + rstore.destroy(); + }); + rstore.startUpdate(); + }, +});