From e6a1160f95f3c27f7c1d3277defd8ca982be21e5 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 5 Jun 2023 18:03:46 +0200 Subject: [PATCH] ui: ceph install: add hints depending on selected repo and subscriptions None hint required if all nodes have subscriptions and enterprise repo is selected, but otherwise give some hints for better UX and to (hopefully) reduce the chance for mishaps. We might want to highlight the label to improve visibility tough. Signed-off-by: Thomas Lamprecht --- www/manager6/Utils.js | 8 +++++ www/manager6/ceph/CephInstallWizard.js | 45 +++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js index d5dd2999..cc7e8ce1 100644 --- a/www/manager6/Utils.js +++ b/www/manager6/Utils.js @@ -37,6 +37,14 @@ Ext.define('PVE.Utils', { +'' +'www.proxmox.com to get a list of available options.', + getClusterSubscriptionLevel: async function() { + let { result } = await Proxmox.Async.api2({ url: '/cluster/status' }); + let levelMap = Object.fromEntries( + result.data.filter(v => v.type === 'node').map(v => [v.name, v.level]), + ); + return levelMap; + }, + kvm_ostypes: { 'Linux': [ { desc: '6.x - 2.6 Kernel', val: 'l26' }, diff --git a/www/manager6/ceph/CephInstallWizard.js b/www/manager6/ceph/CephInstallWizard.js index 2a7bb381..009161d0 100644 --- a/www/manager6/ceph/CephInstallWizard.js +++ b/www/manager6/ceph/CephInstallWizard.js @@ -149,6 +149,31 @@ Ext.define('PVE.ceph.CephInstallWizard', { cephRepo: 'enterprise', configuration: true, isInstalled: false, + nodeHasSubscription: true, // avoid warning hint until fully loaded + allHaveSubscription: true, // avoid warning hint until fully loaded + }, + formulas: { + repoHintHidden: get => get('allHaveSubscription') && get('cephRepo') === 'enterprise', + repoHint: function(get) { + let repo = get('cephRepo'); + let nodeSub = get('nodeHasSubscription'), allSub = get('allHaveSubscription'); + + if (repo === 'enterprise') { + if (!nodeSub) { + return gettext('The enterprise repository is enabled, but there is no active subscription!'); + } else if (!allSub) { + //return gettext('Not all nodes in the cluster have an active subscription, so not all have access to the enterprise repository and therefore may receive upgrades sooner!'); + return gettext('Not all nodes have an active subscription, which is required for cluster-wide enterprise repo access'); + } + return ''; // should be hidden + } else if (repo === 'no-subscription') { + return allSub + ? gettext("Cluster has active subscriptions and would be elligible for using the enterprise repository.") + : gettext("The no-subscription repository is not the best choice for production setups."); + } else { + return gettext('The test repository should only be used for test setups or after consulting the official Proxmox support!'); + } + }, }, }, cbindData: { @@ -175,11 +200,19 @@ Ext.define('PVE.ceph.CephInstallWizard', { }, onShow: function() { this.callParent(arguments); + let viewModel = this.getViewModel(); var isInstalled = this.getViewModel().get('isInstalled'); if (isInstalled) { - this.getViewModel().set('configuration', false); + viewModel.set('configuration', false); this.setInitialTab(2); } + + PVE.Utils.getClusterSubscriptionLevel().then(subcriptionMap => { + viewModel.set('nodeHasSubscription', !!subcriptionMap[this.nodename]); + + let allHaveSubscription = Object.values(subcriptionMap).every(level => !!level); + viewModel.set('allHaveSubscription', allHaveSubscription); + }); }, items: [ { @@ -204,6 +237,16 @@ Ext.define('PVE.ceph.CephInstallWizard', { { flex: 1, }, + { + xtype: 'displayfield', + fieldLabel: gettext('Hint'), + submitValue: false, + labelWidth: 50, + bind: { + value: '{repoHint}', + hidden: '{repoHintHidden}', + }, + }, { xtype: 'pveCephHighestVersionDisplay', labelWidth: 150,