Cisco Active Network Abstraction Customization User Guide, 3.6.4
Bean Shell Commands

Table Of Contents

Bean Shell Commands

Telnet Examples

SNMP Examples


Bean Shell Commands


This chapter describes the methods that should be used for Bean Shell in Cisco ANA commands when you want to interact with devices. In addition, it provides Telnet and SNMP environment object examples.


Caution Unlike Cisco ANA Macro Language, in Bean Shell user arguments, inventory properties should not be embedded within dollar signs ($...$).

This chapter includes the following sections:

Telnet Examples

SNMP Examples

Figure 18-1 presents the methods that should be used for Bean Shell in Cisco ANA commands when interacting with devices for Telnet and SNMP interfaces.

Figure 18-1 Bean Shell Methods


Note For setStatus, 1 = success and 2 = failure.


Telnet Examples

The following are examples of the available predefined Telnet environment objects that you can use to interact with a device:

telnetInterface.config (prompt,telnet_command, true/false, timeout)—Where:

prompt is the expected prompt after command is executed.

telnet_command is the actual command to be executed.

true/false displays or hides results.

timeout is the number of milliseconds before the command times out.

telnetInterface.setStatus (1 or 2)—Where 1 = success and 2 = fail; used, for example, to signal to Workflow Manager that a configuration command has succeeded or failed.

A timeout error reports the failure in the following format:

Unexpected error occurred during script execution: 
receiveUntil(): general timeout expired(value=<elapsed_time_in_milliseconds>) 
(<command_run>) 
Elapsed time: <elapsed_time_in_seconds> seconds

where:

elapsed_time_in_milliseconds is the length of the timeout in milliseconds.

command_run is the command that was being executed when the timeout occurred.

elapsed_time_in_seconds is the length of the timeout in seconds.

For example, a timeout error might read as follows:

Unexpected error occurred during script execution: 
receiveUntil(): general timeout expired(value=10000)(copy tftp://171.69.75.3/radA020C.tmp 
null: 
Accessing tftp://171.69.75.3/radA020C.tmp...) 
Elapsed time: 10 seconds 

SNMP Examples

The following are examples of the available predefined SNMP environment objects that you can use to interact with a device:

snmpInterface.get (OID, true/false)—Gets OID, and displays or hides results.

snmpInterface.getNext (OID, true/false)—Gets next OID, and displays or hides results.

snmpInterface.set (OID, variable type, value)—Sets OID to specified value.

snmpInterface.walk (OID, true/false)—Returns vector of strings.

snmpInterface.setStatus (1 or 2)—Where 1 = success and 2 = failure; used, for example, to signal Workflow Manager that a configuration command has succeeded or failed.

For additional information about general scripting language, refer to http://www.beanshell.org/.