vSphere 6.5: Failed to deploy OVF package from the Content Library

Working on automating the virtual machine (VM) provisioning from an OVF template in a content library in vSphere 6.5 Update 2, I ran across an interesting behaviour. Some virtual machines were created without any issues, whereas others have been failing with the error message ‘Failed to deploy OVF package.’

OVF-Template-Issue-00

OVF-Template-Issue-01

In the vpxd.log on vCenter Server, this error message looks as follows:

info vpxd[7F83D22C5700] [Originator@6876 sub=Default opID=SelectResourcePageMediator-validate-335519-ngc:70031913-ae-71-7e-92-01] [VpxLRO] — ERROR task-51355 — TEST-VM-01 — ResourcePool.ImportVAppLRO: vim.fault.OvfImportFailed:
–> Result:
–> (vim.fault.OvfImportFailed) {
–> faultCause = (vim.fault.NotFound) {
–> faultCause = (vmodl.MethodFault) null,
–> faultMessage = (vmodl.LocalizableMessage) [
–> (vmodl.LocalizableMessage) {
–> key = “com.vmware.ovfs.ovfs-main.ovfs.object_not_found”,
–> arg = (vmodl.KeyAnyValue) [
–> (vmodl.KeyAnyValue) {
–> key = “0”,
–> value = “/TEST-VM-01/nvram”
–> }
–> ],
–> message = “The specified object /TEST-VM-01/nvram could not be found.”
–> }
–> ]
–> msg = “The specified object /TEST-VM-01/nvram could not be found.”
–> },
–> faultMessage = <unset>
–> msg = “”
–> }
–> Args:
–>

The NVRAM file contains information such as BIOS settings. As VMware states here, a new NVRAM file is created ‘when a virtual machine is migrated, migrated with vMotion, cloned or deployed from a template.’

Looking through the knowledge base articles on the vendor’s website, I have found the following hint in KB 2108718:

Error 2: Could not find the file

This issue occurs if the NVRAM file mentioned in the virtual machines configuration file(*.vmx) is not available anymore.

As you might know, templates are stored in OVF format in the content library. Two files compose a template: an OVF descriptor (.ovf) and a virtual disk file (.vmdk). During the VM provisioning phase, the settings listed in the OVF descriptor form the virtual machine’s configuration file (.vmx). So my assumption was that one of those settings caused a conflict that prevented vSphere from creating those VMs.

When we clone a template to the content library, only minimum required settings are stored in the OVF descriptor. However, there is an option available to include extra configuration.

OVF-Template-Issue-02

I decided to compare a vanilla OVF descriptor with the one with extra settings. While doing this comparison, one particular line in the file with extra configuration caught my eye:

<vmw:ExtraConfig ovf:required=”false” vmw:key=”firmware” vmw:value=”efi”/>

For some reason, the provisioning task is not able to succeed in creating new virtual machines with the EFI firmware from the template in vSphere 6.5. This issue happens regardless of the guest operating system version and content library type (local or subscribed).

Surprisingly, I do not see any problem with deploying VMs with the EFI firmware from the content library in vSphere 6.0. I need some time to test this functionality in vSphere 6.7, before opening a support request with VMware.

Workaround: Feel free to use a PowerCLI script below to set the firmware type to EFI after provisioning a new VM.

# File name: Set-EFIFirmware.ps1
#
# Description: This script checks and sets the firmware type to EFI for a particular VM
#
# 26/07/2018 - Version 1.0
# - Initial Release
#
# Author: Roman Dronov (c)
# Clear the screen
Clear-Host
# Set the function
function Set-Firmware {
[CmdletBinding()]
Param
(
[Parameter(Mandatory=$true, Position=0)]
[string]$Argument
)
$choice = Read-Host "`n Would you like to set the firmware type to EFI? (Yes/No)"
while ("Yes","No" -notcontains $choice){
$choice = Read-Host "`n Would you like to set the firmware type to EFI? (Yes/No)"
}
switch ($choice){
"Yes" {
Write-Host " Checking the VM power state..." -NoNewline
if ($vm.PowerState -eq 'PoweredOff'){
Write-Host " The VM is powered off." -ForegroundColor Green
Write-Host " Setting the firmware type..." -NoNewline
if ($Argument -eq '0'){
Get-VM -Name $vmName | New-AdvancedSetting -Name 'firmware' -Value 'efi' -Confirm:$false | Out-Null
}
elseif ($Argument -eq '1'){
Get-VM -Name $vmName | Get-AdvancedSetting -Name 'firmware' | Set-AdvancedSetting -Value 'efi' -Confirm:$false | Out-Null
}
Write-Host " Completed successfully!" -ForegroundColor Green
}
else {
Write-Host " $vm is powered on!" -ForegroundColor Red
Write-Host " Please shutdown the VM and run this script again." -ForegroundColor Yellow
}
Write-Host "`n Exiting..."
}
"No" {
Write-Host " Cancelled by the user." -ForegroundColor Yellow
Write-Host "`n Exiting..."
}
}
}
# Promp for the VM name
$vmName = $null
while ($vmName -eq $null){
$vmName = Read-Host -Prompt "`n Input the VM name"
if ($vmName -eq '' -or -not (Get-VM -Name $vmName -ErrorAction SilentlyContinue)){
Write-Host " Invalid VM name, please re-enter." -ForegroundColor Yellow
$vmName = $null
}
}
# Check the firmware advanced setting
$vmName = $vmName.ToUpper()
$vm = Get-VM -Name $vmName
$vmFirmware = Get-AdvancedSetting -Entity $vm -Name 'firmware'
Write-Host "`n Checking the firmware advanced setting for $vmName..."
if (-not $vmFirmware){
Write-Host " Parameter not exist." -ForegroundColor Yellow
# Set the firmware advanced setting to EFI
Set-Firmware -Argument 0
}
elseif ($vmFirmware.Value -ieq 'efi'){
Write-Host " $vmName has the firmware type set to EFI already." -ForegroundColor Green
Write-Host "`n Exiting..."
}
else {
$vmFirmwareValue = $vmFirmware.Value
$vmFirmwareValue = $vmFirmwareValue.ToUpper()
Write-Host " $vmName has the firmware type set to $vmFirmwareValue." -ForegroundColor Yellow
# Set the firmware advanced setting to EFI
Set-Firmware -Argument 1
}
view raw Set-EFIFirmware.ps1 hosted with ❤ by GitHub

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s