[pve-devel] [PATCH cluster v3 13/14] api/cluster: add endpoint to GET cluster join information

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Dec 19 12:52:38 CET 2017


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.
---

no changes

 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 123cecb..c0fb57e 100644
--- a/data/PVE/API2/ClusterConfig.pm
+++ b/data/PVE/API2/ClusterConfig.pm
@@ -399,6 +399,48 @@ __PACKAGE__->register_method ({
     }});
 
 __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