After your Web application has initialized the VMRC browser plug-in, you can use the connect() method to connect to a remote host and access a particular virtual machine on that host. To use the
connect() method, you must have the following information.
You pass different parameters to the connect() method depending on how you choose to provide the required host identification, authentication, and virtual machine identification.
Parameter List for VMRC connect() Method shows the parameters for the
connect() method.
The connect() method does not return a value. If the connection is successful, the VMRC browser plug-in generates an
onConnectionStateChange event. See
Handling VMRC Events.
Note When using VMRC with vCloud Director, only the host,
ticket, and
vmid parameters are supported when calling
connect(). You must pass
false for the
allowSSLErrors parameter, and empty strings (““) for all other parameters in
connect().
The following is an example of how to call connect() when using VMRC with vCloud Director.
You must provide a form of authentication when using the connect() method. This authentication can be a VIM session ticket, or a
username and
password pair on the remote host. The authentication methods are exclusive, meaning that if you use the parameters for one method, such as a session ticket, you must omit the parameters for the other and pass them as empty strings.
The following is an example of how to call connect(), by using a VIM session ticket as the authentication method. Note that the
username,
password, and SSL
thumbprint parameters are passed as empty strings.
If you authenticate using a username and
password pair, you must provide the SSL
thumbprint to the
connect() method in the
sslThumbprint parameter.
The following is an example of how to call connect(), by using a
username and
password as the authentication method. The ticket parameter is passed as an empty string.
You must provide a way to identify the target virtual machine when using the connect() method. The virtual machine can be identified by a virtual machine ID that you obtain from an active VIM session on your Web application server, or a datacenter name and datastore path to a particular virtual machine.
The two methods of identifying the virtual machine are exclusive. If you use a virtual machine ID, you must pass that value by using the vmid parameter when calling
connect(), and omit any values for
datacenter and
vmpath. Conversely, you must omit the
vmid if you use values for
datacenter and
vmpath when calling
connect().
The following example shows how to call connect() by using the virtual machine ID to identify the target virtual machine.
The following is an example of how to call connect() using the datacenter name and vmpath to identify the target virtual machine.