Hi, all.
I'd like to get vm information when VM's events are occured.
I wrote a test code using WaitForUpdatesEx (vSphere 5.0) method.
When I ran this, I got the following error:
"com.vmware.vim25.InvalidRequest
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at java.lang.Class.newInstance0(Class.java:355)
at java.lang.Class.newInstance(Class.java:308)
at com.vmware.vim25.ws.XmlGen.fromXml(XmlGen.java:201)
at com.vmware.vim25.ws.XmlGen.parseSoapFault(XmlGen.java:80)
at com.vmware.vim25.ws.WSClient.invoke(WSClient.java:132)
at com.vmware.vim25.ws.VimStub.waitForUpdatesEx(VimStub.java:105)
at com.vmware.vim25.mo.PropertyCollector.waitForUpdatesEx(PropertyCollector.java:125)
at com.apexcns.test.AsyncPropsCollection.test(AsyncPropsCollection.java:170)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
if ( update != null && update.getFilterSet() != null ) {
.......
version = update.getVersion();
} else {
logger.debug("No update is present!");
}
}
.....
Please let me know if anyting is wrong in my code.
Thank you.
Yeonki.
Hi Yeonki,
I have not tried to run your code but the InvalidRequest Fault is likely to be a pointer to a malformed SOAP XML body. Now looking at your code the following line:
eventFilter.setType( new String[] {"VmPoweredOffEvent", "VmPoweredOnEvent", "VmSuspendedEvent", "VmResettingEvent"} );
catches my eye as property EventFilterSpec.type has been deprecated. As of vSphere API 4.0 the docs suggest using property EventFilterSpec.eventTypeId instead.
As you indicate you are running against vSphere 5.0 this might be the reason why the server rejects the request.
Could you please change the above line to
eventFilter.setEventTypeId( new String[] {"VmPoweredOffEvent", "VmPoweredOnEvent", "VmSuspendedEvent", "VmResettingEvent"} );
and let me know whether this cures the problem ...
Hi, Thomas
Thanks for the reponse.
I got the same error (InvalidRequest) after I changed code like you intructed.
eventFilter.setType( new String[] {"VmPoweredOffEvent", "VmPoweredOnEvent", "VmSuspendedEvent", "VmResettingEvent"} );
eventFilter.setEventTypeId( new String[] {"VmPoweredOffEvent", "VmPoweredOnEvent", "VmSuspendedEvent", "VmResettingEvent"} );
But, when I invoked waitforUpdates intead, my code worked and it returned proper result whenever VM's power state is changed.
This is worked code after I changed some parts.
............
The point is that I use VimPortType.waitForUpdates, not ProprortyCollector.waitForUpdates.
VimPortType.waitForUpdates is not marked as deprecated.
Although its compile & run works fine, Can I say that this is safe code or not?
Yeonki.