Bash Hacking – F5 Nodes to A10

Here is my little script which is used to migrate a few hundred server from our f5 bigip's to a10.
It's really simple and not very smart but it works for us. It doesn't care about the health check and just uses ping and it can't handle multiple ports... It also assumes that every server has a reverse lookup. If you don't care about this it should work really well.
Just copy /etc/services from the f5 into the same inventory as the script and execute it with the bigip config as a parameter (Bigpipe, not tmsh)

#!/bin/bash
#Function to check for int - guess there are simpler ways but who cares :P
function is_int() { return $(test "$@ -eq $@" > /dev/null 2>&1); }

for i in $(grep -B1 "node type pool" $1 | grep ":" | sed 's/ //g' | tr -d "{" | tr -d "#" | grep ^[0-9] | sort | uniq)
do
server=$(host -4 -t ptr $(echo $i | cut -d ":" -f1) | cut -d " " -f5 | sed 's/.$//')
ip=$(echo $i | cut -d ":" -f1)
port=$(echo $i | cut -d ":" -f2)
#You need to copy the services file from the f5 (/etc/services) into this dir. If you only have port 80 hosts it should work with your normal services file)
real_port=$(grep -P "^$port\t" f5.services | grep tcp | awk '{print $2}' | cut -d "/" -f1)

is_int $port || port=$real_port

$(echo $server | grep -qi ^[a-z]) && echo "
slb server $server $ip
health-check ping
port $port tcp"
done

Comments

  • mischamischa Member
    edited February 2014
    Hi Daniel!

    Thank you for contributing to the community. Could you attach the actual file as well?

    Thanx!
  • edited February 2014
    here it is...
    my pool & virtual server scripts are written really really terrible and highly customized to our setup but if anyone need assistance there too I could help out.
Sign In or Register to comment.