VIX API

 View Only
  • 1.  Connecting to remote host via VIXCOM API

    Posted Aug 19, 2008 06:54 PM

    Trying to connect to remote host running VMware server v1.04 running on Windows 2003 SP and job.Wait doesn't seem to return any values, there for Set host = results(0) throws a general VBScript mismatch error message during runtime. Using the same script against local installation of VMWare Workstation v6.03 works just fine. Any help on will be greatly appreciated. Below is VBScript.

    Dim lib, job

    Dim strUserName

    Dim strPassword

    Dim strHostName

    Dim host

    Dim vm

    Dim results

    Set lib = CreateObject("VixCOM.VixLib")

    strHostName = "MyHostValue"

    strUserName = "MyUserAccountValue"

    +*strP

    ' Connect to host

    Set job = lib.Connect(VixCOM.Constants.VIX_API_VERSION, VixCOM.Constants.VIX_SERVICEPROVIDER_VMWARE_SERVER, strHostName, 902, strUserName, strPassword, 0, Nothing, Nothing)

    ' results needs to be initialized before it's used, even if it's just going to be overwritten.

    Set results = Nothing

    Err = job.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE), results)

    'QuitIfError(err)

    ' The job result handle will be first element in the results array.

    Set host = results(0)

    ' Open the virtual machine with the given .vmx file.

    'Set job = host.OpenVM("D:\VM_Images\VMXP01EN\Windows XP Professional.vmx", Nothing) THis is for VMWare Server

    Set job = host.OpenVM("V:\VmImages\eDWinXP\WindowsXPProfessional.vmx", Nothing)

    err = job.Wait(Array(VixCOM.Constants.VIX_PROPERTY_JOB_RESULT_HANDLE), results)

    'QuitIfError(err)

    Set vm = results(0)

    ' Power on the virtual machine we just opened. This will launch Workstation if it hasn't

    ' already been started.

    Set job = vm.PowerOn(VixCOM.Constants.VIX_VMPOWEROP_LAUNCH_GUI, Nothing, Nothing)

    +' WaitWithoutResults is just like Wait, except it does not get any properties. +

    err = job.WaitWithoutResults()

    'QuitIfError(err)

    Set vm = results(0)

    err = vm.GetRootSnapshot(0, snapshot)

    If lib.ErrorIndicatesFailure(err) Then

    * ' Handle error...*

    End If

    Set job = vm.RevertToSnapshot(snapshot, 0, Nothing, Nothing)

    err = job.WaitWithoutResults()

    host.Disconnect()



  • 2.  RE: Connecting to remote host via VIXCOM API

    Posted Aug 19, 2008 08:49 PM

    The host name parameter should be "https://" & strHostName & ":902/sdk".



  • 3.  RE: Connecting to remote host via VIXCOM API

    Posted Aug 20, 2008 02:07 PM

    Still no luck on this. It also fails when I run this locally on the host w/o passing hostname/username/password parameteres.

    When I use the same script agains Workstation 6.03 it works fine, the only problem is I can not control it remotely.



  • 4.  RE: Connecting to remote host via VIXCOM API

    Posted Aug 20, 2008 06:02 PM

    That is only true for Server 2.0. When using Server 1.0, use just the hostname.



  • 5.  RE: Connecting to remote host via VIXCOM API
    Best Answer

    Posted Aug 20, 2008 06:03 PM

    Try passing 1 (the numeric value, not a string) as the first argument to lib.Connect().

    Server 1.0 only supports an API version of 1.



  • 6.  RE: Connecting to remote host via VIXCOM API

    Posted Aug 21, 2008 03:01 PM

    It did the trick, passing "1" as the first argument to lib.Connect. Thanks a lot for your help, didn't see in any of the documentation, oh well!! Thanks again!