]> git.proxmox.com Git - pve-cluster.git/commitdiff
Fix #1093: allow also delete node by IP
authorWolfgang Link <w.link@proxmox.com>
Tue, 6 Sep 2016 09:43:57 +0000 (11:43 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Tue, 20 Sep 2016 07:25:53 +0000 (09:25 +0200)
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

index 7882b5c30a95e1bc91f888c1b5dfa5d1ba16d7dd..25273327f53cfc40a14c2b3efff01187720870a4 100755 (executable)
@@ -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) {
+           my $ring0_addr = $nodelist->{$tmp_node}->{ring0_addr};
+           my $ring1_addr = $nodelist->{$tmp_node}->{ring1_addr};
+           if (($tmp_node eq $param->{node}) ||
+               (defined($ring0_addr) && ($ring0_addr eq $param->{node})) ||
+               (defined($ring1_addr) && ($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;