Question

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...

Was it helpful?

Solution

I know some VMware, but have admittedly never tried to do what you're doing here, but I do have a thought to share with you.

If I'm not mistaken, your physical ESX host (192.168.20.2) is trying to place a file onto your VM (target_vm). Since that communication is happening over port 443

    Client-Peer: 192.168.20.2:443

I'm guessing that the VMware certificates that are perhaps on your VM do not match the domain that those VM's have been added to (or they are not added to a domain). The certificates look to be from 'localhost.localdom':

    CN=localhost.localdom

If you don't have a certificate authority in your domain already, perhaps you can quickly create a self-signed certificate for your domain and place it in the appropriate certificate store. You also might want to try some of those other API calls like:

    --listds | -S

Maybe they won't require SSL to connect since it's not going over HTTPS? That might validate that the certificates are, indeed, causing your problem?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top