[pmg-devel] [PATCH pmg-api 4/6] cluster: add trigger_update_fingerprints
Stoiko Ivanov
s.ivanov at proxmox.com
Mon Mar 15 23:01:33 CET 2021
this commit adds a method that sends a POST request to
'/config/cluster/update-fingerprints' on the master node in a cluster.
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
src/PMG/Cluster.pm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/PMG/Cluster.pm b/src/PMG/Cluster.pm
index 49ba7d9..e9217fe 100644
--- a/src/PMG/Cluster.pm
+++ b/src/PMG/Cluster.pm
@@ -310,6 +310,32 @@ sub get_remote_cert_fingerprint {
return $fp;
}
+sub trigger_update_fingerprints {
+ my ($cinfo) = @_;
+
+ my $master = $cinfo->{master} || die "unable to lookup master node\n";
+ my $master_fp = $master->{fingerprint};
+
+ # if running on master the current fingerprint for the API-connection is needed
+ if ($cinfo->{local}->{type} eq 'master') {
+ $master_fp = PMG::Cluster::read_local_ssl_cert_fingerprint();
+ }
+
+ my $ticket = PMG::Ticket::assemble_ticket('root at pam');
+ my $csrftoken = PMG::Ticket::assemble_csrf_prevention_token('root at pam');
+ my $conn = PVE::APIClient::LWP->new(
+ ticket => $ticket,
+ csrftoken => $csrftoken,
+ cookie_name => 'PMGAuthCookie',
+ host => $master->{ip},
+ cached_fingerprints => {
+ $master_fp => 1,
+ });
+
+ $conn->post("/config/cluster/update-fingerprints", {});
+ return undef;
+}
+
my $rsync_command = sub {
my ($host_key_alias, @args) = @_;
--
2.20.1
More information about the pmg-devel
mailing list