ScriptvCloud Air

OVFtool wrapper for vCloud Air

Lately I’ve started using vCloud Air. That’s is a new experience for me, being used to using the fat client for a vSphere environment – The vCloud Air is a different experience, not bad, just other ways to get the normal day-to-day operations to work. One of the things I have played with is OVFtool, which is a command-line tool to upload ISOs and VMs to vCloud Air. Working with long command-line strings can be a bit annoying, as small typos quickly breaks things and it can be hard to spot the single digit error somewhere in the long text string.

As part of figuring out how to use the OVFtool I came by this blog post here by William Lam – In which he has created a bash script to help the upload process.

By the way, he has also made a cool post about how to get vcsa and psc uploaded to vCloud Air, see here


OVFtool wrapper

I created a script that help the process of getting files uploaded to vCloud Air in Powershell for the windows users.

Got a bit tired of gathering the same info and typing them in every time I have to upload some files, so I made an option to save the connection data to a clear text file (No username or password are saved). This means that two or three parameters are required as parameter options.

The following options are available, the two first are mandatory – The scripts need to know the file you want to upload and the name the file is going to have in vCloud Air. The last three are optional. These are made as a switch in the script meaning all you have to do to use them is the include the option as a parameter in the string without defining any string to the parameter.


If a config file exists it will be used unless the ClearConfig option is used (Which will delete the config file). If no file is used or ClearConfig option is used, you will be prompted for the options needed. Hint see the first William Lam post for details on how to get the needed information.

OVFtool wrapper vCloud Air

The script only supports iso-to-iso upload and ovf-to-ova, meaning you can upload iso files, and ovf files (including the entire VM) which will become a vApp (ova) once uploaded to vCloud Air. Might expand to include ova-to-ova, but haven’t had the use case so far.


Here it is – Thanks for reading – Comments and additions to the script are always welcome.

UPDATE 21/10-15 – ova upload handling been added.

# Inspired by:
# Reference:
# Created by Michael Ryom -

 param (
	[switch]$ISvappTemplate = $false,
    [switch]$SaveConfig = $false,
	[switch]$ClearConfig = $false

# Global variables 
$OVFTOOL = "$env:programfiles\VMware\VMware OVF Tool\ovftool.exe"
$Config = "$env:userprofile\vCloudAir\vCloud-air.conf"

if(!(Test-Path $OVFTOOL)){
throw "ovftool.exe was not found!
Hey Yo!
What's UP - Something went wrong
Couldn't find ovftool.exe in it default location!
Have you installed it, why not ?
You claim to have... hmm happy hacking then

if($ISvappTemplate -eq $true){
$vappType = "vappTemplate"
$vCloudTemplate = "true"
$vappType = "vapp"
$vCloudTemplate = "false"

#Delete config if $ClearConfig is true
if($ClearConfig -eq $True){
del $config

#Get input from console if config files doesn't exist or get it from file if file exists
if(!(Test-path $Config)){
# vCloud Air On-Demand VCD URL
$VCA_URL = Read-Host "Enter your url for vCloud Air"

# VCD Org Name
$VCA_ORG_NAME = Read-Host "Enter your org name"

# VCD VDC Name
$VCA_ORG_VDC_NAME = Read-host "Enter your VDC name"

# VCD Catalog Name
$VCA_CATALOG_NAME = Read-Host "Enter your catalog name"
}elseif(Test-path $Config){
$File = gc $Config
$VCA_URL = $File[0]
$VCA_ORG_NAME = $File[1]
$VCA_ORG_VDC_NAME = $File[2]

#Save input to config file
if($SaveConfig -eq $True){
if(!(Test-path $Config.TrimEnd("vCloud-air.conf"))){New-Item $Config.TrimEnd("vCloud-air.conf") -type directory}
if(!(Test-path $Config)){New-Item $Config -type file | out-null} 
$VCA_URL > $Config 
$VCA_ORG_NAME >> $Config 
$VCA_ORG_VDC_NAME >> $Config 

#Upload data
if($FILE_TO_UPLOAD.Split(".")[($FILE_TO_UPLOAD.Split(".").length)-1] -match "iso"){
}elseif($FILE_TO_UPLOAD.Split(".")[($FILE_TO_UPLOAD.Split(".").length)-1] -match "ovf"){
&${OVFTOOL} --acceptAllEulas --skipManifestCheck --vCloudTemplate=$vCloudTemplate --allowExtraConfig ${FILE_TO_UPLOAD} vcloud://${VCA_URL}?org=${VCA_ORG_NAME}"&"vdc=${VCA_ORG_VDC_NAME}"&"catalog=${VCA_CATALOG_NAME}"&"${vappType}=${FILE_FILENAME_IN_VCA}
}elseif($FILE_TO_UPLOAD.Split(".")[($FILE_TO_UPLOAD.Split(".").length)-1] -match "ova"){
&${OVFTOOL} --acceptAllEulas --skipManifestCheck --vCloudTemplate=$vCloudTemplate --allowExtraConfig ${FILE_TO_UPLOAD} vcloud://${VCA_URL}?org=${VCA_ORG_NAME}"&"vdc=${VCA_ORG_VDC_NAME}"&"catalog=${VCA_CATALOG_NAME}"&"${vappType}=${FILE_FILENAME_IN_VCA}


4 thoughts on “OVFtool wrapper for vCloud Air

    1. The catalog can be created in vCloud Air. If you need more ressources I belive you have to open a support case with the vCloud Air support team. Thanks for the nice words – hope you will follow my blog.

Leave a Reply

Your email address will not be published. Required fields are marked *