VMware {code} Community
rahulm
Contributor
Contributor

Vix and Perl - Simple example does not work

Hi!

I installed the VMWare Server 2.0 Beta today with hopes of using the Vix-perl api with VMWare Server. This server is installed on RHEL ES4

The installation went fine and I can connect to the vmware server on its website using the root username/password (but not as the user I am logged in to as on the machine). I found the libs for Vix and added them to the LD_LIBRARY_PATH

So when I do something like:

bash-3.00$ perl -e "use VMware::Vix::Simple"

I get no errors.

When I run a program to connect to the host (local host in this case), I get errors like:

-bash-3.00$ perl test1.pl

Connecting to Host Machine...ERROR! 3: One of the parameters was invalid-bash-3.00$

My Program

-


#!/usr/bin/perl

use strict;

use warnings;

use VMware::Vix::Simple;

use VMware::Vix::API::Constants;

my $hostType= VIX_SERVICEPROVIDER_VMWARE_SERVER;

my $hostName= undef;

my $hostPort= undef;

my $userName= undef;

my $password= undef;

my $options = 0;

my $propertyListHandle = VIX_INVALID_HANDLE;

#Host Connect

print "Connecting to Host Machine...";

my ($err, $hostHandle) = HostConnect(VIX_API_VERSION,

$hostType,

$hostName,

$hostPort,

$userName,

$password,

$options,

$propertyListHandle);

if(VIX_OK != $err){

print ("ERROR! $err: " . GetErrorText($err));

exit(1);

}

else {

print "Success!\n";

-


END PROGRAM

I'd really appreciate some help in getting this going! Please let me know if you need more information

Thanks

Rahul

Tags (3)
0 Kudos
7 Replies
lemke
VMware Employee
VMware Employee

For Server 2, you need to change your parameters for HostConnect(). Server 2 needs a different hostType, VIX_SERVICEPROVIDER_VMWARE_VI_SERVER, and also requires a username and password in all cases.

The second post in this thread goes into more detail.

JPatten
Enthusiast
Enthusiast

You will also have to set your hostName variable to the web URL of the SDK, i.e.

This is new in Server 2.0 as well as the new service provider

rahulm
Contributor
Contributor

Thank you for your responses. I tried to modify the relevant code like this:

<snip>

my $hostType= VIX_SERVICEPROVIDER_VMWARE_VI_SERVER;

my $hostName= 'https://myhostip/sdk';

my $hostPort= undef;

my $userName= "user";

my $password= "password";

my $options = 0;

my $propertyListHandle = VIX_INVALID_HANDLE;

</snip>

For the user/password, I also tried root and its password, but still get the same error. Is there anything else I need to do/check?

Thank you very much!

0 Kudos
JPatten
Enthusiast
Enthusiast

I have done most of my VIX programming in C#, so I am basing my response on my connect string from there.

I pass 0 as the host port, where you are passing undef, which I assume is the same as null?

You may want to try passing 0 or 902 (which is the actual port). This is from the VIX guide:

hostPort

TCP/IP port of remote host, typically 902. Use zero for local host.

0 Kudos
lemke
VMware Employee
VMware Employee

The hostName URL probably needs a port in it, since the default isn't 443. Last time I tried, the default was 8333, so [https://myhostip:8333/sdk], but you can specify the port when you install Server.
0 Kudos
rahulm
Contributor
Contributor

Thanks a lot.

I updated the strings like this:

<snip>my $hostType= VIX_SERVICEPROVIDER_VMWARE_VI_SERVER;

my $hostName= 'https://MYIP:8333/sdk';

my $hostPort= 0;

my $userName= "username";

my $password= "password";

my $options = 0;

my $propertyListHandle = VIX_INVALID_HANDLE;

#Host Connect

print "Connecting to Host Machine...";

my ($err, $hostHandle) =

HostConnect(

VIX_API_VERSION,

$hostType,

$hostName,

$hostPort,

$userName,

$password,

$options,

$propertyListHandle);

</snip>

I still keep getting the error that some parameter is invalid. Is there a way to find out which one?

Could it be that some service is not started?

Thanks a lot!

0 Kudos
rahulm
Contributor
Contributor

Hi,

Just wondering if anyone has a solution and/or has tried to get this going on ES4/Linux w/Perl.

Thanks!

0 Kudos