Skip to content

Instantly share code, notes, and snippets.

@beaudierman
Created April 2, 2013 17:24
Show Gist options
  • Save beaudierman/5294217 to your computer and use it in GitHub Desktop.
Save beaudierman/5294217 to your computer and use it in GitHub Desktop.
Find the ServiceNet IP of your Rackspace Cloud Load Balancer
#! /bin/bash
#########################################################
# Bash Script to find the Interal IP for Load Balancers #
#########################################################
echo "=================================================="
echo " ServiceNet IP for Load Balancers "
echo "=================================================="
echo -n "Input Username: "
read USER
echo -n "Input API Key: "
read API
echo -n "Input Region (dfw ord lon): "
read REGION
echo -n "Input name of Load Balancer: "
read NAME
if [ "$REGION" == "lon" ]; then
rc="lon."
else
rc=""
fi
TOKEN=`curl -s -i -H "X-Auth-User: $USER" -H "X-Auth-Key: $API" https://${rc}auth.api.rackspacecloud.com/v1.0 | grep "Auth-Token:" | gawk '{ print $2 }'`
DDI=`curl -s -i -H "X-Auth-User: $USER" -H "X-Auth-Key: $API" https://${rc}auth.api.rackspacecloud.com/v1.0 | grep "Server-Management" | grep -Eo [0-9][0-9][0-9]*`
LB=`curl -s -H "X-Auth-Token: $TOKEN" https://$REGION.loadbalancers.api.rackspacecloud.com/v1.0/$DDI/loadbalancers/ | python -mjson.tool | grep "$NAME" -B 1 | grep "id" | gawk '{ print $2 }' | sed 's/,//g'`
echo ""
echo -n -e "ServiceNet IP = "
curl -s -H "X-Auth-Token: $TOKEN" https://$REGION.loadbalancers.api.rackspacecloud.com/v1.0/$DDI/loadbalancers/$LB | python -mjson.tool | grep "ipv4Servicenet" | gawk '{ print $2 }' | sed 's/"//g' | sed 's/,//g'
echo ""
echo "You're Welcome, $USERNAME"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment