I experienced a situation (several times) a while back with the GUI in the virtualisation engine where it became unresponsive and would eventually die in the browser.  The symptoms occurred when the engine was reclaiming a large amount of space after removing some objects, mainly large dSources.  Obviously I wanted to get to the bottom of why it was happening so raised a support ticket, however, as I’m sure you know, the first thing you do after raising a ticket with Delphix Support is to generate and upload a support bundle.  You’ve probably guessed the problem here… how can I generate a support bundle when the GUI isn’t working?

No GUI, that leaves us with the CLI and the API.  The obvious choice is to go into the CLI and have a root around because there’s bound to be a way to do it in there, isn’t there?  Err, no!


KDVDXE002> service
KDVDXE002 service> ls
Children
certificate
dns
httpConnector
ldap
locale
phonehome
proxy
security
smtp
snmp
support
syslog
time
KDVDXE002 service> support
KDVDXE002 service support> ls
Children
access
bundle
KDVDXE002 service support> bundle
KDVDXE002 service support bundle> ls
Operations
upload
KDVDXE002 service support bundle>

As you can see we have no option to download using the CLI, only upload aka transfer, so can only be used if you have that configured.  Thinking about it, this does make sense because we’re connected via SSH to the CLI so there’s no obvious way of selecting a download destination and transferring the file.

OK, then the only way to go is with the API and that’s the point of this post really.  They say sharing is caring so here’s a bash script you can use.  If you’re using a Windows PC you can use the new “Windows Subsystem for Linux” on Windows 10 or one of the many bash ports for Windows (I use git-bash) to run it.  Otherwise, the Mac and Linux folk can run it from a shell as you would any other shell script.

support_bundle.sh


#!/bin/bash
#
# Usage: $0 -u <user> -S <server> -P <port>
#
# Example
#
# ./download_bundle.sh -u <user> -S <server> -P 80

while getopts u:S:P: option
do
case "${option}"
in
u) USR=${OPTARG};;
S) SERVER=${OPTARG};;
P) PORT=${OPTARG};;
esac
done

echo "Please enter your password";
stty -echo
read PASS;
stty echo

echo "Please enter the directory to locate the support bundle"
read DIR;

URL=${SERVER}:${PORT}
export URL
echo
echo "Create session"
curl -s -X POST -k --data @- ${URL}/resources/json/delphix/session \
-c ~/cookies.txt -H "Content-Type: application/json" <<EOF
{
"type": "APISession",
"version": {
"type": "APIVersion",
"major": 1,
"minor": 0,
"micro": 0
}
}
EOF
echo
echo
echo "Logon as:" ${USR}
curl -s -X POST -k --data @- ${URL}/resources/json/delphix/login \
-b ~/cookies.txt -H "Content-Type: application/json" <<EOF1
{
"type": "LoginRequest",
"username": "${USR}",
"password": "${PASS}"
}
EOF1
echo
echo
echo "Generating Support Bundle..."
export FILENAME=`curl -s -X POST ${URL}/resources/json/delphix/service/support/bundle/generate \
-b ~/cookies.txt -H "Content-Type: application/json" | awk -F\" '{print $8}'`
export DATE=`date "+%Y%m%d-%H-%M"`
echo
echo "Downloading Support Bundle to" $DIR/${FILENAME}-${DATE}.tar.gz
curl -o $DIR/${FILENAME}-${DATE}.tar.gz -X GET -k http://${SERVER}/resources/json/delphix/data/download?token=${FILENAME} \
-b ~/cookies.txt -H "Content-Type: application/json"

I’m not going to take credit here though.  I was lucky enough to have a Delphix consultant on a client site when this exact scenario occurred so I showed him the issue and he was straight on his phone to his colleagues in Delphix and they kindly shared the script with me.  I’ve made a couple of small alterations from their version, namely change the way we provide the password and also give us the option of choosing the download destination.

I think it’s a useful script to have in your toolbox just in case you get stuck with the GUI.  I use it to demo the API during my training courses so those of you who are new to the API, it is useful as a little learning exercise.  Look closely at the curl calls and you get a good idea how the API can be used.

Leave a Reply