From 7d33cb12de638a2b7f2e3cb2eb83e2d47c0b7b65 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabian=20Gr=C3=BCnbichler?= Date: Fri, 28 Sep 2018 12:48:51 +0200 Subject: [PATCH] groups: register groups directly MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- 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", <parse_config("groups.tmp", <