X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=src%2FPMG%2FAPI2%2FCluster.pm;h=07aa8fa7b12386c36d67c0e11e0652d64fbd14fb;hb=54bc8ad60dc9068ede29bfe62ec3dbb85cea2a00;hp=7eab761e008fa1b850ff35cfa3deca9230183f36;hpb=2930bbb211c1028ddfd845210b8a42fd128323ae;p=pmg-api.git diff --git a/src/PMG/API2/Cluster.pm b/src/PMG/API2/Cluster.pm index 7eab761..07aa8fa 100644 --- a/src/PMG/API2/Cluster.pm +++ b/src/PMG/API2/Cluster.pm @@ -111,6 +111,7 @@ __PACKAGE__->register_method({ { name => 'status' }, { name => 'create' }, { name => 'join' }, + { name => 'update-fingerprints' }, ]; return $result; @@ -451,5 +452,44 @@ __PACKAGE__->register_method({ return PMG::ClusterConfig::lock_config($code, "cluster join failed"); }}); +__PACKAGE__->register_method({ + name => 'update_fingerprints', + path => 'update-fingerprints', + method => 'POST', + description => "Update API certificate fingerprints (by fetching it via ssh).", + proxyto => 'master', + protected => 1, + parameters => { + additionalProperties => 0, + }, + returns => { type => 'null' }, + code => sub { + my ($param) = @_; + + my $code = sub { + my $cinfo = PMG::ClusterConfig->new(); + + die "no cluster defined\n" if !scalar(keys %{$cinfo->{ids}}); + + my $localcid = $cinfo->{local}->{cid}; + + foreach my $cid (keys %{$cinfo->{ids}}) { + my $d = $cinfo->{ids}->{$cid}; + my $fp; + if ($d->{cid} == $localcid) { + $fp = PMG::Cluster::read_local_ssl_cert_fingerprint(); + } else { + $fp = PMG::Cluster::get_remote_cert_fingerprint($d); + } + $cinfo->{ids}->{$d->{cid}}->{fingerprint} = $fp; + } + + $cinfo->write(); + + return; + }; + + PMG::ClusterConfig::lock_config($code, "update fingerprints failed"); + }}); 1;