Forum Discussion

rezilient_76720's avatar
rezilient_76720
Icon for Nimbostratus rankNimbostratus
Feb 28, 2014

Find a node using LocalLBNodeAddressV2 based on IP address (not name)

Hello.

We have some iControl PowerShell scripts that we're using with our Private Cloud (IaaS) platform to add/remove VIPs, Pools and Nodes. Previously we were using LTM v10 so we couldn't set a friendly name for the node. Once we upgraded to v11 we started to set the "name" to match the actual server name. So for example we might have SERVER0121 as the node's Name and 192.168.1.17 as the node's address. It has been working fine, but now we've run into a situation where we have stale data - servers that are in the F5 but should have been removed and never were. So we're running into the following error:

Exception calling "create" with "3" argument(s): "Exception caught in LocalLB::urn:iControl:LocalLB/NodeAddressV2::create()
Exception: Common::OperationFailed
    primary_error_code   : 17237812 (0x01070734)
    secondary_error_code : 0
    error_string         : 01070734:3: Configuration error: invalid node address, the IP address 10.27.197.106 already exists"

So I'd like to be able to remove these stale entries as we see them. But I'm not sure how to remove this node based on IP address only. For example if I try delete_node_address using the IP address.

Exception calling "delete_node_address" with "1" argument(s): "Exception caught in LocalLB::urn:iControl:LocalLB/NodeAddressV2::delete_node_address()
Exception: Common::OperationFailed
    primary_error_code   : 16908342 (0x01020036)
    secondary_error_code : 0
    error_string         : 01020036:3: The requested node address (/Common/10.27.197.117) was not found."
At line:1 char:1
+ (Get-F5.iControl).LocalLBNodeAddressV2.delete_node_address($server_ip);
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SoapHeaderException

It's expecting the "name" which is SERVER0117. So how do I remove the node based only on IP address?

Thanks. Rezilient

  • This is one of the reasons I let the F5 default to using an IP address as the node name. I'm pretty sure you'll need to dump a list of all nodes using LocalLB.NodeAddressV2.get_list() and then run them through LocalLB.NodeAddressV2.get_address(). You'll then need to search for your address and map it back to the node name.

     

    Note that you will need to make sure the node is not in any pools before you attempt to delete it, else I'm pretty sure you'll get another error.

     

    Good luck,

     

    -M

     

  • Hi mate!

    I'd do something like this:

    Cache the nodelist and address list
    $Global:nodelist = $f5.LocalLBNodeAddressV2.get_list()
    $Global:nodeaddresses = $f5.LocalLBNodeAddressV2.get_address($nodelist)
    
    function ip2name($ip){
        $indexofip = 0..($Global:nodeaddresses.Count - 1) | Where { $Global:nodeaddresses[$_] -eq $ip }
        $Global:nodelist[$indexofip] <---- name of the node you want to delete
    }
    
    $f5.LocalLBNodeAddressV2.delete_node_address(ip2name(""))