How to import ISO images with OVFManagerImportLocalVApp sample code
search cancel

How to import ISO images with OVFManagerImportLocalVApp sample code

book

Article ID: 336367

calendar_today

Updated On:

Products

VMware vSphere ESXi

Issue/Introduction

The vSphere Web Services SDK sample program OVFManagerImportLocalVApp.java has no difficulty importing an OVF with a VMDK disk, but with a floppy or ISO image, the virtual disk is created correctly, but the downloaded ISO image gets truncated or corrupted.

Note: the sample code is not meant to be used in a production environment. Its purpose is to demonstrate importing an OVF with VMDK, but with the modifications shown below, it can import an OVF with ISO image intact.

Environment

VMware vSphere Web Services SDK 4.1

Resolution

The workaround is to modify the OVFManagerImportLocalVApp.java code by adding the pointed-to statement between lines 305 and 306. The virtual disk was created, empty, when OVF created the virtual machine, so you need to overwrite it.
        if (put) {
conn.setRequestMethod("PUT");
====> conn.setRequestProperty("Overwrite", "t");
System.out.println("HTTP method: PUT");
} else {
Additionally, for large ISO images, probably anything but JeOS, also decrease the sleep value on line 64 so that the NFC lease does not expire before timeout.
        Thread.sleep(200000);
The sample program uses HTTP file transfer, which is slow and relatively unreliable with large data sets. A better solution is to place ISO images on a mounted NFS partition so that disk images can be shared between virtual machines, thus reducing overall storage requirements. You can mount an NFS partition on ESXi with the vicfg-nas command, part of the vCLI package.