Say I have 2 "physical" ESXs which are both headed by a vSphere Server. What I am trying to do is to run a script which would upload a file to a specified VM. So basically, I use the VIFS.pl script provided by the VMWare community, the documentation of which is available here : http://pubs.vmware.com/vsphere-51/index.jsp?topic=%2Fcom.vmware.vcli.ref.doc%2Fvifs.html and the code source is here : http://communities.vmware.com/docs/DOC-10774 .
The source code is pretty simple, it simply uses the http_put_file()
function from the VIExt
module, and this function actually fails for me, since I get an Error 500, the log of which is here (I got it by printing $resp->as_string()
) :
do_put() function
sub do_put {
my ($local_source, $remote_target, $datacenter) = @_;
my ($mode, $dc, $ds, $filepath) = VIExt::parse_remote_path($remote_target);
# bug 322577
if (defined $local_source and -d $local_source) {
VIExt::fail("Error: File to be uploaded cannot be a folder.");
}
# bug 266936
unless (-e $local_source) {
VIExt::fail("Error: File $local_source does not exist.");
}
my $resp = VIExt::http_put_file($mode, $local_source, $filepath, $ds, $datacenter);
# bug 301206
print $resp->as_string(); # => Trace
if ($resp && $resp->is_success) {
print "Uploaded file $local_source to $filepath successfully.\n";
} else {
print "Failed to upload !";
}
}
** Trace **
# vSphere server : @192.168.20.2
# Datastore : nfs
# Datacenter : dc
# Target VM name : target_vm
# Target filename : VM.txt
>> perl vifs --server 192.168.20.2 --username root --password root -p "/tmp/foo.txt" "[nfs] target_vm/VM.txt" -Z "dc"
HTTP/1.1 500 Internal Server Error
Connection: close
Date: Thu, 6 Dec 2012 10:32:30 GMT
Content-Length: 0
Content-Type: text; charset=plain
Client-Date: Thu, 06 Dec 2012 11:32:53 GMT
Client-Peer: 192.168.20.2:443
Client-Response-Num: 9
Client-SSL-Cert-Issuer: /C=US/ST=California/L=Palo Alto/O=VMware, Inc./CN=localhost.localdom CA 26fc6343/emailAddress=ssl-certificates@vmware.com
Client-SSL-Cert-Subject: /C=US/ST=California/L=Palo Alto/O=VMware, Inc./OU=VMware vCenter Server Certificate/emailAddress=ssl-certificates@vmware.com/CN=localhost.localdom/unstructuredName=1352217590,031bd875,564d7761726520496e632e
Client-SSL-Cipher: AES256-SHA
Client-SSL-Socket-Class: IO::Socket::SSL
Client-SSL-Warning: Peer certificate not verified
Failed to upload !
Please not that I checked the value of all the variables passed as argument in the http_put_file
function, they are all correct.
If someone ever experienced this problem, would be much appreciated...