VIX API executes actions on other machine

Jan 6, 2011 at 8:53 PM

I've run into a problem using this API. I'm using VMWare Server, and I've created two machine from scratch. Then I automated some tasks on the two machines.

 

The problem that is happening is that when the second machine starts the actions aren't executed, but if I shutdown the first machine and run the automated tasks then they are well executed.

The IP's and MAC address are diferent on the two machines, and this problem only happens with this two machines, what could it be?

 

Coordinator
Jan 6, 2011 at 9:01 PM

What do you mean by "not executed"?

Jan 7, 2011 at 9:50 AM

Basically when the two Machines are power commands like:

· virtualMachine.RunProgramInGuest(C:\Windows\System32\cmd.exe, c:\CreateDatabase.Bat, 0, 1900);

do not appear on the task manager and are the actions on the .bat file are not executed, but if I close one of the machines the actions on the .bat file are executed correctly and in this sample the database is created.

This only happens on these two machines and when they are power on simultaneous.

Miguel Marques

Test Lead

Innovation in New Technologies

Technology – PRIMAVERA Software Factory
Tel / Phone + 351 253 309 900 | Fax +351 253 309 909
www.primaverabss.com

PBSS

DISCLAIMER: This message is confidential and intended exclusively for the addressee. If you received this message by mistake please inform the sender and delete the message and attachments. No confidentiality nor any privilege regarding the information is waived or lost by any mistransmission.

Coordinator
Jan 7, 2011 at 12:01 PM

Is there an exception thrown? What does the function return? What's the code written in and what versions of VixCOM and VMWareTasks are used?

Jan 7, 2011 at 6:14 PM

Is there an exception thrown?

No the program just executes and do nothing.

What does the function return?

VMWareVirtualMachine.Process process = virtualMachine.RunProgramInGuest(programname, commandLineArgs, 0, timeout);

The process.ExitCode returns 1 when the two virtual machines are power on, and returns 0 when just one of the machines is power on.

What's the code written in and what versions of VixCOM and VMWareTasks are used?

VixCOM is 1.8

Vestris.VMWareLib: 1.4.34376.0

From: dblock [email removed]
Sent: sexta-feira, 7 de Janeiro de 2011 13:02
To: Miguel Marques
Subject: Re: VIX API executes actions on other machine [vmwaretasks:240761]

From: dblock

Is there an exception thrown? What does the function return? What's the code written in and what versions of VixCOM and VMWareTasks are used?

DISCLAIMER: This message is confidential and intended exclusively for the addressee. If you received this message by mistake please inform the sender and delete the message and attachments. No confidentiality nor any privilege regarding the information is waived or lost by any mistransmission.

Coordinator
Jan 10, 2011 at 2:14 PM

So looks like the process actually executes, but returns 1 (otherwise you'd get an exception). At least that's what VMWare VixCOM API is telling you. Let's believe it and change the call to execute something trivial with an explicit return statement first (eg. cmd.exe /C dir & exit /b 0). See if it does work - in which case there's a problem with the thing you're executing.

If the trivial example still fails, the next thing I'd try is to stick a lock around the execute call and see if it matters. If not, I would upgrade VixCOM to 1.10 and then give up. VixCOM is known to be fully buggy for multithreaded executions and they continued fixing bugs release after release. So I'd re-raise this question on VixCOM forum as the problem with the trivial example persists.

Jan 13, 2011 at 5:53 PM

After some tests I verified that this line of codes

if (hostType == VirtualMachineHostType.HostType.VMWareVIServer)

{

// Chek is virtual machine exist.

if(!virtualHost.RegisteredVirtualMachines.Any<VMWareVirtualMachine>(v => v.PathName == virtualMachineNode.SelectSingleNode("name").InnerText))

{

throw new Exception(String.Format("Virtual machine: {0} not found!", virtualMachineNode.SelectSingleNode("name").InnerText));

}

}

Where always sending the message that the machine not exists (even when existed on the VMWare Server), because the registered machines increased a lot (this was my guest because the number increased from 8 to 30 machines registered). But if I commented the above lines the application found the machine and worked just fine.

This was a bug that I found on the RegisteredVirtualMachines method, but for my surprise and against all odds the other bug disapeared. This means that this RegisteredVirtualMachines method had a bug that somewhat was influencing these two machines!!!!

Is it a little strange but what I stated is that now is working.

DISCLAIMER: This message is confidential and intended exclusively for the addressee. If you received this message by mistake please inform the sender and delete the message and attachments. No confidentiality nor any privilege regarding the information is waived or lost by any mistransmission.

Coordinator
Jan 14, 2011 at 4:21 AM

This smells bad. I think you're having a garbage collection problem. So sometimes your GC disposes of something (failure) and sometimes it doesn't have time (success). In VMWareTasks we took great care to make sure that everything that holds native handles is IDisposable - so when you have one of those (eg. VMWareVirtualMachine), wrap it in using( ... ) { }. I doubt that you can just do RegisteredVirtualMachines.Any<>like this - break it up.