mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-05 09:07:19 +00:00

For now it only handles the plugin registration and the two recently integrated helpers. But, this is a prepartation to move the external metrics server update mechanic from a stateless always-newly-connect-send-disconnect to a statefull transaction based mechanis; see later patches keep the PVE::Status::Plugin use in pvestatd, as we read the cfs hosted status.cfg there, and the parser is defined by the common status plugin base module. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
89 lines
1.8 KiB
Perl
89 lines
1.8 KiB
Perl
package PVE::Status::Plugin;
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
use PVE::JSONSchema;
|
|
use PVE::Cluster qw(cfs_register_file);
|
|
use PVE::SectionConfig;
|
|
|
|
use base qw(PVE::SectionConfig);
|
|
|
|
cfs_register_file('status.cfg',
|
|
sub { __PACKAGE__->parse_config(@_); },
|
|
sub { __PACKAGE__->write_config(@_); }
|
|
);
|
|
|
|
my $defaultData = {
|
|
propertyList => {
|
|
type => {
|
|
description => "Plugin type.",
|
|
type => 'string', format => 'pve-configid',
|
|
},
|
|
disable => {
|
|
description => "Flag to disable the plugin.",
|
|
type => 'boolean',
|
|
optional => 1,
|
|
},
|
|
server => {
|
|
type => 'string', format => 'address',
|
|
description => "server dns name or IP address",
|
|
},
|
|
port => {
|
|
type => 'integer',
|
|
description => "server network port",
|
|
},
|
|
},
|
|
};
|
|
|
|
sub private {
|
|
return $defaultData;
|
|
}
|
|
|
|
sub parse_section_header {
|
|
my ($class, $line) = @_;
|
|
|
|
if ($line =~ m/^(\S+):\s*(\S+)?\s*$/) {
|
|
my $type = lc($1);
|
|
my $id = $2 // $type;
|
|
my $errmsg = undef; # set if you want to skip whole section
|
|
eval { PVE::JSONSchema::pve_verify_configid($id) };
|
|
$errmsg = $@ if $@;
|
|
my $config = {}; # to return additional attributes
|
|
return ($type, $id, $errmsg, $config);
|
|
}
|
|
return undef;
|
|
}
|
|
|
|
sub _connect {
|
|
my ($class, $cfg) = @_;
|
|
|
|
die "please implement inside plugin";
|
|
}
|
|
|
|
sub update_node_status {
|
|
my ($class, $plugin_config, $node, $data, $ctime) = @_;
|
|
|
|
die "please implement inside plugin";
|
|
}
|
|
|
|
sub update_qemu_status {
|
|
my ($class, $plugin_config, $vmid, $data, $ctime, $nodename) = @_;
|
|
|
|
die "please implement inside plugin";
|
|
}
|
|
|
|
sub update_lxc_status {
|
|
my ($class, $plugin_config, $vmid, $data, $ctime, $nodename) = @_;
|
|
|
|
die "please implement inside plugin";
|
|
}
|
|
|
|
sub update_storage_status {
|
|
my ($class, $plugin_config, $nodename, $storeid, $data, $ctime) = @_;
|
|
|
|
die "please implement inside plugin";
|
|
}
|
|
|
|
1;
|