[pve-devel] [PATCH cluster v5 00/17] Allow adding/deleting nodes and cluster creation over API

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Jan 26 14:25:10 CET 2018


Fifth iteration of this series, see [1] for the v4 cover letter.

Changes in other packages are now in place.

Higher level changes:
* Split the v4 03/15 refactor patch in two parts, should be easier to
  understand
* add a patch which combines the ringX_addr and nodeid parameter
  format descriptions, suggested by Fabian
* version the libpve-common-perl dependency when introducing the use
  of the fingerprint format
* reword and enhance some commit messageso

Just diff this and v3 for more details, the changes are not that big.

Tested with CLI tool pvecm and through an API client, see below for a
script doing this with our apiclient library.

cheers,
Thomas

[1]: https://pve.proxmox.com/pipermail/pve-devel/2018-January/030177.html

Thomas Lamprecht (17):
  move addnode/delnode from CLI to cluster config API
  tell cluster log when adding/deleting a node
  node add: factor out checks for joining
  node add: factor out local joining steps
  assert_joinable: simplify error and warning handling
  use run_command instead of system
  return cluster config and authkey in addnode API call
  api/cluster: add join endpoint
  pvecm add: use API by default to join cluster
  cluster create: factor out initial corosync config assembly
  cluster create: restart corosync & pmxfs in one go and say so
  move cluster create to API
  api/cluster: create cluster in forked worker
  factor out common parameter definitions
  api/cluster: add endpoint to GET cluster join information
  use resolved IP address for ring0_addr as default
  lock locally on create and add

 data/PVE/API2/ClusterConfig.pm | 505 +++++++++++++++++++++++++++++++++++-
 data/PVE/CLI/pvecm.pm          | 570 +++--------------------------------------
 data/PVE/Cluster.pm            | 137 +++++++++-
 data/PVE/Corosync.pm           |  73 ++++++
 debian/control.in              |   4 +-
 5 files changed, 754 insertions(+), 535 deletions(-)

-- 
2.14.2

Updated API Join example:
--
#!/usr/bin/perl

use strict;
use warnings;

use PVE::APIClient::LWP;

use JSON;

sub p { print to_json($_[0], { pretty => 1, canonical => 1}); }

# TODO: ADAPT BELOW
my $ip_cluster_node = '192.168.30.31';
my $pass_cluster_node = "12345";

my $ip_joinee = '192.168.30.32';
my $pass_joinee = '12345';

my $joinee = PVE::APIClient::LWP->new(
    username => 'root at pam',
    password => $pass_joinee,
    host => $ip_joinee,
    manual_verification => 1,
);
my $cluster_node = PVE::APIClient::LWP->new(
    username => 'root at pam',
    password =>$pass_cluster_node,
    host => $ip_cluster_node,
    manual_verification => 1,
);

my $joininfo = $cluster_node->get("/cluster/config/join", {});

p($joininfo);

my $upid = $joinee->post("/cluster/config/join", {
    hostname => $joininfo->{nodelist}[0]->{pve_addr},
    fingerprint => $joininfo->{nodelist}[0]->{pve_fp},
    password => $pass_cluster_node,
});

print "join task upid: $upid\n";

my $task_state;
my $errors = 0;
while (1) {
    eval { $task_state = $joinee->get("/nodes/localhost/tasks/$upid/status", {}) };
    if (my $err = $@) {
	warn $@;
	$errors++;
	die "to much errors from querying task state!\n" if $errors > 5;
    }

    last if $task_state->{status} eq 'stopped';
    sleep 1;
}

print "join task finished, res:\n";

p($task_state)




More information about the pve-devel mailing list