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.

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. This procedure makes the handling of the HOL much easier.

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, as can be seen in the following image. 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+.

send text to a hands-on lab with indentations
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. 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.