[pve-devel] applied: [PATCH manager 1/2] api: ceph version: actually get full version

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Nov 15 19:10:16 CET 2019


add and change the return signature for the wantarray case, which can
safely done as this is only used once (statd), and there only the
first elemen, the full version string, is used - so no breakage
potential there

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 PVE/Ceph/Tools.pm | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/PVE/Ceph/Tools.pm b/PVE/Ceph/Tools.pm
index b95eb424..dbe6590d 100644
--- a/PVE/Ceph/Tools.pm
+++ b/PVE/Ceph/Tools.pm
@@ -49,12 +49,21 @@ sub get_local_version {
 
     if (check_ceph_installed('ceph_bin', $noerr)) {
 	my $ceph_version;
-	run_command([$ceph_service->{ceph_bin}, '--version'],
-	            noerr => $noerr,
-	            outfunc => sub { $ceph_version = shift; });
-	if ($ceph_version && $ceph_version =~ /^ceph.*\s((\d+)\.(\d+)\.(\d+))/) {
-	    # return (version, major, minor, patch) : major;
-	    return wantarray ? ($1, $2, $3, $4) : $2;
+	run_command(
+	    [ $ceph_service->{ceph_bin}, '--version' ],
+	    noerr => $noerr,
+	    outfunc => sub { $ceph_version = shift if !defined $ceph_version },
+	);
+	return undef if !defined $ceph_version;
+
+	if ($ceph_version =~ /^ceph.*\s(\d+(?:\.\d+)+)\s+(?:\(([a-zA-Z0-9]+)\))?/) {
+	    my ($version, $buildcommit) = ($1, $2);
+	    my $subversions = [ split(/\.|-/, $version) ];
+
+	    # return (version, buildid, major, minor, ...) : major;
+	    return wantarray
+		? ($version, $buildcommit, $subversions)
+		: $subversions->[0];
 	}
     }
 
-- 
2.20.1





More information about the pve-devel mailing list