[pve-devel] [PATCH pve-ha-manager 2/2] Use new lock domain sub instead of storage lock

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Sep 25 17:50:06 CEST 2015


Doesn't changes behaviour at all, but makes code clearer

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/API2/HA/Groups.pm    | 6 +++---
 src/PVE/API2/HA/Resources.pm | 6 +++---
 src/PVE/HA/Config.pm         | 9 ++++-----
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/PVE/API2/HA/Groups.pm b/src/PVE/API2/HA/Groups.pm
index aa4768b..243eca8 100644
--- a/src/PVE/API2/HA/Groups.pm
+++ b/src/PVE/API2/HA/Groups.pm
@@ -116,7 +116,7 @@ __PACKAGE__->register_method ({
 
 	my $opts = $plugin->check_config($group, $param, 1, 1);
 
-	PVE::HA::Config::lock_ha_config(
+	PVE::HA::Config::lock_ha_domain(
 	    sub {
 
 		my $cfg = PVE::HA::Config::read_group_config();
@@ -156,7 +156,7 @@ __PACKAGE__->register_method ({
 	    die "types does not match\n" if $param_type ne $type;
 	}
 
-	PVE::HA::Config::lock_ha_config(
+	PVE::HA::Config::lock_ha_domain(
 	    sub {
 
 		my $cfg = PVE::HA::Config::read_group_config();
@@ -212,7 +212,7 @@ __PACKAGE__->register_method ({
 
 	my $group = extract_param($param, 'group');
 
-	PVE::HA::Config::lock_ha_config(
+	PVE::HA::Config::lock_ha_domain(
 	    sub {
 
 		my $rcfg = PVE::HA::Config::read_resources_config();
diff --git a/src/PVE/API2/HA/Resources.pm b/src/PVE/API2/HA/Resources.pm
index e97b377..d4b4b71 100644
--- a/src/PVE/API2/HA/Resources.pm
+++ b/src/PVE/API2/HA/Resources.pm
@@ -129,7 +129,7 @@ __PACKAGE__->register_method ({
 
 	my $opts = $plugin->check_config($sid, $param, 1, 1);
 
-	PVE::HA::Config::lock_ha_config(
+	PVE::HA::Config::lock_ha_domain(
 	    sub {
 
 		my $cfg = PVE::HA::Config::read_resources_config();
@@ -168,7 +168,7 @@ __PACKAGE__->register_method ({
 	    die "types does not match\n" if $param_type ne $type;
 	}
 
-	PVE::HA::Config::lock_ha_config(
+	PVE::HA::Config::lock_ha_domain(
 	    sub {
 
 		my $cfg = PVE::HA::Config::read_resources_config();
@@ -224,7 +224,7 @@ __PACKAGE__->register_method ({
 
 	my ($sid, $type, $name) = PVE::HA::Tools::parse_sid(extract_param($param, 'sid'));
 
- 	PVE::HA::Config::lock_ha_config(
+	PVE::HA::Config::lock_ha_domain(
 	    sub {
 
 		my $cfg = PVE::HA::Config::read_resources_config();
diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
index 1bb37a3..0a6dfa5 100644
--- a/src/PVE/HA/Config.pm
+++ b/src/PVE/HA/Config.pm
@@ -120,11 +120,10 @@ sub write_manager_status {
     cfs_write_file($manager_status_filename, $status_obj);
 }
 
-sub lock_ha_config {
+sub lock_ha_domain {
     my ($code, $errmsg) = @_;
 
-    # fixme: do not use cfs_lock_storage (replace with cfs_lock_ha)
-    my $res = PVE::Cluster::cfs_lock_storage("_ha_crm_commands", undef, $code);
+    my $res = PVE::Cluster::cfs_lock_domain("ha", undef, $code);
     my $err = $@;
     if ($err) {
 	$errmsg ? die "$errmsg: $err" : die $err;
@@ -143,7 +142,7 @@ sub queue_crm_commands {
 	cfs_write_file($crm_commands_filename, $data);
     };
 
-    return lock_ha_config($code);
+    return lock_ha_domain($code);
 }
 
 sub read_crm_commands {
@@ -154,7 +153,7 @@ sub read_crm_commands {
 	return $data;
     };
 
-    return lock_ha_config($code);
+    return lock_ha_domain($code);
 }
 
 sub vm_is_ha_managed {
-- 
2.1.4




More information about the pve-devel mailing list