VMware introduced the Developer Center and Code Capture with the release of vCenter Server Appliance (VCSA) 6.7 U2 and it is available in all the new releases. In this post, we will look at the Developer Center Code Capture feature available in the vSphere 6.7 latest version.
The Developer Center is a single point of entry for developers that provides tools to manage API structure and to capture user actions to translate them into executable code. Also, the vSphere Client Developer Center provides tools for automation experts, DevOps engineers, and developers to find the resources to manage API structures and to capture vSphere Client actions to translate them into PowerCLI.
Code Capture gives you the ability to record actions taken in the vSphere Client and output them as usable PowerCLI code. And you can easily copy the code or download it as a script and use it in a PowerShell session to execute the task. This feature is available in HTML5 vSphere Client only and to use this you have to enable it first.
Code Capture records user actions and translates them into executable code, this will help administrators and engineers to analyze and reuse the actions through PowerCLI. And note that only vCenter Server calls are recorded. Calls made on operations regarding roles, privileges, tags, content libraries, and storage policies are not recorded.
Enable Code Capture
You can enable the code capture by following below procedure
- Navigate to menu and Click Developer Center
- Select Code Capture
- Click the toggle to enable Code Capture.
You can start the recording from the red record button in the top pane and While a recording is in progress, the red record button in the top pane blinks.
Navigate to your desired pane and Click on the red record button to start the recording. We are testing this feature by performing the clone of the virtual machine and powering on.
Navigate to Developer Center and you can see the only option available is STOP RECORDING since the recording is in progress
Once the clone the process is finished you can verify that the VM is running and stop the recording. And the code of the operations we performed which is cloning the VM and Power on is visible there.
And there are three other options available and STOP RECORDING is grayed after stopping the recording process.
CLEAR AND START ANOTHER: – This option will clear the captured code in a previous session and start a new session
You have to select the CLEAR AND RESTART option from the pop-up message to continue
COPY:- This option will copy the code, and you can paste to any notepad or any other suitable application to save it as PowerCLI format and use it for future purposes.
DOWNLOAD: – This option will download the code as a PowerCLI script
You can open in PowerShell application and verify the code
Disable Code Capture
You can disable the feature by Click the toggle to enable again from the Code Capture option. If you disable Code Capture, a pop-up message will appear “Disabling the Code Capture will clear actions recorded in the current session and hide Code Capture on the navigation header”. So make sure you copy or download the code before proceeding with this operation.
The Developer Center with Code Capture feature is very useful for VMware administrators and engineers to automate different tasks in the vSphere environment. The feature will allow you to “capture” the UI tasks you do within the UI into PowerCLI code and copy the code or download it as a script and use it in a PowerShell session to execute the tasks.