cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2332
Views
0
Helpful
0
Comments
midupont
Cisco Employee
Cisco Employee
Task NameVM Details
Description
  1. Retrieve datastore for current VM and create a disk on that datastore
  2. Create and execute a temporary VB script to partition and format the drive
Prerequisites
  1. Tested on 5.3
  2. vCenter (VIX script execution does not work on any other hypervisor)
  3. Will only work on a Windows VM.  Linux VMs need to be handled completely differently.
CategoryWorkflow
ComponentsvSphere 5.x
User Inputs

Disk Size of new disk

Drive Letter for new disk

Drive Label of new disk

Username of administrative user of the VM

Password of the administrative user of the VM

Instructions for Regular Workflow Use:

  1. Download the attached .ZIP file below to your computer. *Remember the location of the saved file on your computer.
  2. Unzip the file on your computer. Should end up with a .WFD file.
  3. Log in to UCS Director as a user that has "system-admin" privileges.
  4. Navigate to "Policies-->Orchestration" and click on "Import".
  5. Click "Browse" and navigate to the location on your computer where the .WFD file resides. Choose the .WFD file and click "Open".
  6. Click "Upload" and then "OK" once the file upload is completed. Then click "Next".
  7. Click the "Select" button next to "Import Workflows". Click the "Check All" button to check all checkboxes and then the "Select" button.
  8. Click "Submit".
  9. A new folder should appear in "Policies-->Orchestration" that contains the imported workflow. You will now need to update the included tasks with information about the specific environment.

This example uses a VBS script.  To see a DOS only version that accomplishes a similar result see  Windows VM Disk Create (Partition, Format and Assign Drive Letter)(VIX to DOS)

The Workflow:

The Workflow inputs:

Results after execution:

Note:

     If VIX has a UCSD variable all \\ turn into \\\\, this is seen is task 4 of the workflow.

     The following 3 symbols can be passed to a Windows echo command ONLY when on the FIRST line of the VIX script task:  & >  <

     In all cases the symbol needs to be passed with \^ in front.

     The \ being the VIX escape character and the ^ being the DOS escape character.  This can be seen on the first line of steps 5 and 6.

Run Log:

Service Request ID: 1377

Workflow Inputs:

- DiskSize

- DriveLetter

- DriveLabel

- VM-UserName

- VM-Password

Jun 19, 2015 02:37:34 UTC Request submitted

Jun 19, 2015 02:37:36 UTC Executing workflow item number 1

Jun 19, 2015 02:37:36 UTC Completed workflow item number 1, with status Completed

Jun 19, 2015 02:37:42 UTC Executing workflow item number 2

Jun 19, 2015 02:37:42 UTC Trigger context executeWorkFlowStep called

Jun 19, 2015 02:37:42 UTC Executing custom action Create and Format Windows Disk (custom_Get_VM_Datastore0)

Jun 19, 2015 02:37:42 UTC Executing custom action Create and Format Windows Disk (custom_Get_VM_Datastore0) for VM 3806 (SR1605)

Jun 19, 2015 02:37:42 UTC Executing custom script for Get_VM_Datastore0

Jun 19, 2015 02:37:43 UTC The Datastore0 of the VM with a VM_ID of '3806' is: P3_Datastore01.

Jun 19, 2015 02:37:43 UTC Processing output: VM_Datastore0

Jun 19, 2015 02:37:43 UTC Task #1 (Create and Format Windows Disk (custom_Get_VM_Datastore0)) completed successfully in 0 seconds

Jun 19, 2015 02:37:43 UTC Input/Output values for Task #1 (Create and Format Windows Disk (custom_Get_VM_Datastore0)):

Jun 19, 2015 02:37:43 UTC [Mapped Input: VM ID = 3806]

Jun 19, 2015 02:37:43 UTC [Output: VM_Datastore0 = P3_Datastore01]

Jun 19, 2015 02:37:43 UTC Completed workflow item number 2, with status Completed

Jun 19, 2015 02:37:48 UTC Executing workflow item number 3

Jun 19, 2015 02:37:48 UTC Trigger context executeWorkFlowStep called

Jun 19, 2015 02:37:48 UTC Executing custom action Create and Format Windows Disk (custom_Create VM Disk - 2015-06-02)

Jun 19, 2015 02:37:48 UTC Executing custom action Create and Format Windows Disk (custom_Create VM Disk - 2015-06-02) for VM 3806 (SR1605)

Jun 19, 2015 02:37:48 UTC Executing custom script for Create VM Disk - 2015-06-02

Jun 19, 2015 02:37:49 UTC Executing create disk action on VM 3806 as part of custom action Create and Format Windows Disk, (datastore=P3_Datastore01, New Disk Size(GB)=5)

Jun 19, 2015 02:37:49 UTC Waiting for action to complete

Jun 19, 2015 02:38:19 UTC Action Complete

Jun 19, 2015 02:38:19 UTC Task #2 (Create and Format Windows Disk (custom_Create VM Disk - 2015-06-02)) completed successfully in 30 seconds

Jun 19, 2015 02:38:19 UTC Input/Output values for Task #2 (Create and Format Windows Disk (custom_Create VM Disk - 2015-06-02)):

Jun 19, 2015 02:38:19 UTC [Mapped Input: Select VM = 3806]

Jun 19, 2015 02:38:19 UTC [Mapped Input: Disk Size (GB) = 5]

Jun 19, 2015 02:38:19 UTC [Mapped Input: Select Datastore = P3_Datastore01]

Jun 19, 2015 02:38:19 UTC [Local Input: Thin Provisioning = false]

Jun 19, 2015 02:38:19 UTC Completed workflow item number 3, with status Completed

Jun 19, 2015 02:38:24 UTC Executing workflow item number 4

Jun 19, 2015 02:38:24 UTC Trigger context executeWorkFlowStep called

Jun 19, 2015 02:38:25 UTC Executing custom action Create and Format Windows Disk (Execute VIX Script)

Jun 19, 2015 02:38:25 UTC Executing custom action Create and Format Windows Disk (Execute VIX Script) for VM 3806 (SR1605)

Jun 19, 2015 02:38:29 UTC [VIXActionHandler] - account details VMName :SR1605 , Host :phx2-p3-esxi04.cisco.com , OS Type :microsoft windows server 2008 r2 (64-bit) , ExitCode

Jun 19, 2015 02:38:29 UTC Task #3 (Create and Format Windows Disk (Execute VIX Script)) completed successfully in 4 seconds

Jun 19, 2015 02:38:29 UTC Input/Output values for Task #3 (Create and Format Windows Disk (Execute VIX Script)):

Jun 19, 2015 02:38:29 UTC [Mapped Input: Select VM = 3806]

Jun 19, 2015 02:38:29 UTC [Local Input: Credential Type = Login]

Jun 19, 2015 02:38:29 UTC [Mapped Input: Login = administrator]

Jun 19, 2015 02:38:29 UTC [Mapped Input: Password = **masked-value**]

Jun 19, 2015 02:38:29 UTC [Template Input:Script = c:\\\\windows\\\\system32\\\\cmd.exe '/c echo Set objWMIService = GetObject(\\'winmgmts:\\\\\\.\\\\root\\\\cimv2\\') > c:\\\\windows\\\\temp\\\\NewDrive.vbs' && c:\\\\windows\\\\system32\\\\cmd.exe '/c echo Set colVolumes = objWMIService.ExecQuery (\\'Select * from Win32_DiskDrive where Partitions = 0\\') &gt;> c:\\\\windows\\\\temp\\\\NewDrive.vbs' && c:\\\\windows\\\\system32\\\\cmd.exe '/c echo For Each objVolume in colVolumes &gt;> c:\\\\windows\\\\temp\\\\NewDrive.vbs' && c:\\\\windows\\\\system32\\\\cmd.exe '/c echo int_index = objVolume.Index &gt;> c:\\\\windows\\\\temp\\\\NewDrive.vbs' && c:\\\\windows\\\\system32\\\\cmd.exe '/c echo txt_index = CStr(int_index) &gt;> c:\\\\windows\\\\temp\\\\NewDrive.vbs' && c:\\\\windows\\\\system32\\\\cmd.exe '/c echo Next &gt;> c:\\\\windows\\\\temp\\\\NewDrive.vbs' && c:\\\\windows\\\\system32\\\\cmd.exe '/c echo set objShell = WScript.CreateObject(\\'WScript.Shell\\') &gt;> c:\\\\windows\\\\temp\\\\NewDrive.vbs' && c:\\\\win

Jun 19, 2015 02:38:29 UTC [Resolved Template Input: Script = c:\\windows\\system32\\cmd.exe '/c echo Set objWMIService = GetObject(\'winmgmts:\\\.\\root\\cimv2\') > c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo Set colVolumes = objWMIService.ExecQuery (\'Select * from Win32_DiskDrive where Partitions = 0\') &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo For Each objVolume in colVolumes &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo int_index = objVolume.Index &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo txt_index = CStr(int_index) &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo Next &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo set objShell = WScript.CreateObject(\'WScript.Shell\') &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo set objExec = objShell.Exec(\'diskpart.exe\') &gt;> c:\\win

Jun 19, 2015 02:38:29 UTC [Local Input: Script = c:\\windows\\system32\\cmd.exe '/c echo Set objWMIService = GetObject(\'winmgmts:\\\.\\root\\cimv2\') > c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo Set colVolumes = objWMIService.ExecQuery (\'Select * from Win32_DiskDrive where Partitions = 0\') &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo For Each objVolume in colVolumes &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo int_index = objVolume.Index &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo txt_index = CStr(int_index) &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo Next &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo set objShell = WScript.CreateObject(\'WScript.Shell\') &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo set objExec = objShell.Exec(\'diskpart.exe\') &gt;> c:\\windows\\temp\\

Jun 19, 2015 02:38:29 UTC [Local Input: Undo Script = ]

Jun 19, 2015 02:38:29 UTC [Output: EXIT_STATUS_CODE = 0]

Jun 19, 2015 02:38:29 UTC [Output: ERROR_STATUS_MESSAGE = ]

Jun 19, 2015 02:38:29 UTC Completed workflow item number 4, with status Completed

Jun 19, 2015 02:38:31 UTC Executing workflow item number 5

Jun 19, 2015 02:38:31 UTC Trigger context executeWorkFlowStep called

Jun 19, 2015 02:38:31 UTC Executing custom action Create and Format Windows Disk (Execute VIX Script)

Jun 19, 2015 02:38:31 UTC Executing custom action Create and Format Windows Disk (Execute VIX Script) for VM 3806 (SR1605)

Jun 19, 2015 02:38:35 UTC [VIXActionHandler] - account details VMName :SR1605 , Host :phx2-p3-esxi04.cisco.com , OS Type :microsoft windows server 2008 r2 (64-bit) , ExitCode

Jun 19, 2015 02:38:35 UTC Task #4 (Create and Format Windows Disk (Execute VIX Script)) completed successfully in 4 seconds

Jun 19, 2015 02:38:35 UTC Input/Output values for Task #4 (Create and Format Windows Disk (Execute VIX Script)):

Jun 19, 2015 02:38:35 UTC [Mapped Input: Select VM = 3806]

Jun 19, 2015 02:38:35 UTC [Local Input: Credential Type = Login]

Jun 19, 2015 02:38:35 UTC [Mapped Input: Login = administrator]

Jun 19, 2015 02:38:35 UTC [Mapped Input: Password = **masked-value**]

Jun 19, 2015 02:38:35 UTC [Local Input: Script = c:\\windows\\system32\\cmd.exe '/c echo If InStr(IgnoreThis, \'DISKPART>\') \^<\^> 0 Then Exit Do >> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo Loop &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo objExec.StdIn.Write VbCrLf &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo ExecuteDiskPartCommand = \'\' &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo Do While True &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo ExecuteDiskPartCommand = ExecuteDiskPartCommand + objExec.StdOut.ReadLine + vbcrlf &gt;> c:\\windows\\temp\\NewDrive.vbs']

Jun 19, 2015 02:38:35 UTC [Local Input: Undo Script = ]

Jun 19, 2015 02:38:35 UTC [Output: EXIT_STATUS_CODE = 0]

Jun 19, 2015 02:38:35 UTC [Output: ERROR_STATUS_MESSAGE = ]

Jun 19, 2015 02:38:35 UTC Completed workflow item number 5, with status Completed

Jun 19, 2015 02:38:37 UTC Executing workflow item number 6

Jun 19, 2015 02:38:37 UTC Trigger context executeWorkFlowStep called

Jun 19, 2015 02:38:37 UTC Executing custom action Create and Format Windows Disk (Execute VIX Script)

Jun 19, 2015 02:38:37 UTC Executing custom action Create and Format Windows Disk (Execute VIX Script) for VM 3806 (SR1605)

Jun 19, 2015 02:38:41 UTC [VIXActionHandler] - account details VMName :SR1605 , Host :phx2-p3-esxi04.cisco.com , OS Type :microsoft windows server 2008 r2 (64-bit) , ExitCode

Jun 19, 2015 02:38:41 UTC Task #5 (Create and Format Windows Disk (Execute VIX Script)) completed successfully in 4 seconds

Jun 19, 2015 02:38:41 UTC Input/Output values for Task #5 (Create and Format Windows Disk (Execute VIX Script)):

Jun 19, 2015 02:38:41 UTC [Mapped Input: Select VM = 3806]

Jun 19, 2015 02:38:41 UTC [Local Input: Credential Type = Login]

Jun 19, 2015 02:38:41 UTC [Mapped Input: Login = administrator]

Jun 19, 2015 02:38:41 UTC [Mapped Input: Password = **masked-value**]

Jun 19, 2015 02:38:41 UTC [Local Input: Script = c:\\windows\\system32\\cmd.exe '/c echo If InStr(ExecuteDiskPartCommand, \'DISKPART>\') \^<\^> 0 Then Exit Do >> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo Loop &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo End Function &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo Sub ExitDiskPart &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo objExec.StdIn.Write \'exit\' + VbCrLf &gt;> c:\\windows\\temp\\NewDrive.vbs' && c:\\windows\\system32\\cmd.exe '/c echo End Sub &gt;> c:\\windows\\temp\\NewDrive.vbs']

Jun 19, 2015 02:38:41 UTC [Local Input: Undo Script = ]

Jun 19, 2015 02:38:41 UTC [Output: EXIT_STATUS_CODE = 0]

Jun 19, 2015 02:38:41 UTC [Output: ERROR_STATUS_MESSAGE = ]

Jun 19, 2015 02:38:41 UTC Completed workflow item number 6, with status Completed

Jun 19, 2015 02:38:46 UTC Executing workflow item number 7

Jun 19, 2015 02:38:46 UTC Trigger context executeWorkFlowStep called

Jun 19, 2015 02:38:46 UTC Executing custom action Create and Format Windows Disk (Execute VIX Script)

Jun 19, 2015 02:38:46 UTC Executing custom action Create and Format Windows Disk (Execute VIX Script) for VM 3806 (SR1605)

Jun 19, 2015 02:39:38 UTC [VIXActionHandler] - account details VMName :SR1605 , Host :phx2-p3-esxi04.cisco.com , OS Type :microsoft windows server 2008 r2 (64-bit) , ExitCode

Jun 19, 2015 02:39:38 UTC Task #6 (Create and Format Windows Disk (Execute VIX Script)) completed successfully in 52 seconds

Jun 19, 2015 02:39:38 UTC Input/Output values for Task #6 (Create and Format Windows Disk (Execute VIX Script)):

Jun 19, 2015 02:39:38 UTC [Mapped Input: Select VM = 3806]

Jun 19, 2015 02:39:38 UTC [Local Input: Credential Type = Login]

Jun 19, 2015 02:39:38 UTC [Mapped Input: Login = administrator]

Jun 19, 2015 02:39:38 UTC [Mapped Input: Password = **masked-value**]

Jun 19, 2015 02:39:38 UTC [Local Input: Script = C:\\Windows\\system32\\cscript.exe c:\\windows\\temp\\NewDrive.vbs]

Jun 19, 2015 02:39:38 UTC [Local Input: Undo Script = ]

Jun 19, 2015 02:39:38 UTC [Output: EXIT_STATUS_CODE = 0]

Jun 19, 2015 02:39:38 UTC [Output: ERROR_STATUS_MESSAGE = ]

Jun 19, 2015 02:39:38 UTC Completed workflow item number 7, with status Completed

Jun 19, 2015 02:39:40 UTC Executing workflow item number 8

Jun 19, 2015 02:39:40 UTC Trigger context executeWorkFlowStep called

Jun 19, 2015 02:39:40 UTC Executing custom action Create and Format Windows Disk (Execute VIX Script)

Jun 19, 2015 02:39:40 UTC Executing custom action Create and Format Windows Disk (Execute VIX Script) for VM 3806 (SR1605)

Jun 19, 2015 02:39:44 UTC [VIXActionHandler] - account details VMName :SR1605 , Host :phx2-p3-esxi04.cisco.com , OS Type :microsoft windows server 2008 r2 (64-bit) , ExitCode

Jun 19, 2015 02:39:44 UTC Task #7 (Create and Format Windows Disk (Execute VIX Script)) completed successfully in 4 seconds

Jun 19, 2015 02:39:44 UTC Input/Output values for Task #7 (Create and Format Windows Disk (Execute VIX Script)):

Jun 19, 2015 02:39:44 UTC [Mapped Input: Select VM = 3806]

Jun 19, 2015 02:39:44 UTC [Local Input: Credential Type = Login]

Jun 19, 2015 02:39:44 UTC [Mapped Input: Login = administrator]

Jun 19, 2015 02:39:44 UTC [Mapped Input: Password = **masked-value**]

Jun 19, 2015 02:39:44 UTC [Local Input: Script = c:\\windows\\system32\\cmd.exe /c del c:\\windows\\temp\\NewDrive.vbs]

Jun 19, 2015 02:39:44 UTC [Local Input: Undo Script = ]

Jun 19, 2015 02:39:44 UTC [Output: EXIT_STATUS_CODE = 0]

Jun 19, 2015 02:39:44 UTC [Output: ERROR_STATUS_MESSAGE = ]

Jun 19, 2015 02:39:44 UTC Completed workflow item number 8, with status Completed

Jun 19, 2015 02:39:49 UTC Executing workflow item number 9

Jun 19, 2015 02:39:49 UTC Completed workflow item number 9, with status Completed

Before execution:

After execution:

The included custom tasks:

1) Create VM Disk to force disk size selector and force the "system" disk type selection (Step 2 of the attached workflow)

2) Select the first datastore of the target VM where the new disk is to be provisioned (Step 1 of the attached workflow)

Caveats

If there is already a raw disk on the VM then it is possible the script will partition and format the wrong disk.  Since disks are added in increasing order (i.e. index number) it is very likely that the new disk will have a higher number than the older disk so the new disk will be the one that gets partitioned and formatted. The only way the wrong raw disk will be partitioned and formatted is if a previous disk was deleted from the system with a higher index raw disk and then a new disk gets created which would be given a lower index number than the previously created raw disk.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links

Review Cisco Networking for a $25 gift card