[pve-devel] [PATCH ha-manager 04/12] groups: register groups directly

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Sep 28 12:48:51 CEST 2018


and use PVE::HA::Groups to parse the config when testing/simulating.

this allows us to drop the dependency on PVE::HA::Config, which would
otherwise pull in a lot of additional depdendencies that we don't want
in the simulator.

Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
note for Thomas: my original plan of merging Config and Env didn't pan out as
expected - circular dependencies between external API2 modules via the VM/CT
Resources.. this is a more minimal approach that achieves the same goal for now.

 src/PVE/HA/Config.pm       | 4 ----
 src/PVE/HA/Groups.pm       | 3 +++
 src/PVE/HA/Sim/Hardware.pm | 4 ++--
 src/pve-ha-tester          | 2 +-
 src/test/test_failover1.pl | 4 ++--
 5 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
index bf37b04..5de4779 100644
--- a/src/PVE/HA/Config.pm
+++ b/src/PVE/HA/Config.pm
@@ -9,10 +9,6 @@ use PVE::HA::Groups;
 use PVE::Cluster qw(cfs_register_file cfs_read_file cfs_write_file cfs_lock_file);
 use PVE::HA::Resources;
 
-PVE::HA::Groups->register();
-
-PVE::HA::Groups->init();
-
 my $manager_status_filename = "ha/manager_status";
 my $ha_groups_config = "ha/groups.cfg";
 my $ha_resources_config = "ha/resources.cfg";
diff --git a/src/PVE/HA/Groups.pm b/src/PVE/HA/Groups.pm
index 4816f3e..40666f6 100644
--- a/src/PVE/HA/Groups.pm
+++ b/src/PVE/HA/Groups.pm
@@ -99,4 +99,7 @@ sub parse_section_header {
     return undef;
 }
 
+__PACKAGE__->register();
+__PACKAGE__->init();
+
 1;
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 2019d8f..3b192b0 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -14,8 +14,8 @@ use IO::File;
 use Fcntl qw(:DEFAULT :flock);
 use File::Copy;
 use File::Path qw(make_path remove_tree);
-use PVE::HA::Config;
 use PVE::HA::FenceConfig;
+use PVE::HA::Groups;
 
 my $watchdog_timeout = 60;
 
@@ -292,7 +292,7 @@ sub read_group_config {
     my $raw = '';
     $raw = PVE::Tools::file_get_contents($filename) if -f $filename;
 
-    return PVE::HA::Config::parse_groups_config($filename, $raw);
+    return PVE::HA::Groups->parse_config($filename, $raw);
 }
 
 sub read_service_status {
diff --git a/src/pve-ha-tester b/src/pve-ha-tester
index 0f1f14e..aa214d7 100755
--- a/src/pve-ha-tester
+++ b/src/pve-ha-tester
@@ -7,8 +7,8 @@ use JSON;
 use lib '.';
 
 use PVE::Tools;
-use PVE::HA::Config;
 
+use PVE::HA::Groups;
 use PVE::HA::Sim::TestHardware;
 
 sub show_usage {
diff --git a/src/test/test_failover1.pl b/src/test/test_failover1.pl
index d72617e..67573a2 100755
--- a/src/test/test_failover1.pl
+++ b/src/test/test_failover1.pl
@@ -4,10 +4,10 @@ use strict;
 use warnings;
 
 use lib '..';
-use PVE::HA::Config;
+use PVE::HA::Groups;
 use PVE::HA::Manager;
 
-my $groups = PVE::HA::Config::parse_groups_config("groups.tmp", <<EOD);
+my $groups = PVE::HA::Groups->parse_config("groups.tmp", <<EOD);
 group: prefer_node1
 	nodes node1
 EOD
-- 
2.19.0





More information about the pve-devel mailing list