Overview

This chapter contains the following sections:

VM Guest Customization Options

To customize guest operating systems on a VM, Cisco UCS Director provides you the following options:

  • The Execute VIX Scripts task, the Execute VM Commands task, and the Guest Operations tasks from the Cisco UCS Director library tasks, which help execute VIX scripts or commands on the VM.

  • The " userAPIExecuteVIXScript" API and the "EXECUTE_VIX_SCRIPT" API, which help execute VIX scripts on the VM.

Prerequisites

Before you consider customizing your guest operating systems through Cisco UCS Director, read through the following prerequisites:

  • Install the latest VMware tools on the vCenter.

  • Power on the VM that has the guest operating system installed.

  • Make sure the latest VMware tools are installed and running on the guest VM.

  • Obtain the administrator credentials for the guest VM.

  • Make sure the ESX/ESXi host is reachable from UCS Director.

Escape Characters

An escape sequence is a backslash (\) followed by a character. Escape characters are used to specify actions such as inserting a new line and a tab. The following table lists the Java escape sequences:

Escape Sequence

Inserts

\t

Tab

\b

Backspace

\n

New line

\r

Carriage return

\f

Formfeed

\'

Single quotation mark

\"

Double quotation mark

\\

Backslash

\$

Dollar variable

\|

Pipe to send output of one command to other in text

\+

Plus character

\^

Caret character

\\&

Ampersand character

When an escape sequence is encountered in a command, the compiler interprets it accordingly. For example, to use quotes within quotes, use the escape sequence (\") on the interior quotes. To print SQL instance name is "ucsd_instance1", enter the command as follows:

echo "SQL instance name is \"ucsd_instance1\""

If the command contains a backslash (\), add one more '\' character as prefix to the '\' character to send the correct command to the VM. If the command includes a UCSD variable (${variable}), use four backslashes '\\\\' instead of two.

Examples:
C:\\WINDOWS\\system32\\cmd.exe mkdir C:\\test1					// two backslashes

C:\\\\sqlinstall\\\\install.cmd ${SQL_INSTANCE_NAME}								// four backslashes,
                                                            // as UCS Director variables are used in the command

Status Codes

The following table lists some of the VIX status codes:

Code

Description

0

Command successfully executed

1

Unknown error

127

Exception thrown – Command not found

9009

Exception thrown - Not recognized as an operable program or command

3014

Insufficient permissions in host operating system

3015

Authentication failure or insufficient permissions in guest operating system

For a complete list of VIX status codes, refer to VIX Error Codes documentation on the VMware Support site.

After execution of commands, you can check the Cisco UCS Director workflow logs to see whether the VIX script has successfully executed the command. On successful execution, the workflow log shows the status code as 0. For a failed task or passing of irrelevant commands, the VIX script shows a status code other than 0.


Note


In the Cisco UCS Director workflow logs, you see that the ERROR_STATUS_MESSAGE is empty when EXIT_STATUS_CODE = 0 and EXIT_STATUS_CODE = 1. Other Exit Status Codes, however, display proper error messages.


After the task is completed on the VM, you can verify the status code in the VM as well. For a Linux VM, verify the status code by entering the command echo $?. For a Windows VM, verify the status code by entering echo %ERRORLEVEL%.