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 <[email protected]>
---
 data/PVE/API2/ClusterConfig.pm | 53 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/data/PVE/API2/ClusterConfig.pm b/data/PVE/API2/ClusterConfig.pm
index 8c88a17..e44cd85 100644
--- a/data/PVE/API2/ClusterConfig.pm
+++ b/data/PVE/API2/ClusterConfig.pm
@@ -396,6 +396,59 @@ __PACKAGE__->register_method ({
     }});
 
 __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. ",
+                              #"Defaults to connected (current) node.",
+               default => "current connected node",
+               optional => 1,
+           }),
+       },
+    },
+    returns => {
+       type => 'object',
+       additionalProperties => 0,
+       properties => {
+           nodeinfo => {
+               type => 'object',
+               properties => {
+                   addr => { type => 'string', format => 'ip' },
+                   fp => get_standard_option('fingerprint-sha256'),
+               }
+           },
+           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');
+       my $totem_cfg = $conf->{main}->{totem} // {};
+       my $corosync_config_digest = $conf->{digest};
+
+       my $res = {
+           nodeinfo => {
+               fp => PVE::Cluster::get_node_fingerprint($nodename),
+               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


_______________________________________________
pve-devel mailing list
[email protected]
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to