[pve-devel] [PATCH ha-manager 1/3] Env: add get_ha_settings method
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed Dec 19 11:39:39 CET 2018
Add get_ha_settings, a method which returns the datacenter wide HA
settings
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
src/PVE/HA/Env.pm | 7 +++++++
src/PVE/HA/Env/PVE2.pm | 9 +++++++++
src/PVE/HA/Sim/Env.pm | 9 +++++++++
src/PVE/HA/Sim/Hardware.pm | 12 ++++++++++++
4 files changed, 37 insertions(+)
diff --git a/src/PVE/HA/Env.pm b/src/PVE/HA/Env.pm
index 6393532..a173deb 100644
--- a/src/PVE/HA/Env.pm
+++ b/src/PVE/HA/Env.pm
@@ -256,4 +256,11 @@ sub get_max_workers {
return $self->{plug}->get_max_workers();
}
+# return cluster wide enforced HA settings
+sub get_ha_settings {
+ my ($self) = @_;
+
+ return $self->{plug}->get_ha_settings();
+}
+
1;
diff --git a/src/PVE/HA/Env/PVE2.pm b/src/PVE/HA/Env/PVE2.pm
index 00ce438..f3c7243 100644
--- a/src/PVE/HA/Env/PVE2.pm
+++ b/src/PVE/HA/Env/PVE2.pm
@@ -439,4 +439,13 @@ sub get_max_workers {
return $datacenterconfig->{max_workers} || 4;
}
+# return cluster wide enforced HA settings
+sub get_ha_settings {
+ my ($self) = @_;
+
+ my $datacenterconfig = cfs_read_file('datacenter.cfg');
+
+ return $datacenterconfig->{ha};
+}
+
1;
diff --git a/src/PVE/HA/Sim/Env.pm b/src/PVE/HA/Sim/Env.pm
index a431e26..22e13e6 100644
--- a/src/PVE/HA/Sim/Env.pm
+++ b/src/PVE/HA/Sim/Env.pm
@@ -418,4 +418,13 @@ sub get_max_workers {
return 4;
}
+# return cluster wide enforced HA settings
+sub get_ha_settings {
+ my ($self) = @_;
+
+ my $datacenterconfig = $self->{hardware}->read_datacenter_conf();
+
+ return $datacenterconfig->{ha};
+}
+
1;
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 3b192b0..59b6591 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -30,6 +30,7 @@ my $watchdog_timeout = 60;
# $testdir/service_config Service configuration
# $testdir/groups HA groups configuration
# $testdir/service_status_<node> Service status
+# $testdir/datacenter.cfg Datacenter wide HA configuration
#
# runtime status for simulation system
@@ -383,6 +384,10 @@ sub new {
copy("$testdir/fence.cfg", "$statusdir/fence.cfg");
}
+ if (-f "$testdir/datacenter.cfg") {
+ copy("$testdir/datacenter.cfg", "$statusdir/datacenter.cfg");
+ }
+
my $cstatus = $self->read_hardware_status_nolock();
foreach my $node (sort keys %$cstatus) {
@@ -424,6 +429,13 @@ sub statusdir {
return $self->{statusdir};
}
+sub read_datacenter_conf {
+ my ($self, $node) = @_;
+
+ my $filename = "$self->{statusdir}/datacenter.cfg";
+ return PVE::HA::Tools::read_json_from_file($filename, {});
+}
+
sub global_lock {
my ($self, $code, @param) = @_;
--
2.19.2
More information about the pve-devel
mailing list