VMware {code} Community
kuegahd
Contributor
Contributor
Jump to solution

vix using esx

Can you guys help me with my code. It stops at HostConnect:

use VMware::Vix::Simple;
use VMware::Vix::API::Constants;
my $err = VIX_OK;
my $hostHandle = VIX_INVALID_HANDLE;
my $vmHandle = VIX_INVALID_HANDLE;
my $CONNTYPE = "VIX_SERVICEPROVIDER_VMWARE_VI_SERVER";
my $HOSTPORT = 0;
my $USERNAME = "root";
my $PASSWORD = "123456";
my $vmxPath = "[datastore1] windowsxp\\windowsxp.vmx";
($err, $hostHandle) = HostConnect(VIX_API_VERSION,
                                  $CONNTYPE,
                                  $HOSTNAME, #hostName
                                  $HOSTPORT, # hostPort
                                  $USERNAME, # username
                                  $PASSWORD, #password
                                  0, #options
                                  VIX_INVALID_HANDLE); # propertyListHandle
die "HostConnect() failed, $err ", GetErrorText($err), "\n" if $err = !VIX_OK;
($err, $vmHandle) = VMOpen($hostHandle,
                           $vmxPath);
die "VMOpen()failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;
$err = VMPowerOn($vmHandle,
                 VIX_VMPOWEROP_LAUNCH_GUI, # powerOnOptions
                 VIX_INVALID_HANDLE); # propertyListHandle
die "VMPowerOn() failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;

Error says:

Failed to get property type for 3010 on handle 16799219

Reply
0 Kudos
1 Solution

Accepted Solutions
stanguturi
VMware Employee
VMware Employee
Jump to solution

> my $CONNTYPE = "VIX_SERVICEPROVIDER_VMWARE_VI_SERVER";

VIX_SERVICEPROVIDER_VMWARE_VI_SERVER is a constant. Please don't specify that inside the double quotes. Use the following code:

my $CONNTYPE = VIX_SERVICEPROVIDER_VMWARE_VI_SERVER;

Please take a look at sample perl files available in vix-perl bundle.

vix-perl/
- samples/findhosttest.pl
- samples/powertest.pl
- samples/vmrun.pl

-Thanks
Sankar.

View solution in original post

Reply
0 Kudos
6 Replies
admin
Immortal
Immortal
Jump to solution

I think the error is that the port number you have specified in the URL is not usually used by ESX. Normally, ESX uses the default HTTPS port, which is 443. So, you could just supply the URL as

my $HOSTNAME = "https://192.1.1.101/sdk";

Port 8333 is the defaul port for VMware Server 2.0.

I'm surprised the error your getting is so unclear, but I think that is the root cause of the issue.

Reply
0 Kudos
stanguturi
VMware Employee
VMware Employee
Jump to solution

Which version of VIX are you using?

Reply
0 Kudos
kuegahd
Contributor
Contributor
Jump to solution

tried removing the port and still generating the same error

Reply
0 Kudos
kuegahd
Contributor
Contributor
Jump to solution

im using vix 1.10.1

Reply
0 Kudos
stanguturi
VMware Employee
VMware Employee
Jump to solution

> my $CONNTYPE = "VIX_SERVICEPROVIDER_VMWARE_VI_SERVER";

VIX_SERVICEPROVIDER_VMWARE_VI_SERVER is a constant. Please don't specify that inside the double quotes. Use the following code:

my $CONNTYPE = VIX_SERVICEPROVIDER_VMWARE_VI_SERVER;

Please take a look at sample perl files available in vix-perl bundle.

vix-perl/
- samples/findhosttest.pl
- samples/powertest.pl
- samples/vmrun.pl

-Thanks
Sankar.

Reply
0 Kudos
kuegahd
Contributor
Contributor
Jump to solution

thanks stan, that solved the problem

Reply
0 Kudos