Jet Stream administrators can use this CLI cookbook recipe to refresh a container on Jet Stream using the Delphix Engine CLI.

The following script is for educational and demonstration purposes only and is not supported by Delphix.

This script can be downloaded by selecting refreshContainer.sh.

Refreshing a container in Jet Stream

#!/bin/bash
# A sample script for calls to the CLI. This one refresh Jet Stream container.
#
# VERY IMPORTANT: In order for this to work, you need to go through the steps here:
# https://docs.delphix.com/display/DOCS43/CLI+Cookbook%3A+Configuring+Key-Based+SSH+Authentication+for+Automation
# After this you will not need to use a username and password to log into the delphix engine. If you do not
# setup the SSH authentication you will have to manually enter the password.
#

##### Constants
# Describes a Delphix software revision.
VERSION="1.6.2"

##### Default Values. These can be overwriten with optional arguments.
engine="10.0.1.10"
username="dev"
 
##examples##
# Refresh container from latest point in time of Template
#./refreshContainer.sh -T JS_DATA_TEMPLATE-13 JS_DATA_CONTAINER-20
# Refresh container from specific bookmark
#./refreshContainer.sh -b JS_BOOKMARK-76 JS_DATA_CONTAINER-20
# Refresh container from specific point in time of branch
#./refreshContainer.sh -t "2016-08-08T10:00:00.000Z" -T JS_DATA_TEMPLATE-13 JS_DATA_CONTAINER-20

##### Functions
# Help Menu
function usage {
echo "Usage: refreshContainer.sh [[-h] | options...] <containername>"
echo "Create a Jet Stream Bookmark on the given branch."
echo ""
echo " You need to specify either -T, -b or -t to refresh container. With -t option you also need to specify -T also"
echo "Positional arguments"
echo " <containerName>"
echo ""
echo "Optional Arguments:"
echo " -h Show this message and exit"
echo " -d Delphix engine IP address or host name, otherwise revert to default"
echo " -u Server user. Password needs to manually provide at run time, otherwise revert to default"
echo " -T template reference from which need to refresh from latest point in time"
echo " -b Bookmark name from which need to refresh container. If no bookmark is included, the branch will be created at the latest point in time. Type: string. Format JS_BOOKMARK-<n> (Optional)"
echo " -t The time from where the container should be refreshed. This must be accompanied with branch name from which need to pick up time. Type: date, must be in ISO 8601 extended format [yyyy]-[MM]-[dd]T[HH]:[mm]:[ss].[SSS]Z"
}
# Create Our Session, including establishing the API version.
function create_session
{
echo "creating session..."
SSH_CMD="ssh ${username}@${engine}"
${SSH_CMD} "version $VERSION"
check_result
}
# Check the result of the curl. If there are problems, inform the user then exit.
function check_result
{
exitStatus=$?
if [ $exitStatus -ne 0 ]
then
echo "command failed with exit status $exitStatus"
echo $result 
exit 1
fi
}

function restore_container
{
paramString="jetstream/container/select ${containerRef}; restore;"

# If there is not timeInput and no bookmark name, we need to use JSTimelinePointLatestTimeInput from template.
if [[ -n $template && -z $inputTime && -z $bookmark ]]
then
pointParams="set type=JSTimelinePointLatestTimeInput; set sourceDataLayout=\"${template}\";"
# If there is a timeInput and no bookmark name, we need to use Input Time.
elif [[ -n $inputTime && -z $bookmark && -n $template ]]
then
pointParams="set type=JSTimelinePointTimeInput; set time=\"${inputTime}\"; set sourceDataLayout=\"${template}\";"
# If there is a bookmark name and no time input, we need to use bookmark
elif [[ -n $bookmark && -z $template && -z $inputTime ]]
then
pointParams="set type=JSTimelinePointBookmarkInput; set bookmark=\"${bookmark}\";"
else
usage
exit 1
fi

paramString="$paramString $pointParams commit;"
#echo $paramString
result=$(${SSH_CMD} $paramString)
check_result
echo "Verifying job status..."
# Get everything in the result that comes after job.
temp=${result#*job}
# Get rid of everything after 
resultArray=($temp)
jobRef=($resultArray)
jobString="job;select $jobRef;ls"
result=$(${SSH_CMD} $jobString)
check_result
# Get everything in the result that comes after job.
temp=${result#*jobState:}
# Get rid of everything after
resultArray=($temp)
jobState=($resultArray)
if [ $jobState = "COMPLETED" ]
then
echo "Successfully refreshed container $containerName"
else
echo "Unable to refresh container"
echo result
fi
}

##### Main
while getopts "u:d:T:b:t:B:h" flag; do
case "$flag" in
u ) username=${OPTARG%:*}
;;
d ) engine=$OPTARG
;;
T ) template=$OPTARG
;; 
b ) bookmark=$OPTARG
;;
t ) inputTime=$OPTARG
;;
h ) usage
exit
;;
* ) usage
exit 1
esac
done

# Shift the parameters so we only have the positional arguments left
shift $((OPTIND-1))
# Check that there are 1 positional arguments
if [ $# != 1 ]
then
usage
exit 1
fi
# Get the one positional arguments
containerRef=$1
create_session
restore_container