]> git.proxmox.com Git - pve-cluster.git/commitdiff
use 'name' over 'ring0_addr' and prepare for rrp
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 9 Oct 2015 16:49:38 +0000 (18:49 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 12 Oct 2015 09:48:01 +0000 (11:48 +0200)
Adapt some functions to prefer 'name' subkey over 'ring0_addr'.
Add a function to get a hash representatiion of the totem corosync
config item.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
data/PVE/CLI/pvecm.pm

index c9ebffc3e8d5319ad60f39ebad163d5e474ac5d9..ae39af50f1d9664b5ac2f31bdf34a2ac2b8f4e18 100755 (executable)
@@ -554,7 +554,7 @@ sub corosync_update_nodelist {
 
     my $children = [];
     foreach my $v (values %$nodelist) {
-       next if !$v->{ring0_addr};
+       next if !($v->{ring0_addr} || $v->{name});
        my $kv = [];
        foreach my $k (keys %$v) {
            push @$kv, { key => $k, value => $v->{$k} };
@@ -580,22 +580,27 @@ sub corosync_update_nodelist {
 
 sub corosync_nodelist {
     my ($conf) = @_;
-    
-    my $res = {};
 
     my $nodelist = {};
-    
+
     foreach my $main (@{$conf->{children}}) {
        next if !defined($main->{section});
        if ($main->{section} eq 'nodelist') {
            foreach my $ne (@{$main->{children}}) {
                next if !defined($ne->{section}) || ($ne->{section} ne 'node');
                my $node = { quorum_votes => 1 };
+               my $name;
                foreach my $child (@{$ne->{children}}) {
                    next if !defined($child->{key});
                    $node->{$child->{key}} = $child->{value};
-                   if ($child->{key} eq 'ring0_addr') {
-                       $nodelist->{$child->{value}} = $node;
+                   # use 'name' over 'ring0_addr' if set
+                   if ($child->{key} eq 'name') {
+                       delete $nodelist->{$name} if $name;
+                       $name = $child->{value};
+                       $nodelist->{$name} = $node;
+                   } elsif(!$name && $child->{key} eq 'ring0_addr') {
+                       $name = $child->{value};
+                       $nodelist->{$name} = $node;
                    }
                }
            }
@@ -605,6 +610,40 @@ sub corosync_nodelist {
     return $nodelist;
 }
 
+# get a hash representation of the corosync config totem section
+sub corosync_totem_config {
+    my ($conf) = @_;
+
+    my $res = {};
+
+    foreach my $main (@{$conf->{children}}) {
+       next if !defined($main->{section}) ||
+           $main->{section} ne 'totem';
+
+       foreach my $e (@{$main->{children}}) {
+
+           if ($e->{section} && $e->{section} eq 'interface') {
+               my $entry = {};
+
+               $res->{interface} = {};
+
+               foreach my $child (@{$e->{children}}) {
+                   next if !defined($child->{key});
+                   $entry->{$child->{key}} = $child->{value};
+                   if($child->{key} eq 'ringnumber') {
+                       $res->{interface}->{$child->{value}} = $entry;
+                   }
+               }
+
+           } elsif  ($e->{key}) {
+               $res->{$e->{key}} = $e->{value};
+           }
+       }
+    }
+
+    return $res;
+}
+
 __PACKAGE__->register_method ({
     name => 'updatecerts', 
     path => 'updatecerts',