Jet Stream administrators can use this CLI cookbook recipe to create a branch 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 createBranch.sh.

Creating a branch in Jet Stream

#!/bin/bash
# A sample script for calls to the CLI. This one creates a Jet Stream branch.
#
# 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.
#
# Note that the CLI only allows branches to be created from below 
# 1) From latest point in time 
# 2) From specific bookmark
# 3) From specific point in time
 
##examples##
# Create branch from latest point in time
#./createBranch.sh NewBranchName JS_DATA_CONTAINER-20
# Create branch from specific bookmark
#./createBranch.sh -b ExistingBookmarkName NewBranchName 
# Create branch from specific point in time
#./createBranch.sh -t "2016-07-27T01:45:56.453Z" NewBranchName JS_DATA_CONTAINER-20

##### 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"
 
##### Functions

# Help Menu
function usage {
echo "Usage: createBranch.sh [[-h] | options...] <name> <container>"
echo "Create a Jet Stream Bookmark on the given branch."
echo ""
echo "Positional arguments"
echo " <NewBranchName>"
echo " <container> format JS_DATA_CONTAINER-<n>"
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 " -b Bookmark name from which need to create branch. If no bookmark is included, the branch will be created at the latest point in time. Type: string"
echo " -t The time at which the branch should be created. If no time is included, the branch will be created at the latest point in 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 create_branch
{
# If there is not timeInput and no bookmark name, we need to use JSTimelinePointLatestTimeInput.
if [ -z $inputTime ] && [ -z $bookmark ]
then
#code to use JSTimelinePointLatestTimeInput 
pointParams="edit timelinePointParameters; set type=JSTimelinePointLatestTimeInput;"
pointParams="$pointParams set sourceDataLayout=$container; commit;"
# If there is a timeInput and no bookmark name, we need to use Input Time.
elif [ -n $inputTime ] && [ -z $bookmark ]
then
#code to use JSTimelinePointTimeInput 
pointParams="edit timelinePointParameters; set type=JSTimelinePointTimeInput;"
pointParams="$pointParams set time=$inputTime; set sourceDataLayout=$container; commit;"
# If there is a bookmark name and no time input, we need to use bookmark
elif [ -z $inputTime ] && [ -n $bookmark ]
then
#code to use JSTimelinePointBookmarkInput
pointParams="set timelinePointParameters.bookmark=$bookmark;"
pointParams="$pointParams commit;"
fi
# These are the required parameters.
paramString="jetstream branch create;set name=$branchName; set dataContainer=$container;" 

#Add additional optional parameter 
paramString="$paramString $pointParams"
#echo $paramString
echo "Creating Branch..."
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 created branch $branchName"
else
echo "Unable to create branch"
echo $result
fi
}

##### Main
while getopts "u:d:b:t:B:h" flag; do
case "$flag" in
u ) username=${OPTARG%:*}
;;
d ) engine=$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 2 positional arguments
if [ $# != 2 ]
then
usage
exit 1
fi
# Get the two positional arguments
branchName=$1
shift
container=$1
create_session
create_branch