Name

HostConnect

Description

($err, $hostHandle) = HostConnect($apiVersion,
                                  $hostType,
                                  $hostName,
                                  $hostPort,
                                  $userName,
                                  $password,
                                  $options,
                                  $propertyListHandle);

Creates a host handle. This handle cannot be shared or reused after disconnect.

Parameters

apiVersion
Must be VIX_API_VERSION.
hostType
With vCenter Server, ESX/ESXi hosts, and VMware Server 2.0, use VIX_SERVICEPROVIDER_VMWARE_VI_SERVER. With VMware Workstation, use VIX_SERVICEPROVIDER_VMWARE_WORKSTATION. With VMware Workstation (shared mode), use VIX_SERVICEPROVIDER_VMWARE_WORKSTATION_SHARED. With VMware Player, use VIX_SERVICEPROVIDER_VMWARE_PLAYER. With VMware Server 1.0.x, use VIX_SERVICEPROVIDER_VMWARE_SERVER.
hostName
Varies by product platform. With vCenter Server, ESX/ESXi hosts, VMware Workstation (shared mode) and VMware Server 2.0, use a URL of the form "https://<hostName>:<port>/sdk" where <hostName> is either the DNS name or IP address. If missing, <port> may default to 443 (see Remarks below). In VIX API 1.10 and later, you can omit "https://" and "/sdk" specifying just the DNS name or IP address. Credentials are required even for connections made locally. With Workstation, use undef to connect to the local host. With VMware Server 1.0.x, use the DNS name or IP address for remote connections, or the same as Workstation for local connections.
hostPort
TCP/IP port on the remote host. With VMware Workstation and VMware Player, use zero for the local host. With ESX/ESXi hosts, VMware Workstation (shared mode) and VMware Server 2.0 you specify port number within the hostName parameter, so this parameter is ignored (see Remarks below).
login
Username for authentication on the remote machine. With VMware Workstation, VMware Player, and VMware Server 1.0.x, use undef to authenticate as the current user on local host. With vCenter Server, ESX/ESXi hosts, VMware Workstation (shared mode) and VMware Server 2.0, you must use a valid login.
password
Password for authentication on the remote machine. With VMware Workstation, VMware Player, and VMware Server 1.0.x, use undef to authenticate as the current user on local host. With ESX/ESXi, VMware Workstation (shared mode) and VMware Server 2.0, you must use a valid login.
options
must be 0.
propertyListHandle
Must be VIX_INVALID_HANDLE.

Return Value

$err. The error code returned by the operation. For returned values, see Topics > Error Codes.

$hostHandle. A handle to host.

Remarks

Side Effects

None.

Requirements

use VMware::Vix::Simple;
use VMware::Vix::API::Constants;
since VMware Server 1.0

Example

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

my $err = VIX_OK;
my $hostHandle = VIX_INVALID_HANDLE;

($err, $hostHandle) = HostConnect(VIX_API_VERSION,
                                  VIX_SERVICEPROVIDER_VMWARE_VI_SERVER,
                                  "https://viserver/sdk", # hostName
                                  0, # hostPort
                                  "root", # userName
                                  "rootpasswd", # password
                                  0, # options
                                  VIX_INVALID_HANDLE); # propertyListHandle

die "HostConnect() failed, $err ", GetErrorText($err), "\n" if $err != VIX_OK;
# ...Do everything in your program...
HostDisconnect($hostHandle);

Copyright (C) 2007-2017 VMware, Inc. All rights reserved.