public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 2/7] status/plugin: extend send/_connect/_disconnect/test_connection
Date: Wed,  2 Dec 2020 10:21:07 +0100	[thread overview]
Message-ID: <20201202092113.15911-5-d.csapak@proxmox.com> (raw)
In-Reply-To: <20201202092113.15911-1-d.csapak@proxmox.com>

by providing the id or cfg to have better context in those methods
we will need that for influxdb http api

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 PVE/ExtMetric.pm     |  4 ++--
 PVE/Status/Plugin.pm | 14 +++++++-------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/PVE/ExtMetric.pm b/PVE/ExtMetric.pm
index 448d3925..3358c359 100644
--- a/PVE/ExtMetric.pm
+++ b/PVE/ExtMetric.pm
@@ -49,7 +49,7 @@ sub transactions_start {
     foreach_plug($cfg, sub {
 	my ($plugin, $id, $plugin_config) = @_;
 
-	my $connection = $plugin->_connect($plugin_config);
+	my $connection = $plugin->_connect($plugin_config, $id);
 
 	push @$transactions, {
 	    connection => $connection,
@@ -72,7 +72,7 @@ sub transactions_finish {
 	my $flush_err = $@;
 	warn "$flush_err" if $flush_err;
 
-	$plugin->_disconnect($txn->{connection});
+	$plugin->_disconnect($txn->{connection}, $txn->{cfg});
 	$txn->{connection} = undef;
 	# avoid log spam, already got a send error; disconnect would fail too
 	warn "disconnect failed: $@" if $@ && !$flush_err;
diff --git a/PVE/Status/Plugin.pm b/PVE/Status/Plugin.pm
index c3e0bec1..2fa223ca 100644
--- a/PVE/Status/Plugin.pm
+++ b/PVE/Status/Plugin.pm
@@ -70,12 +70,12 @@ sub parse_section_header {
 }
 
 sub _connect {
-    my ($class, $cfg) = @_;
+    my ($class, $cfg, $id) = @_;
     die "please implement inside plugin";
 }
 
 sub _disconnect {
-    my ($class, $connection) = @_;
+    my ($class, $connection, $cfg) = @_;
 
     $connection->close(); # overwrite if not a simple socket
 }
@@ -115,22 +115,22 @@ sub flush_data {
     return if !defined($txn->{data}) || $txn->{data} eq '';
 
     my $data = delete $txn->{data};
-    eval { $class->send($txn->{connection}, $data) };
+    eval { $class->send($txn->{connection}, $data, $txn->{cfg}) };
     die "metrics send error '$txn->{id}': $@" if $@;
 }
 
 sub send {
-    my ($class, $connection, $data) = @_;
+    my ($class, $connection, $data, $cfg) = @_;
 
     defined($connection->send($data))
 	or die "failed to send metrics: $!\n";
 }
 
 sub test_connection {
-    my ($class, $cfg) = @_;
+    my ($class, $cfg, $id) = @_;
 
-    my $conn = $class->_connect($cfg);
-    $class->_disconnect($conn);
+    my $conn = $class->_connect($cfg, $id);
+    $class->_disconnect($conn, $cfg);
 }
 
 sub update_node_status {
-- 
2.20.1





  parent reply	other threads:[~2020-12-02  9:21 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02  9:21 [pve-devel] [PATCH common/storage/manager/docs] implement http api for influxdb status plugin Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH common 1/1] tools: add extract_sensitive_params Dominik Csapak
2020-12-03  8:47   ` Thomas Lamprecht
2020-12-03  9:16     ` Wolfgang Bumiller
2020-12-03  9:35       ` Thomas Lamprecht
2020-12-03 15:52   ` [pve-devel] applied: " Thomas Lamprecht
2020-12-02  9:21 ` [pve-devel] [PATCH storage 1/1] api: storage/config: use extract_sensitive_params from tools Dominik Csapak
2021-01-28 16:31   ` [pve-devel] applied: " Thomas Lamprecht
2020-12-02  9:21 ` [pve-devel] [PATCH manager 1/7] api: cluster/metricserver: prevent simultaneosly setting and deleting of property Dominik Csapak
2020-12-03  9:05   ` Thomas Lamprecht
2020-12-04 11:30     ` Dominik Csapak
2020-12-04 11:57       ` Thomas Lamprecht
2020-12-04 12:45         ` Thomas Lamprecht
2020-12-02  9:21 ` Dominik Csapak [this message]
2020-12-02  9:21 ` [pve-devel] [PATCH manager 3/7] status/plugin: extend with add/update/delete hooks Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 4/7] status/influxdb: implement influxdb 2.x http api Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 5/7] status/influxdb: remove unnecessary comment Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 6/7] ui: add necessary fields for influxdb http api Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 7/7] ui: dc/MetricServerView: add onlineHelp to edit windows Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH docs 1/1] external metrics server: extend docs to explain http api Dominik Csapak
2021-01-28 16:36 ` [pve-devel] applied-series: [PATCH common/storage/manager/docs] implement http api for influxdb status plugin 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=20201202092113.15911-5-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-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 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