[pve-devel] [RFC cluster v2 05/10] api/join: check if peer supports addnode over API

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Dec 4 12:11:12 CET 2017


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 data/PVE/API2/ClusterConfig.pm | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/data/PVE/API2/ClusterConfig.pm b/data/PVE/API2/ClusterConfig.pm
index 9a4d9f5..97706d9 100644
--- a/data/PVE/API2/ClusterConfig.pm
+++ b/data/PVE/API2/ClusterConfig.pm
@@ -96,6 +96,23 @@ my $config_change_lock = sub {
     });
 };
 
+my $peer_can_use_api = sub {
+    my ($conn) = @_;
+
+    print "Probe peer cluster package version...\n";
+    my $res = $conn->get("/nodes/localhost/apt/versions");
+
+    my $api_ok = undef;
+    foreach my $pkg (@$res) {
+	next if $pkg->{Package} ne 'pve-cluster';
+	if ($pkg->{OldVersion} =~ m/^(\d\.\d)-(\d+)/) {
+	    my ($version, $release) = ($1, $2);
+	    $api_ok = 1 if $version >= 5.1 && $release >= 16;
+	}
+    }
+
+    return $api_ok;
+};
 
 __PACKAGE__->register_method ({
     name => 'join',
@@ -197,6 +214,10 @@ __PACKAGE__->register_method ({
 
 	print "Login succeeded.\n";
 
+	if (!$peer_can_use_api->($conn)) {
+	    die "Cannot use API to join, peer is not up to date!\n";
+	}
+
 	my $args = {
 	    node => $nodename,
 	};
-- 
2.11.0





More information about the pve-devel mailing list