4.1.1 Script Analysis

Table 4-1 provides an analysis of each line of the code.

Table 4-1 Line-by_Line Script Analysis

Lines Description

1

Jython import construct to import all EM CLI verb functions in the current program.

3

search_list is a variable to pass to the search option in the list verb. This example uses escape characters to represent single quotes. To pass more than one value for the same option in the list verb, define as comma separated values, surrounded by square brackets.

5

Defines an if condition to ensure the user provides two arguments with the script, otherwise the script prints an error message (defined in lines #15, 16)

6

Provides a login to Enterprise Manager. You can remove this if you have set up EM CLI with autologin. For more information about setup and autologin, see Downloading and Deploying the EM CLI Client with the Script Option and the setup and the login verbs.

7

l_prop_val_to_set is a variable. This is the property value to be set. Remember that this script is changing this value from Test to Production. You can change this value to any acceptable Lifecycle property value. For a list of valid values, see the modify_lifecycle_stage_name verb or the Oracle Enterprise Manager Cloud Control Administrator's Guide.

8

Stores the output of the list verb in l_targets. In the list verb, this script passes the resource as TargetProperties, and search as the search_list variable. This script specifies three columns:

  • target_name

  • target_type

  • property_name

9

Defines a for loop. The data in l_targets is available in JSON format. This loop iterates through the information target property information returned from the list verb.

For information about JSON processing, see JSON Processing

10

Sets t_pn to the LifeCycle Status value.

11

Provides a progress message to the user stating that the script is setting the LifeCycle Status to the value passed to the script from the command line.

12

Defines the set_target_property_value verb, which sets the value using the property_records option. When this verb is set for a target pair, it moves to the next one. This example shows three databases, but in reality, use this script for a larger number of databases.

13 -15

Else statement combined with the if condition in line #5. If the arguments specified in line #5 are not provided correctly, then the script displays one of the following error messages:

  • Property value argument is missing

  • Format to run this file is filename.py <username> <Database Target LifeCycle Status Property Value>