- my $conf = PVE::Cluster::cfs_read_file("corosync.conf");
-
- my $nodelist = PVE::Corosync::nodelist($conf);
-
- my $totem_cfg = PVE::Corosync::totem_config($conf);
-
- my $name = $param->{node};
-
- # ensure we do not reuse an address, that can crash the whole cluster!
- my $check_duplicate_addr = sub {
- my $addr = shift;
- return if !defined($addr);
-
- while (my ($k, $v) = each %$nodelist) {
- next if $k eq $name; # allows re-adding a node if force is set
- if ($v->{ring0_addr} eq $addr || ($v->{ring1_addr} && $v->{ring1_addr} eq $addr)) {
- die "corosync: address '$addr' already defined by node '$k'\n";
+ my $code = sub {
+ my $conf = PVE::Cluster::cfs_read_file("corosync.conf");
+ my $nodelist = PVE::Corosync::nodelist($conf);
+ my $totem_cfg = PVE::Corosync::totem_config($conf);
+
+ my $name = $param->{node};
+
+ # ensure we do not reuse an address, that can crash the whole cluster!
+ my $check_duplicate_addr = sub {
+ my $addr = shift;
+ return if !defined($addr);
+
+ while (my ($k, $v) = each %$nodelist) {
+ next if $k eq $name; # allows re-adding a node if force is set
+ if ($v->{ring0_addr} eq $addr || ($v->{ring1_addr} && $v->{ring1_addr} eq $addr)) {
+ die "corosync: address '$addr' already defined by node '$k'\n";
+ }