API cookbook: stop/start a VDB
This API cookbook recipe describes how to stop and start a VDB using the Delphix Engine API.
To stop or start a VDB, you need a reference to the Database
object. See the topic, API Cookbook: List dSources and VDBs, for information on how to obtain the database reference. The following script example includes working examples for creating a session, authenticating to the Delphix Engine, and stopping or starting a VDB. Please update the script variables to match your environment before using it. This script requires a single argument which is 'start' or 'stop'.
#!/bin/bash
#
# sample script to start or stop a VDB.
#
# set this to the FQDN or IP address of the Delphix Engine
DE="192.168.2.131"
# set this to the Delphix admin user name
DELPHIX_ADMIN="delphix_admin"
# set this to the password for the Delphix admin user
DELPHIX_PASS="delphix"
# set this to the object reference for the VDB
VDB="ORACLE_VIRTUAL_SOURCE-5"
#
# create our session
curl -s -X POST -k --data @- http://${DE}/resources/json/delphix/session \
-c ~/cookies.txt -H "Content-Type: application/json" <<EOF
{
"type": "APISession",
"version": {
"type": "APIVersion",
"major": 1,
"minor": 11,
"micro": 8
}
}
EOF
echo
#
# authenticate to the DE
curl -s -X POST -k --data @- http://${DE}/resources/json/delphix/login \
-c ~/cookies.txt -b ~/cookies.txt -H "Content-Type: application/json" <<EOF
{
"type": "LoginRequest",
"username": "${DELPHIX_ADMIN}",
"password": "${DELPHIX_PASS}"
}
EOF
echo
#
# start or stop the vdb based on the argument passed to the script
case $1 in
start)
curl -s -X POST -k http://${DE}/resources/json/delphix/source/${VDB}/start \
-c ~/cookies.txt -b ~/cookies.txt -H "Content-Type: application/json"
;;
stop)
curl -s -X POST -k http://${DE}/resources/json/delphix/source/${VDB}/stop \
-c ~/cookies.txt -b ~/cookies.txt -H "Content-Type: application/json"
;;
*)
echo "Unknown option: $1"
;;
esac
echo