Hi there
Using Workstation 6.5 with VixCom 1.6.1.4558.
I am using the VixCom API via C# to automate a single VM as part of a larger Windows based automated testing framework.
The basic process involves powering on a VM, waiting for it to power up, waiting for VM tools to load and then waiting for an application to launch via the startup menu.
When the VM is shutdown (from inside it NOT using the VixCom but using something similar to PSShutdown), I then wait for it to power down, pause 5 seconds, and then power it back on again and this is repeated.
At different stages of the power on process, I poll for the current state using the following code snippet:-
========
UInt64 error = 0;
VixLibClass m_VixComlib = new VixLibClass();
error = ((VixCOM.IVixHandle)VirtualMachine).GetProperties(properyIDs, ref properties);
if (m_VixComlib.ErrorIndicatesFailure(error))
{
Console.writeline( "Failed to retrieve the properties of the VM");
return -1;
}
vmPowerState = (int)((object[])properties)[0]; // VixCOM.Constants.VIX_PROPERTY_VM_POWER_STATE
vmPathName = (string)((object[])properties)[1]; // VixCOM.Constants.VIX_PROPERTY_VM_VMX_PATHNAME
========
Now, during the VM power on stage, vmPowerState returns either 1032 or 1096 and I am unable to determine what power state the VM is in. Its clearly not one of the known states defined
in Vix.h but I am aware of the fact that it could be a combination of a few states but I have been unable to determine what these are.
Any help with this will be greatly appreciated.
AutoTestGuru.
I know AutoTestGuy in real life, and had a quick look into this.
The constants are bitmasks:
VIX_POWERSTATE_POWERING_OFF | 0000000001 |
VIX_POWERSTATE_POWERED_OFF | 0000000010 |
VIX_POWERSTATE_POWERING_ON | 0000000100 |
VIX_POWERSTATE_POWERED_ON | 0000001000 |
VIX_POWERSTATE_SUSPENDING | 0000010000 |
VIX_POWERSTATE_SUSPENDED | 0000100000 |
VIX_POWERSTATE_TOOLS_RUNNING | 0001000000 |
VIX_POWERSTATE_RESETTING | 0010000000 |
VIX_POWERSTATE_BLOCKED_ON_MSG | 0100000000 |
VIX_POWERSTATE_PAUSED | 1000000000 |
VIX_POWERSTATE_RESUMING | 100000000000 |
You're getting 1032 and 1096 which are:
10000001000 | VIX_POWERSTATE_POWERED_ON |
10001001000 | VIX_POWERSTATE_POWERED_ON + VIX_POWERSTATE_TOOLS_RUNNING |
But theres another bit on (1024) which isn't explained by the constants. I'd be interested to know what that actually means.
In any case try AND the value you get back with the constant you'd like to check and make sure that matches your original constant.
I know AutoTestGuy in real life, and had a quick look into this.
The constants are bitmasks:
VIX_POWERSTATE_POWERING_OFF | 0000000001 |
VIX_POWERSTATE_POWERED_OFF | 0000000010 |
VIX_POWERSTATE_POWERING_ON | 0000000100 |
VIX_POWERSTATE_POWERED_ON | 0000001000 |
VIX_POWERSTATE_SUSPENDING | 0000010000 |
VIX_POWERSTATE_SUSPENDED | 0000100000 |
VIX_POWERSTATE_TOOLS_RUNNING | 0001000000 |
VIX_POWERSTATE_RESETTING | 0010000000 |
VIX_POWERSTATE_BLOCKED_ON_MSG | 0100000000 |
VIX_POWERSTATE_PAUSED | 1000000000 |
VIX_POWERSTATE_RESUMING | 100000000000 |
You're getting 1032 and 1096 which are:
10000001000 | VIX_POWERSTATE_POWERED_ON |
10001001000 | VIX_POWERSTATE_POWERED_ON + VIX_POWERSTATE_TOOLS_RUNNING |
But theres another bit on (1024) which isn't explained by the constants. I'd be interested to know what that actually means.
In any case try AND the value you get back with the constant you'd like to check and make sure that matches your original constant.
Quick C# example - powerState is the return value from GetProperty:
int powerState = 1032;
if ((powerState & VixCOM.Constants.VIX_POWERSTATE_POWERED_ON) == VixCOM.Constants.VIX_POWERSTATE_POWERED_ON)
{
Console.WriteLine("Powered on");
}
else
{
Console.WriteLine("Not powered on");
}
if ((powerState & VixCOM.Constants.VIX_POWERSTATE_TOOLS_RUNNING) == VixCOM.Constants.VIX_POWERSTATE_TOOLS_RUNNING)
{
Console.WriteLine("Tools running");
}
else
{
Console.WriteLine("Tools not running");
}
Cheers Gaz