From 35306f47678b0e459f705a9bcd59ae3dbcdc8729 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 31 May 2019 15:39:48 +0200 Subject: [PATCH] followup: make ceph version handling more flexible ceph has a bad reputation for chaging such minor things a few times, even during a stable release, and as here a bit more flexibillity cost exactly nothing let's do so and accept versions with one to arbitrary version levels Signed-off-by: Thomas Lamprecht --- www/manager6/Utils.js | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js index 4dc8ab6a..4be22f7f 100644 --- a/www/manager6/Utils.js +++ b/www/manager6/Utils.js @@ -108,7 +108,7 @@ Ext.define('PVE.Utils', { utilities: { } if (service.ceph_version) { - var match = service.ceph_version.match(/version (\d+\.\d+\.\d+)/); + var match = service.ceph_version.match(/version (\d+(\.\d+)*)/); if (match) { return match[1]; } @@ -121,32 +121,26 @@ Ext.define('PVE.Utils', { utilities: { if (a === b) { return 0; } + let avers = a.toString().split('.'); + let bvers = b.toString().split('.'); - var match_a = a.toString().match(/^(\d+)\.(\d+).(\d+)$/); - var match_b = b.toString().match(/^(\d+)\.(\d+).(\d+)$/); + while (true) { + let av = avers.shift(); + let bv = bvers.shift(); - if (!match_a && !match_b) { - // both versions invalid/undefined - return 0; - } else if(!match_a) { - // a is undefined/invalid but b not - return -1; - } else if(!match_b) { - // b is undefined/invalid but a not - return 1; - } - - var i; - for (i = 1; i <= 3; i++) { - var ver_a = parseInt(match_a[i], 10); - var ver_b = parseInt(match_b[i], 10); - if (ver_a !== ver_b) { - return ver_a - ver_b; + if (av === undefined && bv === undefined) { + return 0; + } else if (av === undefined) { + return -1; + } else if (bv === undefined) { + return 1; + } else { + let diff = parseInt(av, 10) - parseInt(bv, 10); + if (diff != 0) return diff; + // else we need to look at the next parts } } - // all parts were the same - return 0; }, get_ceph_icon_html: function(health, fw) {