[pve-devel] [PATCH cluster v5 15/17] api/cluster: add endpoint to GET cluster join information
Thomas Lamprecht
t.lamprecht at proxmox.com
Fri Jan 26 14:25:25 CET 2018
Returns all relevant information for joining this cluster over the
current connected node securely over the API, address, fingerprint,
totem config section and (not directly needed but possibly useful)
cluster configuration digest.
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
data/PVE/API2/ClusterConfig.pm | 72 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 72 insertions(+)
diff --git a/data/PVE/API2/ClusterConfig.pm b/data/PVE/API2/ClusterConfig.pm
index daabcf1..fdcf52a 100644
--- a/data/PVE/API2/ClusterConfig.pm
+++ b/data/PVE/API2/ClusterConfig.pm
@@ -389,6 +389,78 @@ __PACKAGE__->register_method ({
return undef;
}});
+__PACKAGE__->register_method ({
+ name => 'join_info',
+ path => 'join',
+ method => 'GET',
+ description => "Get information needed to join this cluster over the connected node.",
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node', {
+ description => "The node for which the joinee gets the nodeinfo. ",
+ default => "current connected node",
+ optional => 1,
+ }),
+ },
+ },
+ returns => {
+ type => 'object',
+ additionalProperties => 0,
+ properties => {
+ nodelist => {
+ type => 'array',
+ items => {
+ type => "object",
+ additionalProperties => 1,
+ properties => {
+ name => get_standard_option('pve-node'),
+ nodeid => get_standard_option('corosync-nodeid'),
+ ring0_addr => get_standard_option('corosync-ring0-addr'),
+ quorum_votes => { type => 'integer', minimum => 0 },
+ pve_addr => { type => 'string', format => 'ip' },
+ pve_fp => get_standard_option('fingerprint-sha256'),
+ },
+ },
+ },
+ preferred_node => get_standard_option('pve-node'),
+ totem => { type => 'object' },
+ config_digest => { type => 'string' },
+ },
+ },
+ code => sub {
+ my ($param) = @_;
+
+ my $nodename = $param->{node} // PVE::INotify::nodename();
+
+ PVE::Cluster::cfs_update(1);
+ my $conf = PVE::Cluster::cfs_read_file('corosync.conf');
+
+ die "node is not in a cluster, no join info available!\n"
+ if !($conf && $conf->{main});
+
+ my $totem_cfg = $conf->{main}->{totem} // {};
+ my $nodelist = $conf->{main}->{nodelist}->{node} // {};
+ my $corosync_config_digest = $conf->{digest};
+
+ die "unknown node '$nodename'\n" if ! $nodelist->{$nodename};
+
+ foreach my $name (keys %$nodelist) {
+ my $node = $nodelist->{$name};
+ $node->{pve_fp} = PVE::Cluster::get_node_fingerprint($name);
+ $node->{pve_addr} = scalar(PVE::Cluster::remote_node_ip($name));
+ }
+
+ my $res = {
+ nodelist => [ values %$nodelist ],
+ preferred_node => $nodename,
+ totem => $totem_cfg,
+ config_digest => $corosync_config_digest,
+ };
+
+ return $res;
+ }});
+
__PACKAGE__->register_method ({
name => 'join',
path => 'join',
--
2.14.2
More information about the pve-devel
mailing list