[Users] [rhevm-api] Need help to Start and Stop VM using Java SDK
Itamar Heim
iheim at redhat.com
Tue Feb 11 15:16:48 UTC 2014
On 02/11/2014 04:55 PM, Tejesh M wrote:
> Thanks for your fast response.
>
> But intelli sense is not listing vm.*start *function
>
> I'm using rhevm-sdk-java-1.0.0.29-1.jar
>
> _*code:*_
>
> import org.ovirt.engine.sdk.Api;
> import org.ovirt.engine.sdk.common.*;
> import org.ovirt.engine.sdk.decorators.VMDisk;
> import org.ovirt.engine.sdk.entities.*;
> import org.apache.commons.beanutils.*;
>
>
> public class rhvm {
> static Api api;
> public static void callAPI()
> {
> try{
>
> api = new Api("https://rhevm:443/api", "admin at internal",
> "password");
>
>
> org.ovirt.engine.sdk.entities.VM vm =
> api.getVMs().get("testVM3"); //get VM
> vm.setDescription("java_sdk");
>
> System.out.print("VM ID:" + vm.getStatus().getState());
> System.out.print("VM ID:" + vm.getId());
>
>
> }
> catch(Exception e)
> {
> System.out.print(e);
> }
> finally {
> api.shutdown();
> }
> }
> public static void main(String a[]) throws Exception
> {
> //rhvm obj = new rhvm();
> callAPI();
> System.out.println("\ncompleted");
> }
> }
>
>
>
>
> On Tue, Feb 11, 2014 at 8:08 PM, Ewoud Kohl van Wijngaarden
> <ewoud+rhevm-api at kohlvanwijngaarden.nl
> <mailto:ewoud+rhevm-api at kohlvanwijngaarden.nl>> wrote:
>
> On Tue, Feb 11, 2014 at 08:00:57PM +0530, Tejesh M wrote:
> > Can anyone share sample on how to Start & Stop VM using Java SDK? I
> > couldn't find any document on JAVA SDK for RHEVM.
>
> While this list hasn't been in use for some time, I hope I can still
> point you
> in the right direction. http://www.ovirt.org/Java-sdk#Examples has the
> following examples:
>
> // -- Create proxy
>
> // #1 - import
> import org.ovirt.engine.sdk.Api;
>
> // #2 - create proxy
> Api api = new Api("http://localhost:8080/api", "user at domain",
> "password");
>
> // -- perform an action on resource
>
> // #1 - fetch resource
> VM vm = api.getVMs().get("test");
>
> // #2 - create params + perform an action
> Action res = vm.start(new Action() {
> {
> setVm(new org.ovirt.engine.sdk.entities.VM());
> }
> });
>
> I'd guess vm.stop is exactly the same as vm.start.
> _______________________________________________
> rhevm-api mailing list
> rhevm-api at lists.fedorahosted.org
> <mailto:rhevm-api at lists.fedorahosted.org>
> https://lists.fedorahosted.org/mailman/listinfo/rhevm-api
>
>
>
>
> --
> Thanks & Regards
> Tejesh
>
>
> _______________________________________________
> rhevm-api mailing list
> rhevm-api at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/rhevm-api
>
moving to users at ovirt.org...
thanks,
Itamar
More information about the Users
mailing list