[pve-devel] [RFC cluster v2 05/10] api/join: check if peer supports addnode over API
Fabian Grünbichler
f.gruenbichler at proxmox.com
Wed Dec 6 16:07:01 CET 2017
this should probably have some kind of place holder remark so that we
don't forget to fill in the correct version when applying. the error
message could also contain the needed version and package so that the
user has an idea what is wrong ;)
On Mon, Dec 04, 2017 at 12:11:12PM +0100, Thomas Lamprecht wrote:
> 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
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list