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

Wolfgang Link w.link at proxmox.com
Wed Aug 31 13:05:42 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 | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/data/PVE/CLI/pvecm.pm b/data/PVE/CLI/pvecm.pm
index 7882b5c..8a897e9 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,22 @@ __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 ($nodelist->{$tmp_node}->{ring0_addr} eq $param->{node}
+		|| $tmp_node 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