2.7. Performing Actions on Resources
The following example outlines how to perform actions on a resource. In this example, a virtual machine with the name 'test' is started.
Procedure 2.3. Performing an Action on a Resource
- Declare an instance of the resource:
VM vm = api.getVMs().get("test");
- Declare action parameters to send to the resource:
Action actionParam = new Action(); org.ovirt.engine.sdk.entities.VM vmParam = new org.ovirt.engine.sdk.entities.VM(); actionParam.setVm(vmParam);
- Perform the action:
Action res = vm.start(actionParam);
Alternatively, you can perform the action as an inner method:
Action res = vm.start(new Action() { { setVm(new org.ovirt.engine.sdk.entities.VM()); } });