]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: ceph install: add hints depending on selected repo and subscriptions
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 5 Jun 2023 16:03:46 +0000 (18:03 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 5 Jun 2023 17:04:12 +0000 (19:04 +0200)
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 <t.lamprecht@proxmox.com>
www/manager6/Utils.js
www/manager6/ceph/CephInstallWizard.js

index d5dd2999081ec6970bd2122da9d61caf43d3ce0b..cc7e8ce17ffe4c87acb83f64b44c0ccff425eadb 100644 (file)
@@ -37,6 +37,14 @@ Ext.define('PVE.Utils', {
       +'<a target="_blank" href="https://www.proxmox.com/products/proxmox-ve/subscription-service-plans">'
       +'www.proxmox.com</a> 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' },
index 2a7bb381a6739397e57c17cadca0fe8555ab4d95..009161d0432f7d25bfe6ab3bbb8ffd5682ffa61f 100644 (file)
@@ -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,