]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
env: add get_static_node_stats() method
authorFiona Ebner <f.ebner@proxmox.com>
Thu, 17 Nov 2022 14:00:02 +0000 (15:00 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 18 Nov 2022 12:25:21 +0000 (13:25 +0100)
to be used for static resource scheduling. In the simulation
environment, the information can be added in hardware_status.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
src/PVE/HA/Env.pm
src/PVE/HA/Env/PVE2.pm
src/PVE/HA/Sim/Env.pm
src/PVE/HA/Sim/Hardware.pm

index ac569a9fd83407e9e6fad9e167fbf75900cb1d39..00e3e3c18d8c42ad8cbbdf0f7b65aabf390eb5d7 100644 (file)
@@ -269,4 +269,10 @@ sub get_ha_settings {
     return $self->{plug}->get_ha_settings();
 }
 
+sub get_static_node_stats {
+    my ($self) = @_;
+
+    return $self->{plug}->get_static_node_stats();
+}
+
 1;
index 5e0a6830265cfd6a7c9e37b81010018b38c47f84..7cecf3544da6879c10a3d5f8aa901cccaedb70ed 100644 (file)
@@ -5,6 +5,7 @@ use warnings;
 use POSIX qw(:errno_h :fcntl_h);
 use IO::File;
 use IO::Socket::UNIX;
+use JSON;
 
 use PVE::SafeSyslog;
 use PVE::Tools;
@@ -459,4 +460,16 @@ sub get_ha_settings {
     return $datacenterconfig->{ha};
 }
 
+sub get_static_node_stats {
+    my ($self) = @_;
+
+    my $stats = PVE::Cluster::get_node_kv('static-info');
+    for my $node (keys $stats->%*) {
+       $stats->{$node} = eval { decode_json($stats->{$node}) };
+       $self->log('err', "unable to decode static node info for '$node' - $@") if $@;
+    }
+
+    return $stats;
+}
+
 1;
index b28670884231733b57211af2150d5ebf58ba86fb..6bd35b3be999df2a1bb137f7ba60be3a010df18d 100644 (file)
@@ -433,4 +433,10 @@ sub get_ha_settings {
     return $datacenterconfig->{ha};
 }
 
+sub get_static_node_stats {
+    my ($self) = @_;
+
+    return $self->{hardware}->get_static_node_stats();
+}
+
 1;
index 96a4064b9646969e64abc0f7c77f1318c3003275..e38561acee5ef8c69dbb616a9fd248396c8b285c 100644 (file)
@@ -858,4 +858,17 @@ sub watchdog_update {
     return &$modify_watchog($self, $code);
 }
 
+sub get_static_node_stats {
+    my ($self) = @_;
+
+    my $cstatus = $self->read_hardware_status_nolock();
+
+    my $stats = {};
+    for my $node (keys $cstatus->%*) {
+       $stats->{$node} = { $cstatus->{$node}->%{qw(cpus memory)} };
+    }
+
+    return $stats;
+}
+
 1;