[pve-devel] [PATCH ha-manager 07/11] env: add get_crs_settings() method

Fiona Ebner f.ebner at proxmox.com
Thu Nov 10 15:37:55 CET 2022


for reading the resource scheduler settings.

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
 src/PVE/HA/Env.pm      |  7 +++++++
 src/PVE/HA/Env/PVE2.pm | 12 ++++++++++++
 src/PVE/HA/Sim/Env.pm  |  9 +++++++++
 3 files changed, 28 insertions(+)

diff --git a/src/PVE/HA/Env.pm b/src/PVE/HA/Env.pm
index 00e3e3c..c014ff7 100644
--- a/src/PVE/HA/Env.pm
+++ b/src/PVE/HA/Env.pm
@@ -269,6 +269,13 @@ sub get_ha_settings {
     return $self->{plug}->get_ha_settings();
 }
 
+# return cluster wide resource scheduling settings
+sub get_crs_settings {
+    my ($self) = @_;
+
+    return $self->{plug}->get_crs_settings();
+}
+
 sub get_static_node_stats {
     my ($self) = @_;
 
diff --git a/src/PVE/HA/Env/PVE2.pm b/src/PVE/HA/Env/PVE2.pm
index 7fac43c..e8f746c 100644
--- a/src/PVE/HA/Env/PVE2.pm
+++ b/src/PVE/HA/Env/PVE2.pm
@@ -464,6 +464,18 @@ sub get_ha_settings {
     return $datacenterconfig->{ha};
 }
 
+sub get_crs_settings {
+    my ($self) = @_;
+
+    my $datacenterconfig = eval { cfs_read_file('datacenter.cfg') };
+    if (my $err = $@) {
+	$self->log('err', "unable to get CRS settings from datacenter.cfg - $err");
+	return {};
+    }
+
+    return $datacenterconfig->{crs};
+}
+
 sub get_static_node_stats {
     my ($self) = @_;
 
diff --git a/src/PVE/HA/Sim/Env.pm b/src/PVE/HA/Sim/Env.pm
index b286708..967c031 100644
--- a/src/PVE/HA/Sim/Env.pm
+++ b/src/PVE/HA/Sim/Env.pm
@@ -433,4 +433,13 @@ sub get_ha_settings {
     return $datacenterconfig->{ha};
 }
 
+# return cluster wide resource scheduling settings
+sub get_crs_settings {
+    my ($self) = @_;
+
+    my $datacenterconfig = $self->{hardware}->read_datacenter_conf();
+
+    return $datacenterconfig->{crs};
+}
+
 1;
-- 
2.30.2






More information about the pve-devel mailing list