This simple example for adding a Clone will help you to get started with scripting for the Oracle FS System.
#! /usr/bin/env bash # example script using fscli credentials to add clone, # call backup, and delete clone # verify command line arguments if [ $# -ne 5 ]; then echo "Usage: ./$(basename $0) <ofs-user-account> <ofs-name-or-ip> <source-lun-fqn> <backup-server-fqn> <clone-lun-name>" exit 1 fi # prompt for password read -s -p "Password: " password echo "" echo "" # check overall system status command="./fscli system -list -status -u $1 -oraclefs $2" echo $command command="echo $password | $command" response=$(eval $command) rc=$(echo $?) if [ $rc == 0 ] then echo "command passed" else echo "command failed" exit $rc fi state=$(echo "$response" | grep -w SystemStatus | awk -F': ' '{print $2}') echo "system status is '$state'" echo "" if [ $state != "NORMAL" ] then exit $rc fi # check source lun status command="./fscli lun -list -details -lun $3 -u $1 -oraclefs $2" echo $command command="echo $password | $command" response=$(eval $command) rc=$(echo $?) if [ $rc == 0 ] then echo "command passed" else echo "command failed" exit $rc fi state=$(echo "$response" | grep -w Status | awk -F': ' '{print $2}') echo "source lun status is '$state'" echo "" if [ $state != "ONLINE" ] then exit $rc fi # check backup server status command="./fscli san_host -list -details -sanhost $4 -u $1 -oraclefs $2" echo $command command="echo $password | $command" response=$(eval $command) rc=$(echo $?) if [ $rc == 0 ] then echo "command passed" else echo "command failed" exit $rc fi state=$(echo "$response" | grep -w ManagementState | awk -F': ' '{print $2}') echo "backup server status is '$state'" echo "" if [ $state != "AVAILABLE" ] then exit $rc fi # get next available lun number command="./fscli hostmap -list -availablelunnumbers -host $4 -u $1 -oraclefs $2" echo $command command="echo $password | $command" response=$(eval $command) rc=$(echo $?) if [ $rc == 0 ] then echo "command passed" else echo "command failed" exit $rc fi lunnumber=$(echo "$response" | grep -w LunNumber | head -n1 | awk -F': ' '{print $2}') echo "next available lun number is '$lunnumber'" echo "" # add clone command="./fscli clone_lun -add -name $5 -source $3 -hostmap $4 -lunnumber $lunnumber -u $1 -oraclefs $2" echo $command command="echo $password | $command" response=$(eval $command) rc=$(echo $?) if [ $rc == 0 ] then echo "command passed" else echo "command failed" exit $rc fi echo "" # check clone status command="./fscli clone_lun -list -details -clonelun /$5 -u $1 -oraclefs $2" echo $command command="echo $password | $command" response=$(eval $command) rc=$(echo $?) if [ $rc == 0 ] then echo "command passed" else echo "command failed" exit $rc fi state=$(echo "$response" | grep -w Status | awk -F': ' '{print $2}') echo "clone lun status is '$state'" echo "" if [ $state != "ONLINE" ] then exit $rc fi # call backup application echo "call backup application" echo "backup complete" echo "" # delete clone command="./fscli clone_lun -delete -clonelun /$5 -suppresswarnings -u $1 -oraclefs $2" echo $command command="echo $password | $command" response=$(eval $command) rc=$(echo $?) if [ $rc == 0 ] then echo "command passed" else echo "command failed" exit $rc fi echo "" echo ""
$ ./d_clone_lun.sh administrator OFS_MACHINE_NAME /fooLunZ /HOST_NAME clone_fooLunZ Password: ./fscli system -list -status -u administrator -oraclefs OFS_MACHINE_NAME command passed system status is 'NORMAL' ./fscli lun -list -details -lun /fooLunZ -u administrator -oraclefs OFS_MACHINE_NAME command passed source lun status is 'ONLINE' ./fscli san_host -list -details -sanhost /HOST_NAME -u administrator -oraclefs OFS_MACHINE_NAME command passed backup server status is 'AVAILABLE' ./fscli hostmap -list -availablelunnumbers -host /HOST_NAME -u administrator -oraclefs OFS_MACHINE_NAME command passed next available lun number is '12' ./fscli clone_lun -add -name clone_fooLunZ -source /fooLunZ -hostmap /HOST_NAME -lunnumber 12 -u administrator -oraclefs OFS_MACHINE_NAME command passed ./fscli clone_lun -list -details -clonelun /clone_fooLunZ -u administrator -oraclefs OFS_MACHINE_NAME command passed clone lun status is 'ONLINE' call backup application backup complete ./fscli clone_lun -delete -clonelun /clone_fooLunZ -suppresswarnings -u administrator -oraclefs OFS_MACHINE_NAME command passed