[pve-devel] [PATCH manager 3/4] gui: ceph osd: improve version hints

Dominik Csapak d.csapak at proxmox.com
Fri Jul 19 10:17:02 CEST 2019


we now traverse the whole tree for the versions and save not only
the maxversion but if we have mixed versions at all

the traversal contains code to inject the host versions into the treenodes

this way we can omit any icon in case everything is on the same level
and if not we:

* show a check at update hosts and services
* show a 'restart' symbol for osds that only need a restart
* show an 'upgrade' symbol (fa-upload) for osds/hosts that need
  a package upgrade

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/ceph/OSD.js | 47 +++++++++++++++++++++++++++++++---------
 1 file changed, 37 insertions(+), 10 deletions(-)

diff --git a/www/manager6/ceph/OSD.js b/www/manager6/ceph/OSD.js
index 7e197c90..42cec5cb 100644
--- a/www/manager6/ceph/OSD.js
+++ b/www/manager6/ceph/OSD.js
@@ -173,6 +173,7 @@ Ext.define('PVE.node.CephOsdTree', {
 	    nodename: '',
 	    flags: [],
 	    maxversion: '0',
+	    mixedversions: false,
 	    versions: {},
 	    isOsd: false,
 	    downOsd: false,
@@ -213,13 +214,36 @@ Ext.define('PVE.node.CephOsdTree', {
 		    }
 		    vm.set('versions', data.versions);
 		    // extract max version
-		    var maxversion = vm.get('maxversion');
-		    Object.values(data.versions || {}).forEach(function(version) {
-			if (PVE.Utils.compare_ceph_versions(version, maxversion) > 0) {
-			    maxversion = version;
+		    var maxversion = "0";
+		    var mixedversions = false;
+		    var traverse;
+		    traverse = function(node, fn) {
+			fn(node);
+			if (Array.isArray(node.children)) {
+			    node.children.forEach(c => { traverse(c, fn); });
 			}
+		    };
+		    traverse(data.root, node => {
+			// compatibility for old api call
+			if (node.type === 'host' && node.version === undefined) {
+			    node.version = data.versions[node.name];
+			}
+
+			if (node.version === undefined) {
+			    return;
+			}
+
+			if (node.version !== maxversion && maxversion !== "0") {
+			    mixedversions = true;
+			}
+
+			if (PVE.Utils.compare_ceph_versions(node.version, maxversion) > 0) {
+			    maxversion = node.version;
+			}
+
 		    });
 		    vm.set('maxversion', maxversion);
+		    vm.set('mixedversions', mixedversions);
 		    sm.deselectAll();
 		    me.setRootNode(data.root);
 		    me.expandAll();
@@ -386,12 +410,15 @@ Ext.define('PVE.node.CephOsdTree', {
 	    var versions = vm.get('versions');
 	    var icon = "";
 	    var version = value || "";
-	    if (value && value != vm.get('maxversion')) {
-		icon = PVE.Utils.get_ceph_icon_html('HEALTH_OLD');
-	    }
-
-	    if (!value && rec.data.type == 'host') {
-		version = versions[rec.data.name] || Proxmox.Utils.unknownText;
+	    var maxversion = vm.get('maxversion');
+	    if (value && value != maxversion) {
+		if (rec.data.type === 'host' || versions[rec.data.host] !== maxversion) {
+		    icon = PVE.Utils.get_ceph_icon_html('HEALTH_UPGRADE');
+		} else {
+		    icon = PVE.Utils.get_ceph_icon_html('HEALTH_OLD');
+		}
+	    } else if (value && vm.get('mixedversions')) {
+		icon = PVE.Utils.get_ceph_icon_html('HEALTH_OK');
 	    }
 
 	    return icon + version;
-- 
2.20.1





More information about the pve-devel mailing list