VCF Automation Blog

from Stefan Schnell


Tips for Handling the VMware Hands-on Labs


VMware Hands-on Labs (HOL) is a great way to learn about and test VMware products. This post describes how this environment can be handled, in consideration of a system language other than the one preset in the HOL. Everything works in a web browser and no installation is necessary. The settings in the HOL environment are a standard, e.g. English keyboard layout.

Linux

Show English Keyboard Layout

To view the English keyboard layout click in the upper right region and choose the settings (gearwheel icon). Choose keyboard in the side bar and in the burger menu choose the item View Keyboard Layout. A virtual keyboard with the English keyboard layout is now displayed.

keyboard icon in the system tray
english keyboard layout

Choose another Keyboard Layout

Choose + Add Input Source > Burger item > Scroll down and choose Other > Enter the language or country > Click on it and press the Add button
This will display an additional icon in the upper right region, which shows the selected language.

language change menu
Hint: When a text is transferred, the English keyboard layout must always be activated.

Use Mousepad as Destination for Text Transfer

It is recommended to always use Mousepad as the destination for a text transfer.

Configure Mousepad

To ensure better text transfer, Mousepad should be set as follows:

Keyboard Shortcuts in Visual Studio Code

Visual Studio Code offers keyboard shortcuts to format the source code.
With Ctrl+Shift+I is it possible to format the document.

Windows

Show English Keyboard Layout

To view the English keyboard layout click on the keyboard icon in the system tray and select the layout. A virtual keyboard with the English keyboard layout is now displayed. The desired character can now be entered.
keyboard icon in the system tray
different keyboard layouts
english keyboard layout

Use Notepad++ as Destination for Text Transfer

It is recommended to always use Notepad++ as the destination for a text transfer. Tabs and spaces are added during text transfer, which must be removed again afterwards. The easiest way to do this is with Notepad++.

Configure Notepad++

To ensure better text transfer, Notepad++ should be set as follows:

Avoid Indentations at Transfer Text

When sending text with indentations, e.g. whitespaces, these are retained, after a line break. Therefore leading whitespaces should be removed before sending the text to the console. Otherwise it can quickly happen that the text is aligned far to the right. To delete leading whitespaces you can use a regular expression like ^\s+.
If the text data was transferred directly in the VCF Automation editor of the embedded Orchestrator, e.g if it is a JavaScript source, it is possible to use format document from the command palette, or with the keyboard shortcut Shift+Alt+F. This command removes all indentations with one step.
Hint: This procedure does not work with Python.

Transfer Binary Files

Sometimes it is necessary to transfer binary data to the HOL, e.g. a zip file. To make this possible, it is necessary to convert the binary data into the base64 format beforehand. Below are two PowerShell scripts that can be used to do the conversion and return to the original format. PowerShell is available in the HOL.

File to Base64

Converts the given file to base64 format and stores it with the same name with the additional extension base64.
# convertFileToBase64.ps1

Param (
  [Parameter(Mandatory=$true)]
  [System.String]$fileName
)

if ($PSVersionTable.PSVersion.Major -gt 5) {
  [System.Array]$fileContent = `
    Get-Content -Path $fileName -AsByteStream -Raw
} else {
  [System.Array]$fileContent = `
    Get-Content -Path $fileName -Encoding Byte
}

[System.String]$fileContentBase64 = `
  [System.Convert]::ToBase64String($fileContent)
Set-Content -Path "$($fileName).base64" `
  -Value $fileContentBase64 -Encoding ASCII

Base64 to File

Converts a file, which contains data in base64 format, back to the original and stores the file with the given filename without the extension base64.
# convertBase64ToFile.ps1

Param (
  [Parameter(Mandatory=$true)]
  [System.String]$fileName
)

if ($fileName.EndsWith(".base64")) {
  $fileName = $fileName.SubString(0, $fileName.Length - 7)
}

[System.String]$fileContentBase64 = `
  Get-Content -Path "$($fileName).base64" -Encoding ASCII
[System.Array]$fileContentBase = `
  [System.Convert]::FromBase64String($fileContentBase64)

if ($PSVersionTable.PSVersion.Major -gt 5) {
  Set-Content -Path $fileName -Value $fileContentBase -AsByteStream
} else {
  Set-Content -Path $fileName -Value $fileContentBase -Encoding Byte
}

Conclusion

HOLs are a fantastic way to learn about and test VMware products. With a few procedures we can already optimize our handling with it, to simplify our trainings and tests in consideration of another system language.