[pve-devel] [PATCHV2 pve-cluster 1/2] Fix #1093: allow also delete node by IP

Wolfgang Link w.link at proxmox.com
Tue Sep 6 11:43:57 CEST 2016


If there is a second ring or the ring0_addr is set on a IP.
pvecm nodes shows the ip instead the name.
So there is a reason to delete a node also by IP.
---
 data/PVE/CLI/pvecm.pm | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/data/PVE/CLI/pvecm.pm b/data/PVE/CLI/pvecm.pm
index 7882b5c..d673929 100755
--- a/data/PVE/CLI/pvecm.pm
+++ b/data/PVE/CLI/pvecm.pm
@@ -392,7 +392,10 @@ __PACKAGE__->register_method ({
     parameters => {
     	additionalProperties => 0,
 	properties => {
-	    node => PVE::JSONSchema::get_standard_option('pve-node'),
+	    node => {
+		type => 'string',
+		description => "Hostname or IP of the corosync ring0 address of this node.",
+	    },
 	},
     },
     returns => { type => 'null' },
@@ -406,9 +409,24 @@ __PACKAGE__->register_method ({
 
 	my $nodelist = corosync_nodelist($conf);
 
-	my $nd = delete $nodelist->{$param->{node}};
-	die "no such node '$param->{node}'\n" if !$nd;
-	
+	my $node;
+
+	foreach my $tmp_node (keys %$nodelist) {
+
+	    if ( $tmp_node eq $param->{node}
+		|| $nodelist->{$tmp_node}->{ring0_addr} eq $param->{node}
+		|| (defined($nodelist->{$tmp_node}->{ring1_addr})
+		&& $nodelist->{$tmp_node}->{ring1_addr} eq $param->{node})) {
+		$node = $tmp_node;
+		last;
+	    }
+	}
+
+	die "Node/IP: $param->{node} is not a known host of the cluster.\n"
+		if !defined($node);
+
+	delete $nodelist->{$node};
+
 	corosync_update_nodelist($conf, $nodelist);
 
 	return undef;
-- 
2.1.4





More information about the pve-devel mailing list