[pve-devel] [RFC cluster v2 10/10] api/cluster: add join_info endpoint

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


Returns all relevant information for joining this cluster securely
over the API.

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

diff --git a/data/PVE/API2/ClusterConfig.pm b/data/PVE/API2/ClusterConfig.pm
index 9bbefaf..11005e6 100644
--- a/data/PVE/API2/ClusterConfig.pm
+++ b/data/PVE/API2/ClusterConfig.pm
@@ -206,6 +206,48 @@ my $peer_can_use_api = sub {
 };
 
 __PACKAGE__->register_method ({
+    name => 'join_info',
+    path => 'join',
+    method => 'GET',
+    description => "Returns the information needed to join this cluster.",
+    parameters => {
+	additionalProperties => 0,
+	properties => { },
+    },
+    returns => {
+	type => 'object',
+	additionalProperties => 0,
+	properties => {
+	    ip_addr => { type => 'string', format => 'ip' },
+	    fingerprint => {
+		type => 'string',
+		pattern => '^(:?[A-Z0-9]{2}:){31}[A-Z0-9]{2}$',
+	    },
+	    totem => { type => 'object' },
+	    config_digest => { type => 'string' },
+	},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $nodename = PVE::INotify::nodename();
+
+	PVE::Cluster::cfs_update(1);
+	my $conf = PVE::Cluster::cfs_read_file('corosync.conf');
+	my $totem_cfg = $conf->{main}->{totem} // {};
+	my $corosync_config_digest = $conf->{digest};
+
+	my $res = {
+	    fingerprint => PVE::Cluster::get_node_fingerprint($nodename),
+	    ip_addr => scalar(PVE::Cluster::remote_node_ip($nodename)),
+	    totem => $totem_cfg,
+	    config_digest => $corosync_config_digest,
+	};
+
+	return $res;
+    }});
+
+__PACKAGE__->register_method ({
     name => 'join',
     path => 'join',
     method => 'POST',
-- 
2.11.0





More information about the pve-devel mailing list