all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stoiko Ivanov <s.ivanov@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-api 3/6] api: cluster: add update-fingerprints call
Date: Mon, 15 Mar 2021 23:01:32 +0100	[thread overview]
Message-ID: <20210315220135.25988-4-s.ivanov@proxmox.com> (raw)
In-Reply-To: <20210315220135.25988-1-s.ivanov@proxmox.com>

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
---
 src/PMG/API2/Cluster.pm | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

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;
-- 
2.20.1





  parent reply	other threads:[~2021-03-15 22:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 22:01 [pmg-devel] [PATCH pmg-api 0/6] add mechanism to update certificate fingerprints in cluster Stoiko Ivanov
2021-03-15 22:01 ` [pmg-devel] [PATCH pmg-api 1/6] cluster: refactor rsync_command Stoiko Ivanov
2021-03-15 22:01 ` [pmg-devel] [PATCH pmg-api 2/6] cluster: add helper to get remote cert fingerprint Stoiko Ivanov
2021-03-15 22:01 ` Stoiko Ivanov [this message]
2021-03-15 22:01 ` [pmg-devel] [PATCH pmg-api 4/6] cluster: add trigger_update_fingerprints Stoiko Ivanov
2021-03-15 22:01 ` [pmg-devel] [PATCH pmg-api 5/6] pmgcm: add trigger-update-fingerprint Stoiko Ivanov
2021-03-15 22:01 ` [pmg-devel] [PATCH pmg-api 6/6] api: certificates: trigger fingerprint update Stoiko Ivanov
2021-03-16 18:18 ` [pmg-devel] applied-series: [PATCH pmg-api 0/6] add mechanism to update certificate fingerprints in cluster Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210315220135.25988-4-s.ivanov@proxmox.com \
    --to=s.ivanov@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal