Unable to list Folders of Datastores in VIFS.pl Script

Author: NetworkAdminKB.com
Created: 2008-12-10
Modified: 2008-12-12

Issue:

The following VIFS.pl command is an example of how to list all the folders on a specific Datastore on a specific Datacenter and the specified VirtualCenter Server.

vifs.pl --server vc_server --passthroughauth -Z dc_name -D [ds_name]

 

This command (and slight variations) will always return the following error message.

 

GET https://vc_server /folder?dsName=ds_name unsuccessful : 404 Not Found

 

This issue was found in v3.5 Update 2 of the Remote CLI client available for download from VMWare here.

http://vmware.com/download/vi/drivers_tools.html

 

Cause:

The following is from the Remote Command-Line Interface Installation and Reference Guide

Update 2 Release for ESX Server 3.5, ESX Server 3i version 3.5, VirtualCenter 2.5.

 

The vifs command performs common operations such as copy, remove, get, and put

on files and directories. The command is supported on ESX Server 3 but not on

VirtualCenter Server.

 

From the syntax of the command there is no reason why the “LIST” commands should not work against a VirtualCenter server.  Ultimately the ability to “LIST” folders via VirtualCenter can be traced back to a programming error in the sub do_dir procedure in the VIFS.pl script.

 

Solution:

1)      Copy VIFS.pl file to VIFS2.pl

2)      Edit the VIFS2.pl file using Notepad

3)      Locate the sub do_dir procedure

4)      Modify the following line changing Current Line to the New Line as indicated in Bold.

a.       Current:

my $resp = VIExt::http_get_file($mode, $filepath, $ds, $dc, undef);

b.      New:

my $resp = VIExt::http_get_file($mode, $filepath, $ds, $datacenter, undef);

5)      Save the VIFS2.pl file

6)      Run the following command

Vifs2.pl --server vc_server --passthroughauth -Z dc_name -D [ds_name]

 

More Information:

The correct URL that the Perl script should send is:

https://vc_server/folder?dcPath=dc_name&dsName=ds_name

 

You can manually test the original URL and the new URL via any web browser.

 

This modification has only been tested with “LIST” commands.  The copy, remove, get, and put file not work against VirtualCenter Server.

Article ID: 113, Created On: 9/17/2011, Modified: 9/17/2011