Prerequisites:

  • Have Delphix Self-Service user privileges.
  • Know the bookmark you would like to share.


Delphix Self-Service administrators can use this CLI cookbook recipe to share a bookmark on Delphix Self-Service 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 shareBookmark.sh.

Sharing a bookmark in Delphix Self-Service

#!/bin/bash

# A sample script for calls to the CLI. This one shares Bookmark across containers in same template.
#
# 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.
#




##examples##
# Share Bookmark
#./shareBookmark.sh -a share JS_BOOKMARK-75
# Unshare Bookmark
#./shareBookmark.sh -a unshare JS_BOOKMARK-75



##### Constants

# Describes a Delphix software revision.
VERSION="1.11.10"


##### Default Values. These can be overwriten with optional arguments.
engine="10.110.213.109"
username="admin"



##### Functions


# Help Menu
function usage {
	echo "Usage: shareBookmark.sh [[-h] | options...] -a share/unshare  <bookmarkName>"
	echo "Share/Unshare JetStream bookmark"
	echo ""
	echo "Positional arguments"
	echo "bookmarkName. Format: JS_BOOKMARK-<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 "  -a                action to perform on bookmark. Type:String. Values:share/unshare"
}

# 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 bookmark_action
{
	# Change share mode of bookmark
	echo "Changing share mode.."	
	if [[ $action = "share" ]]
	then
		paramString="selfservice bookmark select $bookmarkName share; commit;"
    elif [[ $action = "unshare" ]]
	then
		paramString="selfservice bookmark select $bookmarkName unshare; commit;"
	else
		usage
		exit 1
	fi
	result=$(${SSH_CMD}  $paramString)
	check_result
	if [[ $action = "share" ]]
	then
		echo "Bookmark ${bookmarkName} is now in shared mode"
	elif [[ $action = "unshare" ]]
	then
	    echo "Bookmark ${bookmarkName} is now in not-share mode"		            
	fi
}


##### Main

while getopts "u:d:a:h" flag; do
	case "$flag" in
    	u )             username=${OPTARG%:*}
						;;
		d )             engine=$OPTARG
						;;
		a )         	action=$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 is 1 positional arguments
if [ $# != 1 ]
then
	usage
	exit 1
fi

# Get the one positional arguments
bookmarkName=$1

create_session
bookmark_action