Forum Discussion

sas1's avatar
sas1
Icon for Nimbostratus rankNimbostratus
Aug 15, 2016

Get pool member NAMES in irule?

members -list and nodes -list produces a list of IP addresses of the pool members. Node command does not seem to have an option to get the node name from an IP. Is there any command that can retrieve the pool member names? Node names have to be specified when adding them, why would there not be an option to retrieve them from an irule?

 

2 Replies

  • Hi Sas,

    unfortunately its not a build-in iRule functionality to resolve the name-labels of a member in given pool.

    But you could resolve the names manually by creating a

    [datagroup]
    or
    [array]
    containing all the pool member IP/Port combinations and their name-labels.

    Note: Sorry for providing an answer you may not wanted to hear... 😞

    Cheers, Kai

  • Hi Sas,

    had some spare time in the evening to play around with iCall. The iCall script below will dump your Node Names and Node IPs of every single /Partition/ every 60 seconds into the datagroup "/Common/DG_IP_2_NODENAME". Enjoy... 😉

    sys icall script NodeList_2_Datagroup {
        app-service none
        definition {
            set nodelist ""
            set nodecounter 0
             tmsh::log "iCall: Starting to enumerate existing node objects..."
            foreach partition [tmsh::get_config auth partition] {
                set partition "/[tmsh::get_name $partition]"
                 tmsh::log "iCall: Processing Partition: $partition"
                tmsh::cd $partition
                set nodes [tmsh::get_config /ltm node]
                foreach node $nodes {
                     tmsh::log "Processing Node : $partition/[tmsh::get_name $node]"
                    append nodelist "\"[tmsh::get_field_value $node "address"]\" \{ data \"[tmsh::get_name $node]\" \}\n"
                    incr nodecounter
                }
                 tmsh::log "Finished Partition: $partition"
            }
            tmsh::cd "/Common"
            if { not ([tmsh::list /ltm data-group] contains "ltm data-group internal DG_IP_2_NODENAME") } then {
                tmsh::log "iCall: Created the data-group \"DG_IP_2_NODENAME\"."
                tmsh::create /ltm data-group internal "DG_IP_2_NODENAME" type "string"
            } else {
                 tmsh::log "iCall: The DataGroup does exist."
            }
            eval "tmsh::modify /ltm data-group internal DG_IP_2_NODENAME \{ records replace-all-with \{ $nodelist \} \}"
            tmsh::log "iCall: Updated the data-group DG_IP_2_NODENAME with \"$nodecounter\" entries."
        }
        description none
        events none
    }
    sys icall handler periodic NodeList_2_Datagroup {
        first-occurrence 2016-08-15:00:00:00
        interval 60
        script NodeList_2_Datagroup
    }
    

    Note: Tweak the periodic update interval (in seconds) as needed. Then use

    tmsh load sys config merge from-terminal
    to import and merge the partial configuration.

    Cheers, Kai