Script Integration Examples

The Oracle FS CLI provides three methods for integrating commands in scripts.

The following tables highlight the features, advantages, and disadvantages of each integration method, as well as provide an example of each of the integration methods.
Important! The example code provided here is for instructional purposes only to help you to get started with scripting for the Oracle Flash Storage System. As such, the use of this example code is unsupported.
Important! You must place your scripts in the same directory as the FSCLI binary.
Table 1 Credentials integration

Example

! /usr/bin/env bash
# example script using fscli credentials
# command is automatically wrapped with a login and logout

# verify command line arguments
if [ $# -ne 2 ]; then
    echo "Usage: ./$(basename $0) <ofs-user-account> <ofs-name-or-ip>"
    exit 1
fi

# prompt for password
read -s -p "Password: " password

# issue command and display result
command="./fscli system -list -status -u $1 -oraclefs $2"
command="echo $password | $command" eval $command

Features

The command is automatically wrapped with login and logout commands.

Advantages

  • The easiest method to implement
  • The most extensible method
  • Can be used to log in and manage one or more Oracle FS System sessions concurrently
  • Login and logout commands are seen as atomic operations

Disadvantages

None

Table 2 Local file integration

Example

#! /usr/bin/env bash
# example script using fscli local file
# session key automatically managed by fscli

# verify command line arguments
if [ $# -ne 2 ]; then
    echo "Usage: ./$(basename $0) <ofs-user-account> <ofs-name-or-ip>"
    exit 1
fi

# prompt for password
read -s -p "Password: " password

# login 
command="./fscli login -u $1 -oraclefs $2"
command="echo $password | $command"
eval $command

# issue command and display result
command="./fscli system -list -status"
eval $command

# logout
command="./fscli logout"
eval $command

Features

The Oracle FS CLI manages the session key using a temporary file.

Advantages

Next to the Credentials Integration method, the easiest method to implement

Disadvantages

  • Can only be used to log in to a single Oracle FS System session on a single Oracle FS System at any given time
  • You must take into account session error conditions when using this method.
    Note:

    For the Local File integration and Session Key integration methods, you can reduce the possibility of session error conditions by using the -force option with each login. However, using the -force option might cause additional problems.

    For example, if a script logs in using the -force option for a Monitor role-based administrator account, anyone using the Oracle FS System Manager (GUI) with the same account will be logged out.

  • Requires that the -login and -logout commands be added to each script
  • The method is not extensible
Table 3 Session key integration

Example

#! /usr/bin/env bash
# example script using fscli session key
# session key managed by user

# verify command line arguments
if [ $# -ne 2 ]; then
    echo "Usage: ./$(basename $0) <ofs-user-account> <ofs-name-or-ip>"
    exit 1
fi

# prompt for password
read -s -p "Password: " password

# login and return session key
command="./fscli login -u $1 -oraclefs $2 -returnKey"
command="echo $password | $command"
eval $command

# prompt for session key 
read -s -p "Sessionkey: " sessionKey 

# issue command and display result
command="./fscli system -list -status -sessionKey"
command="echo $sessionKey | $command" 
eval $command

# prompt for session key 
read -s -p "Sessionkey: " sessionKey 

# logout
command="./fscli logout -sessionKey"
command="echo $sessionKey | $command" 
eval $command

Features

The user manages the session key.

Advantages

Can be used to log in and manage one or more Oracle FS System sessions concurrently

Disadvantages

  • The hardest method to implement
  • The script must manage the session key
  • Requires that the script be able to handle session error conditions
    Note:

    For the Local File integration and Session Key integration methods, you can reduce the possibility of session error conditions by using the -force option with each login. However, using the -force option might cause additional problems.

    For example, if a script logs in using the -force option for a Monitor role-based administrator account, anyone using the Oracle FS System Manager (GUI) with the same account will be logged out.