From: Alexandre Derumier <aderumier@odiso.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-ha-manager 5/8] sim : hardware: add read stats
Date: Wed, 27 Apr 2022 17:33:48 +0200 [thread overview]
Message-ID: <20220427153351.1773666-6-aderumier@odiso.com> (raw)
In-Reply-To: <20220427153351.1773666-1-aderumier@odiso.com>
---
src/PVE/HA/Sim/Hardware.pm | 150 +++++++++++++++++++++++++++++++++++++
1 file changed, 150 insertions(+)
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 96a4064..3c3622b 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -110,6 +110,46 @@ sub read_service_config {
return $conf;
}
+sub read_service_stats {
+ my ($self) = @_;
+
+ my $filename = "$self->{statusdir}/service_stats";
+ my $conf = PVE::HA::Tools::read_json_from_file($filename);
+ return $conf;
+}
+
+sub read_vm_config {
+ my ($self) = @_;
+
+ my $filename = "$self->{statusdir}/vm_config";
+ my $conf = PVE::HA::Tools::read_json_from_file($filename);
+ return $conf;
+}
+
+sub read_node_stats {
+ my ($self) = @_;
+
+ my $filename = "$self->{statusdir}/node_stats";
+ my $conf = PVE::HA::Tools::read_json_from_file($filename);
+ return $conf;
+}
+
+sub read_node_config {
+ my ($self) = @_;
+
+ my $filename = "$self->{statusdir}/node_config";
+ my $conf = PVE::HA::Tools::read_json_from_file($filename);
+ return $conf;
+}
+
+sub read_storecfg {
+ my ($self) = @_;
+
+ my $filename = "$self->{statusdir}/storecfg";
+ my $conf = PVE::HA::Tools::read_json_from_file($filename);
+ return $conf;
+}
+
sub update_service_config {
my ($self, $sid, $param) = @_;
@@ -133,6 +173,51 @@ sub write_service_config {
return PVE::HA::Tools::write_json_to_file($filename, $conf);
}
+sub write_vm_config {
+ my ($self, $conf) = @_;
+
+ $self->{vm_config} = $conf;
+
+ my $filename = "$self->{statusdir}/vm_config";
+ return PVE::HA::Tools::write_json_to_file($filename, $conf);
+}
+
+sub write_service_stats {
+ my ($self, $conf) = @_;
+
+ $self->{service_stats} = $conf;
+
+ my $filename = "$self->{statusdir}/service_stats";
+ return PVE::HA::Tools::write_json_to_file($filename, $conf);
+}
+
+sub write_node_config {
+ my ($self, $conf) = @_;
+
+ $self->{node_config} = $conf;
+
+ my $filename = "$self->{statusdir}/node_config";
+ return PVE::HA::Tools::write_json_to_file($filename, $conf);
+}
+
+sub write_node_stats {
+ my ($self, $conf) = @_;
+
+ $self->{node_stats} = $conf;
+
+ my $filename = "$self->{statusdir}/node_stats";
+ return PVE::HA::Tools::write_json_to_file($filename, $conf);
+}
+
+sub write_storecfg {
+ my ($self, $conf) = @_;
+
+ $self->{storecfg} = $conf;
+
+ my $filename = "$self->{statusdir}/storecfg";
+ return PVE::HA::Tools::write_json_to_file($filename, $conf);
+}
+
sub read_fence_config {
my ($self) = @_;
@@ -384,6 +469,66 @@ sub new {
$self->write_service_config($conf);
}
+ if (-f "$testdir/service_stats") {
+ copy("$testdir/service_stats", "$statusdir/service_stats");
+ } else {
+ my $conf = {
+ '101' => { cpu => 0, maxcpu => 0, mem => 0, maxmem => 0, cpu_pressure => 0 },
+ '102' => { cpu => 0, maxcpu => 0, mem => 0, maxmem => 0, cpu_pressure => 0 },
+ '103' => { cpu => 0, maxcpu => 0, mem => 0, maxmem => 0, cpu_pressure => 0 },
+ '104' => { cpu => 0, maxcpu => 0, mem => 0, maxmem => 0, cpu_pressure => 0 },
+ '105' => { cpu => 0, maxcpu => 0, mem => 0, maxmem => 0, cpu_pressure => 0 },
+ '106' => { cpu => 0, maxcpu => 0, mem => 0, maxmem => 0, cpu_pressure => 0 },
+ };
+ $self->write_service_stats($conf);
+ }
+
+ if (-f "$testdir/vm_config") {
+ copy("$testdir/vm_config", "$statusdir/vm_config");
+ } else {
+ my $conf = {
+ '101' => { ostype => 'l26', storage => 'local' },
+ '102' => { ostype => 'l26', storage => 'local' },
+ '103' => { ostype => 'l26', storage => 'local' },
+ '104' => { ostype => 'l26', storage => 'local' },
+ '105' => { ostype => 'l26', storage => 'local' },
+ '106' => { ostype => 'l26', storage => 'local' },
+ };
+ $self->write_vm_config($conf);
+ }
+
+ if (-f "$testdir/node_config") {
+ copy("$testdir/node_config", "$statusdir/node_config");
+ } else {
+ my $conf = {
+ 'node1' => { cpumodel => '' },
+ 'node2' => { cpumodel => '' },
+ 'node3' => { cpumodel => '' },
+ };
+ $self->write_node_config($conf);
+ }
+
+ if (-f "$testdir/node_stats") {
+ copy("$testdir/node_stats", "$statusdir/node_stats");
+ } else {
+ my $conf = {
+ 'node1' => { cpu => 0, maxcpu => 0, mem => 0, maxmem => 0, ksm => 0, cpu_pressure => 0 },
+ 'node2' => { cpu => 0, maxcpu => 0, mem => 0, maxmem => 0, ksm => 0, cpu_pressure => 0 },
+ 'node3' => { cpu => 0, maxcpu => 0, mem => 0, maxmem => 0, ksm => 0, cpu_pressure => 0 },
+ };
+ $self->write_node_stats($conf);
+ }
+
+ if (-f "$testdir/storecfg") {
+ copy("$testdir/storecfg", "$statusdir/storecfg");
+ } else {
+ my $conf = {
+ 'local' => { nodes => { node1 => 1, node2 => 1, node3 => 1 } },
+ 'local-lvm' => { nodes => { node1 => 1, node2 => 1, node3 => 1 } },
+ };
+ $self->write_storecfg($conf);
+ }
+
if (-f "$testdir/hardware_status") {
copy("$testdir/hardware_status", "$statusdir/hardware_status") ||
die "Copy failed: $!\n";
@@ -417,6 +562,11 @@ sub new {
}
$self->{service_config} = $self->read_service_config();
+ $self->{vm_config} = $self->read_vm_config();
+ $self->{service_stats} = $self->read_service_stats();
+ $self->{node_stats} = $self->read_node_stats();
+ $self->{node_config} = $self->read_node_config();
+ $self->{storecfg} = $self->read_storecfg();
return $self;
}
--
2.30.2
next prev parent reply other threads:[~2022-04-27 15:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 15:33 [pve-devel] [PATCH pve-ha-manager 0/8] WIP: ressource aware HA manager + balancer Alexandre Derumier
2022-04-27 15:33 ` [pve-devel] [PATCH pve-ha-manager 1/8] add AHP && Topsis Math Helpers Alexandre Derumier
2022-04-27 15:33 ` [pve-devel] [PATCH pve-ha-manager 2/8] get services && nodes stats Alexandre Derumier
2022-04-27 15:33 ` [pve-devel] [PATCH pve-ha-manager 3/8] implement ressource aware service recovery Alexandre Derumier
2022-04-27 15:33 ` [pve-devel] [PATCH pve-ha-manager 4/8] add vm loadbalancing Alexandre Derumier
2022-04-27 15:33 ` Alexandre Derumier [this message]
2022-04-27 15:33 ` [pve-devel] [PATCH pve-ha-manager 6/8] add resources group Alexandre Derumier
2022-04-27 15:33 ` [pve-devel] [PATCH pve-ha-manager 7/8] add affinity Alexandre Derumier
2022-04-27 15:33 ` [pve-devel] [PATCH pve-ha-manager 8/8] add tests Alexandre Derumier
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=20220427153351.1773666-6-aderumier@odiso.com \
--to=aderumier@odiso.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 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.