VMWare Tasks and vCenter Lab Manager 4.0

Apr 8, 2010 at 6:19 PM

Hello,

 I have a question regarding using VMWare Tasks with the vCenter Lab Manager 4.0 platform. I'm trying to implement the sample code found in the help file's

'The following example creates, restores, powers on and removes a snapshot on a remote VMWare ESX host. ' I have a question regarding what server address I should be using in the following call:

 virtualHost.ConnectToVMWareVIServer("ourServer", "username", "password");
 

If I use the domain name contained in my Lab Manager UI URL I get an "Unknown Error" . If I use the Host address found in Lab Manager Configuration UI for this VM (appear to be many esx hosts in this vCenter) I get a "Insufficient permissions in host operating system". Though I am a user of our site’s Lab Manager UI I am not any Lab Manager administrator.

 For us to use VMWareTasks in our environment, what address should I be connecting to given the number of Hosts and Resource Pools available? I’m trying to get enough information to find out if we can use VMWareTasks for test automation on our vCenter Lab Manager platform or if we will need to use some other avenue to automate the OS guests inside our virtual machines. I’m hoping we can use VMWareTasks.  Thank you for your help!

Coordinator
Apr 8, 2010 at 9:15 PM

It should be the same thing as what you type in the VI (Virtual Infrastructure) client, for example esx.mydomain.com or 192.168.1.23. Sounds like the second attempt, ie. when you use the host address found in Lab Manager Configuration UI is the correct one and you're facing an "insufficient permissions in host operating system" error. That's because your username/password aren't correct or the ESX host isn't liking it. Those are the username and password to the host, not to the guest! Once connected to the host you can do all kinds of things, such as opening a virtual machine, booting it and logging in to it with other credentials.

Apr 9, 2010 at 5:39 PM
Edited Apr 9, 2010 at 6:19 PM

Thanks for your response. Your answer got me looking into the VI Client for V 4.0 and V 3.0. I now have access to a standalone ESX server (VMware ESX Server Version 3.5.0, Build 123630) where I can investigate VMWareTasks. Once I get traction on this ESX server I can then try and hit the ESX 4.0 servers in our vCenter.

 I am now able to connect to the ESX server but am now throwing an exception when executing the following line:

             using (VMWareVirtualMachine virtualMachine = virtualHost.Open("[storage]myDirectory/myTemplate.vmx"))
                {
                    // power on this virtual machine

 The excpeption is below:

Vestris.VMWareLib.VMWareException was unhandled
  Message="The virtual machine cannot be found"
  Source="Vestris.VMWareLib"
  ErrorCode=4000
  StackTrace:
       at Vestris.VMWareLib.VMWareInterop.Check(UInt64 errCode)
       at Vestris.VMWareLib.VMWareJob.Wait[T](Object[] properties)
       at Vestris.VMWareLib.VMWareJob.Wait[T](Object[] properties, Int32 index, Int32 timeoutInSeconds)
       at Vestris.VMWareLib.VMWareJob.Wait[T](Int32 propertyId, Int32 timeoutInSeconds)
       at Vestris.VMWareLib.VMWareVirtualHost.Open(String fileName, Int32 timeoutInSeconds)
       at Vestris.VMWareLib.VMWareVirtualHost.Open(String fileName)

 I can see in my VMware Infrastructure Client that at the moment I executed the above line the 'Recent Tasks' updated with 'Find Virtual Machine By Datastore Path' with a status of a green 'Completed'.

 I'm using the latest Vestris.VMWareLib. Whether the vm in question is powered up already or powered down I still get the error. It seems as though we're not able to handle the response from this command.

 Any ideas?

 As an update, the Version of the guest OS is Windows Server 2003, Enterprise Edition (64bit) and the ESX Server is running Linux. I'm running this test app from an x86 XP box.

 Thanks!

Apr 9, 2010 at 6:36 PM

I found my immediate issue. I should have had a space after the right bracket after storage and before the 'my' in myDirectory.

virtualHost.Open("[storage]myDirectory/myTemplate.vmx")

should be

virtualHost.Open("[storage] myDirectory/myTemplate.vmx").

I was able to launch Notepad.exe!