My problem is I can create a snapshot but I don't have a VirtualMachineSnapshot object in order to Remove the snapshot.
Here is how I'm setup:
\- I'm using C# in Visual Studio
\- I have installed the sdk in '[b]vi-sdk-2.0.1-32042.zip[/b]' and have gotten all the DotNet samples working.
\- I'm using the VimService proxy class provided through the sdk to communicate with the webservice.
\- I have been able to successfully start a snapshot task using using VimService.CreateSnapshot_TaskAsync().
\- I then receive the callback from the webservice that the snapshot was successfully created.
But, according to the documentation I should get a VirtualMachineSnapshot from the webservice callback when the snapshot has been successfully created. What I get back is a ManagedObjectReference with a type of 'Task' and a value of the task id. I tried to use this 'Task' ManagedObjectReference to Remove the snapshot but it fails.
I assumed I would get back a ManagedObjectReference with a type of 'VirtualMachineSnaptshot' and it's corresponding id.
Is there a way to get the VirtualMachineSnapshot using the webservice? Am I missing something?
Here is the documentation that you should look at http://pubs.vmware.com/vi301/sdk/ReferenceGuide/vim.VirtualMachine.html#createSnapshot.
CreateSnapshot returns a task object (a moref). When the task is completed, then the task.info.result will give you the ManagedObjectReference of the snapshot that was created.
H
That was the documentation that I was referring to above. It says that I should have access to the task.result which has the VirtualMachineSnapshot but that's not the case in the webservice. All I get is the Task object.
I was able to get the VirtualMachineSnapshot object by using the RetrieveProperties method. I specified 'VirtualMachine' in the ObjectSpec and snapshot.currentSnapshot in the PropertySpec.
Once I got the VirtualMachineSnapshot ManagedObjectReference object I could call the RemoveSnapshot_TaskAsync() method.
Success!!!!
The call to the function returns a ManagedObjectReference to a Task object. You need to retrieve the TaskInfo property of the Task, and check on it's sub-properties. Once Task.info.state goes to a value of success, Task.info.result willl contain a ManagedObjectReference to the VirtualMachineSnapshot.
I'm doing this via the web service and it works fine. You'd better make sure your create snapshot task has finished before you try to access the snapshot - if Virtual Center was extremely busy your task could be queued for an indeterminate amount of time.
That's not what I'm seeing. If I call CreateSnapshot_Task() synchronously then the return value is a ManagedObjectReference object with type of 'Task' but it can not cast to a Task object. This may be because the library that I created from the wsdl in the sdk did not have a Task object defined.
I get the same result asynchonously using the CreateSnapshot_TaskAsync() method and wiring into the CreateSnapshot_TaskCompleted event for the response from the webservice. When I get a successful response in the above event the CreateSnapshot_TaskCompletedEventArgs.Result contains a ManagedObjectReference with a type = 'Task' and cannot be cast to anything else.
Like I said above my library does not have a Task object or a VirtualMachineSnapshot object defined in it. Neither object was specified in the wsdl. Is there a newer version out there? Looking at the zip file, which the SDK came in, it looks like my version is '2.0.1-32042'.
Hi Jay,
I am facing the same problem. My library also does not have Task Object :-(. My intension is to get the details of the snapshot that I have created using CreateSnapshot_Task(). Can anyone help me out ??
Thanks in Advance,
Mani
Hi Jay and Ram,
Have a look at this thread
http://communities.vmware.com/message/889636#889636
Hope this helps.