[pve-devel] [RFC pve-cluster] Add parameter to set ring address of a new node

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Oct 5 13:26:20 CEST 2015


Currently we use the node name as ring0_addr in the corosync config,
this resolves to the ip address configured for the webinterface.
Now if the cluster network is separated and we add a new node to
the cluster configuration this is wrong. So let the user set an
optional 'ringaddr' parameter, it defaults to the nodename and keeps
the behaviour we had when not set. Else it will be used for the
ring0_addr entry of this node in the corosync config.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 data/PVE/CLI/pvecm.pm | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/data/PVE/CLI/pvecm.pm b/data/PVE/CLI/pvecm.pm
index c9ebffc..b9f3d56 100755
--- a/data/PVE/CLI/pvecm.pm
+++ b/data/PVE/CLI/pvecm.pm
@@ -223,6 +223,11 @@ __PACKAGE__->register_method ({
 		description => "Do not throw error if node already exists.",
 		optional => 1,
 	    },
+	    ringaddr => {
+		type => 'string',
+		description => "Hostname (or IP) of the corosync ring address.",
+		optional => 1,
+	    },
 	},
     },
     returns => { type => 'null' },
@@ -238,6 +243,8 @@ __PACKAGE__->register_method ({
 
 	my $name = $param->{node};
 
+	my $ring_addr = $param->{ringaddr} ? $param->{ringaddr} : $name ;
+
 	if (defined(my $res = $nodelist->{$name})) {
 	    $param->{nodeid} = $res->{nodeid} if !$param->{nodeid};
 	    $param->{votes} = $res->{quorum_votes} if !defined($param->{votes});
@@ -278,7 +285,7 @@ __PACKAGE__->register_method ({
 	eval { 	PVE::Cluster::ssh_merge_keys(); };
 	warn $@ if $@;
 
-	$nodelist->{$name} = { ring0_addr => $name, nodeid => $param->{nodeid} };
+	$nodelist->{$name} = { ring0_addr => $ring_addr, nodeid => $param->{nodeid} };
 	$nodelist->{$name}->{quorum_votes} = $param->{votes} if $param->{votes};
 	
 	corosync_update_nodelist($conf, $nodelist);
@@ -346,6 +353,12 @@ __PACKAGE__->register_method ({
 		description => "Do not throw error if node already exists.",
 		optional => 1,
 	    },
+	    ringaddr => {
+		type => 'string',
+		description => "Hostname (or IP) of the corosync ring address".
+		    " we want to use for this node.",
+		optional => 1,
+	    },
 	},
     },
     returns => { type => 'null' },
@@ -395,6 +408,8 @@ __PACKAGE__->register_method ({
 
 	push @$cmd, '--votes', $param->{votes} if defined($param->{votes});
 
+	push @$cmd, '--ringaddr', $param->{ringaddr} if defined($param->{ringaddr});
+
 	if (system (@$cmd) != 0) {
 	    my $cmdtxt = join (' ', @$cmd);
 	    die "unable to add node: command failed ($cmdtxt)\n";
-- 
2.1.4





More information about the pve-devel mailing list