Performing provisioning operations using bdacli
Command line utilities support using templates to perform provisioning operations on all the databases supported by BMC Database Automation (BDA). The bdacli utility uses command-based syntax that specifies what operations will be performed on the database by referencing a template for those operations.
Before you begin
Ensure that you have downloaded the command line utilities and have configured your environment to use them. For more information, see Setting-up-the-CLI-environment.
Manager address and user credentials
To successfully initiate a job, provide a manager address and login/password using environment variables or command line parameters. You will most likely use environment variables because of the likelihood that you will use one manager with its own BDA credentials. Note, however, that command line parameters take a precedence over environment variables.
The following environment variables are used:
- GA_MANAGER (manager address)
- GA_USERNAME (user)
- GA_PASSWORD (password)
Alternatively, the following command line parameters can be used:
- --manager
- --username
- --password
Password file and filename parameter
The --password-filename parameter is an optional parameter that takes the name of a password file, a plain text file that specifies the username on the first line and the password on the second line. If this parameter is specified, all checks related to GA_USERNAME and GA_PASSWORD environment variables are ignored.
Password file descriptor parameter
For UNIX environments, you can use the optional command line parameter --password-file-descriptor to pass the username and password to the bdacli utility. If the parameter is specified, all checks related to GA_USERNAME and GA_PASSWORD environment variables are ignored.
The file descriptor can be used while using the mtd_client in shell scripts. The following example shows how to use FIFO to pass the file descriptor to bdacli:
exec 4<>fifo; (echo sysadmin; echo pass) >&4; ./bdacli.pl --password-file-descriptor 4 ....
rm fifo
Using the utility
To use the tool, type the following command:
Where:
-type is the type of database on which you want BDA to perform the operation. You can use a shortcut to replace this option by typing the database type and command directly (for example, bdacli_mssql.pl --add-instance). You can use the DB type as a shortcut to replace the type option. For example:
bdacli_mssql.pl --add-instance
bdacli_oracle.pl --remove-database
bdacli_sybase.pl --apply-patch
bdacli_db2.pl --add-instance- <COMMAND> is a set of parameters to be specified. For one command these are host or instance names, and for another a user or cluster name. For example commands, see Provisioning operations.
- [COMMAND OPTIONS] are the variable parameters that must accompany a specific command. For example command options, see Provisioning operations.
- <TEMPLATE> is the template that is used to pass parameters relevant to that template. For more information, see Working with templates.
The following table describes the command line exit values that are used and their meaning.
Working with templates
You can specify a template in one of two ways:
Template FQN (for example,/ oracle_instance_provision_template)
- Template ID
Setting and overriding template parameters
Template parameters can be configured using the command line, an XML file, or the --params parameter.
Setting and overriding template parameters using the command line
Using the command line to set parameters is especially effective for operations that can be easily expressed in a wizard. For example, the following syntax is used for Oracle single instance provisioning:
Setting and overriding template parameters in an .xml file
When you have several parameters, you want to set or override in the template, you can type them into an XML file, as shown in the following example:
<parameters> <display_name>MYDB</display_name> <ora_home_location>/opt/oracle</ora_home_location> </parameters>=
You then reference the saved file in your command line syntax, as shown in the following example:
Setting and overriding template parameters using the --params parameter
Another option to set or override parameters in a template is to set the --params parameter in the bdacli utility. For example, the following existing template:
ora_home_location=/app/oracle
can be overridden using the utility, as follows:
Using custom fields and parameters to set and substitute values
You can define any number of custom fields, set field values as those custom fields and then, using the --params argument, override those values.
For example, set this custom field in your template:
<name>ASM_DISK_GROUP_NAME</name>
<value/>
<required>true</required>
<editable>true</editable>
</hidden>
</field>
Then, use it as a replacement custom field. For example:
Name: Disk Group Name
Description: The name of the diskgroup.
Required: This is a required field if specifying diskgroups.
-->
<name>{ASM_DISK_GROUP_NAME}</name>
Next, specify a new value using the params option. For example:
Provisioning operations
To locate a specific operation to perform using the bdacli command line tool, perform any of the following actions:
- Select an option from the Type list to filter the table by database type.
- Select an option from the Operation list to filter the table by a specific provisioning operation that you want to perform for the selected database type, such as Create Database.
- Type a character string in the Description boxes to filter the list of operations (for example, typing cre in the Description field displays all operations with Create in the description.
- Click any column heading to sort this table or change sort direction.
1 For SQL Server, the value for the --version parameter might not always match the file name generated by the mediaprep utility. For example:
- The file name generated after preparing SQL Server 2012 RTM media is sql_2012_x64_enterprise.zip. However, the --version parameter must also have the RTM appended to the filename (sql_2012_x64_enterprise_rtm).
- However, the file name generated after preparing rep SQL Server 2014 slipstreamed with Service Pack 1 is sql_2014_x64_enterprise_4100.zip. In this case the value for the --version parameter is sql_2014_x64_enterprise_4100.
List operations
In addition to enabling provisioning operations, the bdacli utility provides the ability to generate lists that help you perform pre- or post-provisioning operations, as described in the following examples.
List available patches for a specific database type
The bdacli_{type}.pl command enables you to list patches for a specific database type.
/PSU-Apr2012-11.2.0.3-Linux-x86_64
/PSU-Jul2012-11.2.0.3-Linux-x86_64
List unapproved objects that are under Pending Approval
The bdacli_unapproved.pl tool (formerly named list_unapproved.pl in version 8.8 of BDA) enables you to list unapproved objects that are under Pending Approval in BDA.
The following command options can be used in the syntax for the bdacli_unapproved.pl tool:
- --manager: Specify BDA manager URL to connect to. Can be set globally via GA_MANAGER.
- --sessid: Session ID (optional). Used locally in the client for logging purposes. Default value is auto-generated.
- --client-version: BDA cmdutils version information.
- --server-version: BDA mtd version information. Requires valid server credentials.
- --type: The specific object type. Options are node, oradb, sqlinst, ds, rs, db2_instance, db2_database, orapdb, avgrp, app, or ohome.
- --help: Command line tool help message.
Using bdacli_approve.pl after determining objects that are Pending Approval
You can subsequently approve any objects into BDA that are listed when running the bdacli_unapproved.pl command using the bdacli_approve.pl command line tool:
The following command options can be used in the syntax for the bdacli_approve.pl tool:
- --manager: Specify BDA manager URL to connect to. Can be set globally via GA_MANAGER
- --sessid: Session ID (optional). Used locally in the client for logging purposes. Default value is auto-generated.
- --client-version: BDA cmdutils version information
- --server-version: BDA mtd version information. Requires valid server credentials.
- --db2-database: Approve a DB2 database.
- --host-name=hostname: The host on which the database is located
- --instance-name=name: The name of the instance displayed in BDA
- --database-name=name: The name of the database
- --display-name=name: (optional) BDA name to approve. The default is the database name.
- --help: Command line tool help message
For example, the following script approves the DB2 instance db2inst2 on the specified manager, which is also reflected in the BDA GUI: