From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 0AF49A879 for ; Wed, 27 Apr 2022 17:34:31 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C6F0228869 for ; Wed, 27 Apr 2022 17:34:00 +0200 (CEST) Received: from bastionodiso.odiso.net (bastionodiso.odiso.net [185.151.191.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 40CDD287DD for ; Wed, 27 Apr 2022 17:33:53 +0200 (CEST) Received: from kvmformation3.odiso.net (formationkvm3.odiso.net [10.3.94.12]) by bastionodiso.odiso.net (Postfix) with ESMTP id C28E3159BB; Wed, 27 Apr 2022 17:33:52 +0200 (CEST) Received: by kvmformation3.odiso.net (Postfix, from userid 0) id BFC7ADE5EA; Wed, 27 Apr 2022 17:33:52 +0200 (CEST) From: Alexandre Derumier To: pve-devel@lists.proxmox.com Date: Wed, 27 Apr 2022 17:33:48 +0200 Message-Id: <20220427153351.1773666-6-aderumier@odiso.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220427153351.1773666-1-aderumier@odiso.com> References: <20220427153351.1773666-1-aderumier@odiso.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.111 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% HEADER_FROM_DIFFERENT_DOMAINS 0.248 From and EnvelopeFrom 2nd level mail domains are different KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods NO_DNS_FOR_FROM 0.001 Envelope sender has no MX or A DNS records SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pve-devel] [PATCH pve-ha-manager 5/8] sim : hardware: add read stats X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Apr 2022 15:34:31 -0000 --- 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