public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager] api: metrics/server: test connection on add/update
@ 2020-11-25 12:56 Dominik Csapak
  2020-11-25 13:56 ` [pve-devel] applied: " Thomas Lamprecht
  2020-12-03 16:55 ` [pve-devel] " Thomas Lamprecht
  0 siblings, 2 replies; 5+ messages in thread
From: Dominik Csapak @ 2020-11-25 12:56 UTC (permalink / raw)
  To: pve-devel

just a basic check, but better than not checking at all

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 PVE/API2/Cluster/MetricServer.pm | 5 +++++
 PVE/Status/Plugin.pm             | 7 +++++++
 2 files changed, 12 insertions(+)

diff --git a/PVE/API2/Cluster/MetricServer.pm b/PVE/API2/Cluster/MetricServer.pm
index b96228b0..9a14985e 100644
--- a/PVE/API2/Cluster/MetricServer.pm
+++ b/PVE/API2/Cluster/MetricServer.pm
@@ -159,6 +159,9 @@ __PACKAGE__->register_method ({
 		if $cfg->{ids}->{$id};
 
 	    my $opts = $plugin->check_config($id, $param, 1, 1);
+
+	    $plugin->test_connection($opts);
+
 	    $cfg->{ids}->{$id} = $opts;
 
 	    PVE::Cluster::cfs_write_file('status.cfg', $cfg);
@@ -198,6 +201,8 @@ __PACKAGE__->register_method ({
 	    my $plugin = PVE::Status::Plugin->lookup($data->{type});
 	    my $opts = $plugin->check_config($id, $param, 0, 1);
 
+	    $plugin->test_connection($opts);
+
 	    for my $k (keys %$opts) {
 		$data->{$k} = $opts->{$k};
 	    }
diff --git a/PVE/Status/Plugin.pm b/PVE/Status/Plugin.pm
index 0faf0da6..c3e0bec1 100644
--- a/PVE/Status/Plugin.pm
+++ b/PVE/Status/Plugin.pm
@@ -126,6 +126,13 @@ sub send {
 	or die "failed to send metrics: $!\n";
 }
 
+sub test_connection {
+    my ($class, $cfg) = @_;
+
+    my $conn = $class->_connect($cfg);
+    $class->_disconnect($conn);
+}
+
 sub update_node_status {
     my ($class, $txn, $node, $data, $ctime) = @_;
     die "please implement inside plugin";
-- 
2.20.1





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-07 14:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 12:56 [pve-devel] [PATCH manager] api: metrics/server: test connection on add/update Dominik Csapak
2020-11-25 13:56 ` [pve-devel] applied: " Thomas Lamprecht
2020-12-03 16:55 ` [pve-devel] " Thomas Lamprecht
2020-12-07 14:30   ` Thomas Lamprecht
2020-12-07 14:32     ` Dominik Csapak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal