4.2.1 Script Analysis

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

Table 4-2 Line-by_Line Script Analysis

Lines Description

1-2

Imports all EM CLI verbs, and imports VerbExecutionError.

3-4

Imports Jython libraries.

6-25

Defines the job where the script updates the database password for each member of the l_grp_name group. After each successful job completion, the script displays a message to the user, and waits 2 seconds before processing the next job, unless there are any errors or all database passwords are updated.

27-43

Defines variables for updating the database password on each target member of the l_grp_name group. While the script successfully updates the database password, it provides the following message to the user before proceeding to update the password of the next database target:

Changing the password for member : name = database_name type = database_type

45-51

Defines a loop to get all members from the l_grp_name group and update the password for each member as defined in line #85. When the script starts processing this loop, it provides this message to the user:

Changing the password for group - l_grp_name from l_old_password to l_new_password

54-58

Necessary connection to OMS to retrieve all targets. Before connecting to the OMS, you must set the OMS connection details using the set_client_property() function. This sets the OMS URL to https://myoms.com/em and enables the client to trust all certificates.

Note that none of these details are stored in disk. These details are stored in memory and only last for a single script execution. For more information on client properties, enter help('client_properties') from the interactive shell.

You can define EMCLI_OMS_URL and EMCLI_TRUSTALL variables as environment variables if you do not want to set these in your script. If you have downloaded certificates somewhere, you can also use the environment variable EMCLI_CERT_LOC to point to the certificate directory. In this case, you do not need EMCLI_TRUSTALL. For more information, see Interactive Mode — Connecting to an Oracle Management Server (OMS).

60

Provides a login to the OMS. 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.

63

l_grp_name is a variable for the group name

65

l_group_members is a variable for the array of the database name and type.

69

Adds members from l_group_members to the l_grp_name group

71-74

Provides a message to users while the script is adding members to the l_grp_name group

77-79

Provides a prompt to users to decide if they want to continue with the script. If the user enters n, then the script exits. If the user enters y, then the script proceeds.

81

l_tgt_username is a variable for the user name of the database owner.

82

l_old_password is a variable for the existing password associated with the database owner.

83

l_new_password is a variable for the new password associated with the database owner.

85

Replaces the existing password with the new password for all members of the l_grp_name group.