Back in the 1980s, file systems in the computing world were notoriously inconsistent. Each major tech company—Apple, IBM, and Microsoft—had its own unique way of organizing files. This made it extremely difficult to share data between different platforms.

Then came the Compact Disc (CD). Initially developed for music, it didn’t take long for technology companies to realize that CDs could also be used to store software, documents, and even operating systems. However, the lack of a standard method for reading data CDs across different systems presented a major obstacle.

To solve this, Sony and Philips—who pioneered the CD-ROM—needed a file system that would work across all operating systems. In 1988, the International Organization for Standardization (ISO) introduced ISO 9660, a universal file system standard for CDs.

ISO 9660 was a game-changer. It allowed discs burned on one system to be read on others, including MS-DOS, UNIX, and Mac. This was a major breakthrough in cross-platform compatibility.

Fun Fact:
The original ISO 9660 standard had strict limitations: filenames could only be 8 characters long, with a 3-character extension (e.g., .TXT or .EXE)—a nod to MS-DOS constraints. Later extensions like Microsoft’s Joliet and UNIX’s Rock Ridge overcame these limitations by supporting longer filenames.

The Concept

Recently, I realized how useful it would be to mount an ISO to a virtual machine (VM) without needing access to vCenter or the datastore directly. It surprised me that I hadn’t tackled this before—time to fix that.

As I began designing the workflow, I initially thought to ask users for the VM and full ISO file path. But that’s prone to user error. A better solution? Build a more user-friendly system by letting users browse datastores and folders, and validate that the VM has a CD-ROM device. Here’s what the custom form should support:

– Browse available datastores
– Browse folders within those datastores
– Support root-level ISO files
– Validate the presence of a CD-ROM on the VM

Let’s dive in.

Getting Folders

Typically, ISOs are stored in a specific folder on a datastore. While hardcoding this path is possible, it would limit the flexibility of the workflow. So instead, I created an action that allows users to browse folders.

To retrieve folders:

– Define a query specification for folders
– Use searchDatastore_Task to run the query

Here’s the JavaScript code that accomplishes this:

function createQuery() {
return [new VcFolderFileQuery()];
}

function createSearchSpec(query) {
var spec = new VcHostDatastoreBrowserSearchSpec();
spec.query = query;
spec.sortFoldersFirst = true;
return spec;
}

function searchDatastore(datastoreBrowser, datastorePath, searchSpec) {
return datastoreBrowser.searchDatastore_Task(datastorePath, searchSpec);
}

function extractFolders(searchResults) {
return searchResults.file
.filter(file => file instanceof VcFolderFileInfo)
.map(file => file.path);
}

function main(datastore) {
if (!datastore) return [“”];
var path = `[${datastore.name}] `;
var query = createQuery();
var spec = createSearchSpec(query);
var task = searchDatastore(datastore.browser, path, spec);
var results = System.getModule(“com.vmware.library.vc.basic”).vim3WaitTaskEnd(task, false, 1);
return extractFolders(results);
}

return main(datastore);

Getting ISO Files

Once we have the folder, finding the ISO files inside it is similar. We just modify the query to look for VcIsoImageFileQuery instead.

function createQuery() {
return [new VcIsoImageFileQuery()];
}

function createSearchSpec(query) {
var spec = new VcHostDatastoreBrowserSearchSpec();
spec.query = query;
spec.details = new VcFileQueryFlags();
spec.details.fileSize = true;
spec.details.fileOwner = true;
spec.details.modification = true;
spec.details.fileType = true;
spec.searchCaseInsensitive = true;
spec.sortFoldersFirst = true;
return spec;
}

function extractIsoFilePaths(results) {
return results.file
.filter(file => file instanceof VcIsoImageFileInfo)
.map(file => file.path);
}

function main(datastore, folder) {
if (!datastore) return [“”];
var path = `[${datastore.name}] `;
if (folder) path += folder;
var query = createQuery();
var spec = createSearchSpec(query);
var task = datastore.browser.searchDatastore_Task(path, spec);
var results = System.getModule(“com.vmware.library.vc.basic

Similar Posts