Re: [Users] Fwd: Sample code for setting NIC - CloudInit
Thanks. It worked. On Fri, Feb 21, 2014 at 4:25 PM, Juan Hernandez wrote: > On 02/21/2014 08:13 AM, Tejesh M wrote: > > > > When i try to execute with the ovirt sdk 3.3.3 and do operations on > > RHEV-M 3.3, it fails with below error > > > > This happens because the oVirt SDK is compiled with Java 7, and you are > probably using Java 6. > > I suggest to switch to Java 7, unless there is a very good reason to > stick to Java 6. Java 6 "end of life" was declared by Oracle on Feb 1023. > > However, the OpenJDK community still support Java 6, so if you really > need it please tell us, and we can try to make a version of the oVirt > SDK compatible with Java 6. > > > Exception in thread "main" java.lang.UnsupportedClassVersionError: > > org/ovirt/engine/sdk/Api > > at rhvm.callAPI(rhvm.java:238) > > at rhvm.main(rhvm.java:278) > > > > > > On Fri, Feb 21, 2014 at 12:19 AM, Juan Hernandez > <mailto:jhern...@redhat.com>> wrote: > > > > On 02/20/2014 05:56 PM, Tejesh M wrote: > > > Ok. Will it take long time for that sdk to release? > > > > > > > No, it should be released soon. > > > > Meanwhile you may want to use the latest ovirt 3.3 Java SDK, it is > > almost identical to the RHEV-M Jaa SDK. > > > > If you are using maven these are the coordinates of the artifact: > > > > > > org.ovirt.engine.sdk > > ovirt-engine-sdk-java > > 3.3.3.0 > > > > > > If you aren't using maven you can still download the .jar file from > > here: > > > > > http://search.maven.org/#artifactdetails|org.ovirt.engine.sdk|ovirt-engine-sdk-java|3.3.3.0|jar > > > > > On 20 Feb 2014 04:11, "Moti Asayag" > <mailto:masa...@redhat.com> > > > <mailto:masa...@redhat.com <mailto:masa...@redhat.com>>> wrote: > > > > > > > > > > > > - Original Message - > > > > From: "Tejesh M" > <mailto:tejes...@gmail.com> <mailto:tejes...@gmail.com > > <mailto:tejes...@gmail.com>>> > > > > To: "users@oVirt.org" > <mailto:users@ovirt.org> <mailto:users@ovirt.org > > <mailto:users@ovirt.org>>> > > > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > > > Hi, > > > > > > > > Can someone share me sample java code for assigning IP > > address for > > > VM on eth0 > > > > through Java SDK via CloudInit ? > > > > > > > > > > Hi Tejesh, > > > > > > I've attached a sample code that sends the required request > > (as the > > > output is demonstrated in debug mode). > > > Note that the code is jdk-7 compliant. > > > I haven't configured cloud-init and haven't tested it > end-to-end. > > > Please try to test it on your environment and provide a > > feedback for it. > > > > > > Thanks, > > > Moti > > > > > > > Something Like this but in Java: > > > > > > > > > > > > > > > > eth0 > > > > STATIC > > > > > > > > netmask="255.255.0.0" > > > >gateway="192.168.2.1" /> > > > > > > > > true > > > > > > > > > > > > eth1 > > > > DHCP > > > > > > > > > > > > eth2 > > > > NONE > > > > true > > > > > > > > > > > > > > > > > > > > > > > >1.1.2.2 > > > > > > > > > > > >1.2.3.4 > > > > > > > > > > > > > > > > > > > >qa.lab > > > > > > > > > > > > google.com <http://google.com> > > <http://google.com> > > > > > > > > > > > > > > > > > > > > > > > > > > -- > Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta > 3ºD, 28016 Madrid, Spain > Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L. > -- Thanks & Regards Tejesh ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
On 02/21/2014 08:13 AM, Tejesh M wrote: > > When i try to execute with the ovirt sdk 3.3.3 and do operations on > RHEV-M 3.3, it fails with below error > This happens because the oVirt SDK is compiled with Java 7, and you are probably using Java 6. I suggest to switch to Java 7, unless there is a very good reason to stick to Java 6. Java 6 "end of life" was declared by Oracle on Feb 1023. However, the OpenJDK community still support Java 6, so if you really need it please tell us, and we can try to make a version of the oVirt SDK compatible with Java 6. > Exception in thread "main" java.lang.UnsupportedClassVersionError: > org/ovirt/engine/sdk/Api > at rhvm.callAPI(rhvm.java:238) > at rhvm.main(rhvm.java:278) > > > On Fri, Feb 21, 2014 at 12:19 AM, Juan Hernandez <mailto:jhern...@redhat.com>> wrote: > > On 02/20/2014 05:56 PM, Tejesh M wrote: > > Ok. Will it take long time for that sdk to release? > > > > No, it should be released soon. > > Meanwhile you may want to use the latest ovirt 3.3 Java SDK, it is > almost identical to the RHEV-M Jaa SDK. > > If you are using maven these are the coordinates of the artifact: > > > org.ovirt.engine.sdk > ovirt-engine-sdk-java > 3.3.3.0 > > > If you aren't using maven you can still download the .jar file from > here: > > > http://search.maven.org/#artifactdetails|org.ovirt.engine.sdk|ovirt-engine-sdk-java|3.3.3.0|jar > > > On 20 Feb 2014 04:11, "Moti Asayag" <mailto:masa...@redhat.com> > > <mailto:masa...@redhat.com <mailto:masa...@redhat.com>>> wrote: > > > > > > > > - Original Message - > > > From: "Tejesh M" <mailto:tejes...@gmail.com> <mailto:tejes...@gmail.com > <mailto:tejes...@gmail.com>>> > > > To: "users@oVirt.org" <mailto:users@ovirt.org> <mailto:users@ovirt.org > <mailto:users@ovirt.org>>> > > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > Hi, > > > > > > Can someone share me sample java code for assigning IP > address for > > VM on eth0 > > > through Java SDK via CloudInit ? > > > > > > > Hi Tejesh, > > > > I've attached a sample code that sends the required request > (as the > > output is demonstrated in debug mode). > > Note that the code is jdk-7 compliant. > > I haven't configured cloud-init and haven't tested it end-to-end. > > Please try to test it on your environment and provide a > feedback for it. > > > > Thanks, > > Moti > > > > > Something Like this but in Java: > > > > > > > > > > > > eth0 > > > STATIC > > > > > > > >gateway="192.168.2.1" /> > > > > > > true > > > > > > > > > eth1 > > > DHCP > > > > > > > > > eth2 > > > NONE > > > true > > > > > > > > > > > > > > > > > >1.1.2.2 > > > > > > > > >1.2.3.4 > > > > > > > > > > > > > > >qa.lab > > > > > > > > > google.com <http://google.com> > <http://google.com> > > > > > > > > > > > > > > > > > > -- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L. ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
On 02/20/2014 08:42 PM, Greg Padgett wrote: > On 02/20/2014 02:26 PM, Juan Hernandez wrote: >> On 02/20/2014 04:28 PM, Juan Hernandez wrote: >>> On 02/20/2014 10:40 AM, Tejesh M wrote: >>>> I wrote this code to assign IP address to VM interface eth0, but not >>>> luck. Also, have attached debug log. >>>> >>> >>> I'm attaching a complete examaple of how to do this. However, I think >>> that setting the DNS information doesn't currently work. Apparently >>> cloud-init is expecting a network configuration containing the DNS >>> settings inside the network interface, something like this: >>> >>> iface eth0 inet static >>>dns-nameservers 1.1.2.2 1.2.3.4 >>>dns-search google.com >>>address 192.168.1.102 >>>netmask 255.255.0.0 >>>gateway 192.168.2.1 >>> auto eth0 >>> >>> But we actually pass them outside of the network interface, like this: >>> >>> dns-nameservers 1.1.2.2 1.2.3.4 >>> dns-search google.com >>> iface eth0 inet static >>>address 192.168.1.102 >>>netmask 255.255.0.0 >>>gateway 192.168.2.1 >>> auto eth0 >>> >>> I need to check it. >>> >> >> I have modified the code that generates the cloud-init files to put the >> DNS configuration inside the "iface" configuration, and then it works: >> >> http://gerrit.ovirt.org/24850 >> >> So this is probably a bug, either in our side or in cloud-init itself. >> Greg, Shahar, you know cloud-init better, what do you think? >> I opened the following bug to track it: https://bugzilla.redhat.com/1067906 > > It looks like our bug. Cloud-init wants to see a standard debian/ubuntu > style /etc/network/interfaces, and the documentation for that format > supports your change. Thanks for posting the patch! > >>>> _*Java Code:*_ >>>>org.ovirt.engine.sdk.entities.User userData = new User(); >>>>userData.setUserName("root"); >>>>userData.setPassword(password); >>>>Users usersData = new Users(); >>>>usersData.getUsers().add(userData); >>>>CloudInit cloudData = new CloudInit(); >>>> >>>> >>>>cloudData.setUsers(usersData); >>>>Host hostData = new Host(); >>>>hostData.setAddress(vmName); >>>>cloudData.setHost(hostData); >>>> >>>>org.ovirt.engine.sdk.entities.CloudInit.Network >>>> networkConfiguration=new org.ovirt.engine.sdk.entities.CloudInit.Network(); >>>> >>>>DNS dns = new DNS(); >>>>dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); >>>>dns.setSearchDomains(createServersList("google.com >>>> <http://google.com>")); >>>>networkConfiguration.setDns(dns); >>>>networkConfiguration.setNics(new Nics()); >>>> >>>>Nics nics = networkConfiguration.getNics(); >>>>nics.getNics().add(createNic("eth0", "STATIC", >>>> createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true)); >>>> >>>>networkConfiguration.setNics(nics); >>>> >>>>cloudData.setNetwork(networkConfiguration); >>>> >>>>Initialization initData = new Initialization(); >>>> >>>>initData.setCloudInit(cloudData); >>>> >>>>VM vmDataForStart = new VM(); >>>>vmDataForStart.setInitialization(initData); >>>>Action actionData = new Action(); >>>>actionData.setVm(vmDataForStart); >>>> >>>>// Send the request to start the VM to the server: >>>>api.getVMs().get(vmName).start(actionData); >>>> >>>> >>>> >>>> >>>> >>>> >>>> On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag >>> <mailto:masa...@redhat.com>> wrote: >>>> >>>> >>>> >>>> - Original Message - >>>> > From: "Tejesh M" mailto:tejes...@gmail.com>> >>>> > To: "Moti Asayag" mailto:masa...@redhat.com>
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
When i try to execute with the ovirt sdk 3.3.3 and do operations on RHEV-M 3.3, it fails with below error Exception in thread "main" java.lang.UnsupportedClassVersionError: org/ovirt/engine/sdk/Api at rhvm.callAPI(rhvm.java:238) at rhvm.main(rhvm.java:278) On Fri, Feb 21, 2014 at 12:19 AM, Juan Hernandez wrote: > On 02/20/2014 05:56 PM, Tejesh M wrote: > > Ok. Will it take long time for that sdk to release? > > > > No, it should be released soon. > > Meanwhile you may want to use the latest ovirt 3.3 Java SDK, it is > almost identical to the RHEV-M Jaa SDK. > > If you are using maven these are the coordinates of the artifact: > > > org.ovirt.engine.sdk > ovirt-engine-sdk-java > 3.3.3.0 > > > If you aren't using maven you can still download the .jar file from here: > > > http://search.maven.org/#artifactdetails|org.ovirt.engine.sdk|ovirt-engine-sdk-java|3.3.3.0|jar > > > On 20 Feb 2014 04:11, "Moti Asayag" > <mailto:masa...@redhat.com>> wrote: > > > > > > > > - Original Message - > > > From: "Tejesh M" mailto:tejes...@gmail.com>> > > > To: "users@oVirt.org" mailto:users@ovirt.org>> > > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > Hi, > > > > > > Can someone share me sample java code for assigning IP address for > > VM on eth0 > > > through Java SDK via CloudInit ? > > > > > > > Hi Tejesh, > > > > I've attached a sample code that sends the required request (as the > > output is demonstrated in debug mode). > > Note that the code is jdk-7 compliant. > > I haven't configured cloud-init and haven't tested it end-to-end. > > Please try to test it on your environment and provide a feedback for > it. > > > > Thanks, > > Moti > > > > > Something Like this but in Java: > > > > > > > > > > > > eth0 > > > STATIC > > > > > > > >gateway="192.168.2.1" /> > > > > > > true > > > > > > > > > eth1 > > > DHCP > > > > > > > > > eth2 > > > NONE > > > true > > > > > > > > > > > > > > > > > >1.1.2.2 > > > > > > > > >1.2.3.4 > > > > > > > > > > > > > > >qa.lab > > > > > > > > > google.com <http://google.com> > > > > > > > > > > > > > > > > > > > > > > > > -- > > > Thanks & Regards > > > Tejesh > > > > > > ___ > > > Users mailing list > > > Users@ovirt.org <mailto:Users@ovirt.org> > > > http://lists.ovirt.org/mailman/listinfo/users > > > > > > > > > > > ___ > > Users mailing list > > Users@ovirt.org > > http://lists.ovirt.org/mailman/listinfo/users > > > > > -- > Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta > 3ºD, 28016 Madrid, Spain > Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L. > -- Thanks & Regards Tejesh ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
On 02/20/2014 02:26 PM, Juan Hernandez wrote: On 02/20/2014 04:28 PM, Juan Hernandez wrote: On 02/20/2014 10:40 AM, Tejesh M wrote: I wrote this code to assign IP address to VM interface eth0, but not luck. Also, have attached debug log. I'm attaching a complete examaple of how to do this. However, I think that setting the DNS information doesn't currently work. Apparently cloud-init is expecting a network configuration containing the DNS settings inside the network interface, something like this: iface eth0 inet static dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0 But we actually pass them outside of the network interface, like this: dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com iface eth0 inet static address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0 I need to check it. I have modified the code that generates the cloud-init files to put the DNS configuration inside the "iface" configuration, and then it works: http://gerrit.ovirt.org/24850 So this is probably a bug, either in our side or in cloud-init itself. Greg, Shahar, you know cloud-init better, what do you think? It looks like our bug. Cloud-init wants to see a standard debian/ubuntu style /etc/network/interfaces, and the documentation for that format supports your change. Thanks for posting the patch! _*Java Code:*_ org.ovirt.engine.sdk.entities.User userData = new User(); userData.setUserName("root"); userData.setPassword(password); Users usersData = new Users(); usersData.getUsers().add(userData); CloudInit cloudData = new CloudInit(); cloudData.setUsers(usersData); Host hostData = new Host(); hostData.setAddress(vmName); cloudData.setHost(hostData); org.ovirt.engine.sdk.entities.CloudInit.Network networkConfiguration=new org.ovirt.engine.sdk.entities.CloudInit.Network(); DNS dns = new DNS(); dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); dns.setSearchDomains(createServersList("google.com <http://google.com>")); networkConfiguration.setDns(dns); networkConfiguration.setNics(new Nics()); Nics nics = networkConfiguration.getNics(); nics.getNics().add(createNic("eth0", "STATIC", createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true)); networkConfiguration.setNics(nics); cloudData.setNetwork(networkConfiguration); Initialization initData = new Initialization(); initData.setCloudInit(cloudData); VM vmDataForStart = new VM(); vmDataForStart.setInitialization(initData); Action actionData = new Action(); actionData.setVm(vmDataForStart); // Send the request to start the VM to the server: api.getVMs().get(vmName).start(actionData); On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag mailto:masa...@redhat.com>> wrote: - Original Message - > From: "Tejesh M" mailto:tejes...@gmail.com>> > To: "Moti Asayag" mailto:masa...@redhat.com>> > Cc: "users@oVirt.org" mailto:users@ovirt.org>> > Sent: Thursday, February 20, 2014 8:52:52 AM > Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit > > I'm not getting below class: > > import org.ovirt.engine.sdk.entities.*NetworkConfiguration*; Which version of ovirt-engine-sdk-java are you using ? I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml: org.ovirt.engine.sdk ovirt-engine-sdk-java 3.4.0.1-1 jar compile > > > On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag mailto:masa...@redhat.com>> wrote: > > > > > > > ----- Original Message - > > > From: "Tejesh M" mailto:tejes...@gmail.com>> > > > To: "users@oVirt.org" mailto:users@ovirt.org>> > > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > Hi, > > > > > > Can someone share me sample java code for assigning IP address for VM on > > eth0 > > > through Java SDK via CloudInit ? > > > > > > > Hi Tejesh, > > > > I've attached a sample
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
On 02/20/2014 04:28 PM, Juan Hernandez wrote: > On 02/20/2014 10:40 AM, Tejesh M wrote: >> I wrote this code to assign IP address to VM interface eth0, but not >> luck. Also, have attached debug log. >> > > I'm attaching a complete examaple of how to do this. However, I think > that setting the DNS information doesn't currently work. Apparently > cloud-init is expecting a network configuration containing the DNS > settings inside the network interface, something like this: > > iface eth0 inet static > dns-nameservers 1.1.2.2 1.2.3.4 > dns-search google.com > address 192.168.1.102 > netmask 255.255.0.0 > gateway 192.168.2.1 > auto eth0 > > But we actually pass them outside of the network interface, like this: > > dns-nameservers 1.1.2.2 1.2.3.4 > dns-search google.com > iface eth0 inet static > address 192.168.1.102 > netmask 255.255.0.0 > gateway 192.168.2.1 > auto eth0 > > I need to check it. > I have modified the code that generates the cloud-init files to put the DNS configuration inside the "iface" configuration, and then it works: http://gerrit.ovirt.org/24850 So this is probably a bug, either in our side or in cloud-init itself. Greg, Shahar, you know cloud-init better, what do you think? >> _*Java Code:*_ >> org.ovirt.engine.sdk.entities.User userData = new User(); >> userData.setUserName("root"); >> userData.setPassword(password); >> Users usersData = new Users(); >> usersData.getUsers().add(userData); >> CloudInit cloudData = new CloudInit(); >> >> >> cloudData.setUsers(usersData); >> Host hostData = new Host(); >> hostData.setAddress(vmName); >> cloudData.setHost(hostData); >> >> org.ovirt.engine.sdk.entities.CloudInit.Network >> networkConfiguration=new org.ovirt.engine.sdk.entities.CloudInit.Network(); >> >> DNS dns = new DNS(); >> dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); >> dns.setSearchDomains(createServersList("google.com >> <http://google.com>")); >> networkConfiguration.setDns(dns); >> networkConfiguration.setNics(new Nics()); >> >> Nics nics = networkConfiguration.getNics(); >> nics.getNics().add(createNic("eth0", "STATIC", >> createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true)); >> >> networkConfiguration.setNics(nics); >> >> cloudData.setNetwork(networkConfiguration); >> >> Initialization initData = new Initialization(); >> >> initData.setCloudInit(cloudData); >> >> VM vmDataForStart = new VM(); >> vmDataForStart.setInitialization(initData); >> Action actionData = new Action(); >> actionData.setVm(vmDataForStart); >> >> // Send the request to start the VM to the server: >> api.getVMs().get(vmName).start(actionData); >> >> >> >> >> >> >> On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag > <mailto:masa...@redhat.com>> wrote: >> >> >> >> - Original Message - >> > From: "Tejesh M" mailto:tejes...@gmail.com>> >> > To: "Moti Asayag" mailto:masa...@redhat.com>> >> > Cc: "users@oVirt.org" mailto:users@ovirt.org>> >> > Sent: Thursday, February 20, 2014 8:52:52 AM >> > Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit >> > >> > I'm not getting below class: >> > >> > import org.ovirt.engine.sdk.entities.*NetworkConfiguration*; >> >> Which version of ovirt-engine-sdk-java are you using ? >> >> I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml: >> >> >> org.ovirt.engine.sdk >> ovirt-engine-sdk-java >> 3.4.0.1-1 >> jar >> compile >> >> >> > >> > >> > On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag > <mailto:masa...@redhat.com>> wrote: >> > >> > > >> > > >> > > - Original Message - >>
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
On 02/20/2014 05:56 PM, Tejesh M wrote: > Ok. Will it take long time for that sdk to release? > No, it should be released soon. Meanwhile you may want to use the latest ovirt 3.3 Java SDK, it is almost identical to the RHEV-M Jaa SDK. If you are using maven these are the coordinates of the artifact: org.ovirt.engine.sdk ovirt-engine-sdk-java 3.3.3.0 If you aren't using maven you can still download the .jar file from here: http://search.maven.org/#artifactdetails|org.ovirt.engine.sdk|ovirt-engine-sdk-java|3.3.3.0|jar > On 20 Feb 2014 04:11, "Moti Asayag" <mailto:masa...@redhat.com>> wrote: > > > > - Original Message - > > From: "Tejesh M" mailto:tejes...@gmail.com>> > > To: "users@oVirt.org" mailto:users@ovirt.org>> > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > Hi, > > > > Can someone share me sample java code for assigning IP address for > VM on eth0 > > through Java SDK via CloudInit ? > > > > Hi Tejesh, > > I've attached a sample code that sends the required request (as the > output is demonstrated in debug mode). > Note that the code is jdk-7 compliant. > I haven't configured cloud-init and haven't tested it end-to-end. > Please try to test it on your environment and provide a feedback for it. > > Thanks, > Moti > > > Something Like this but in Java: > > > > > > > > eth0 > > STATIC > > > > >gateway="192.168.2.1" /> > > > > true > > > > > > eth1 > > DHCP > > > > > > eth2 > > NONE > > true > > > > > > > > > > > >1.1.2.2 > > > > > >1.2.3.4 > > > > > > > > > >qa.lab > > > > > > google.com <http://google.com> > > > > > > > > > > > > > > > > -- > > Thanks & Regards > > Tejesh > > > > ___ > > Users mailing list > > Users@ovirt.org <mailto:Users@ovirt.org> > > http://lists.ovirt.org/mailman/listinfo/users > > > > > > ___ > Users mailing list > Users@ovirt.org > http://lists.ovirt.org/mailman/listinfo/users > -- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L. ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
Also, any workaround to assign ip? On 20 Feb 2014 04:11, "Moti Asayag" wrote: > > > - Original Message - > > From: "Tejesh M" > > To: "users@oVirt.org" > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > Hi, > > > > Can someone share me sample java code for assigning IP address for VM on > eth0 > > through Java SDK via CloudInit ? > > > > Hi Tejesh, > > I've attached a sample code that sends the required request (as the output > is demonstrated in debug mode). > Note that the code is jdk-7 compliant. > I haven't configured cloud-init and haven't tested it end-to-end. > Please try to test it on your environment and provide a feedback for it. > > Thanks, > Moti > > > Something Like this but in Java: > > > > > > > > eth0 > > STATIC > > > > >gateway="192.168.2.1" /> > > > > true > > > > > > eth1 > > DHCP > > > > > > eth2 > > NONE > > true > > > > > > > > > > > >1.1.2.2 > > > > > >1.2.3.4 > > > > > > > > > >qa.lab > > > > > > google.com > > > > > > > > > > > > > > > > -- > > Thanks & Regards > > Tejesh > > > > ___ > > Users mailing list > > Users@ovirt.org > > http://lists.ovirt.org/mailman/listinfo/users > > > ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
Ok. Will it take long time for that sdk to release? On 20 Feb 2014 04:11, "Moti Asayag" wrote: > > > - Original Message - > > From: "Tejesh M" > > To: "users@oVirt.org" > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > Hi, > > > > Can someone share me sample java code for assigning IP address for VM on > eth0 > > through Java SDK via CloudInit ? > > > > Hi Tejesh, > > I've attached a sample code that sends the required request (as the output > is demonstrated in debug mode). > Note that the code is jdk-7 compliant. > I haven't configured cloud-init and haven't tested it end-to-end. > Please try to test it on your environment and provide a feedback for it. > > Thanks, > Moti > > > Something Like this but in Java: > > > > > > > > eth0 > > STATIC > > > > >gateway="192.168.2.1" /> > > > > true > > > > > > eth1 > > DHCP > > > > > > eth2 > > NONE > > true > > > > > > > > > > > >1.1.2.2 > > > > > >1.2.3.4 > > > > > > > > > >qa.lab > > > > > > google.com > > > > > > > > > > > > > > > > -- > > Thanks & Regards > > Tejesh > > > > ___ > > Users mailing list > > Users@ovirt.org > > http://lists.ovirt.org/mailman/listinfo/users > > > ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
On 02/20/2014 05:09 PM, Tejesh M wrote: > I'm using rhevm 3.3 java sdk,which doesn't have NetworkConfiguration class. > In that case you will have to use CloudInit.Network. That was an error in that version of the SDK, which will be fixed with the next release. > On 20 Feb 2014 20:58, "Juan Hernandez" <mailto:jhern...@redhat.com>> wrote: > > On 02/20/2014 10:40 AM, Tejesh M wrote: > > I wrote this code to assign IP address to VM interface eth0, but not > > luck. Also, have attached debug log. > > > > I'm attaching a complete examaple of how to do this. However, I think > that setting the DNS information doesn't currently work. Apparently > cloud-init is expecting a network configuration containing the DNS > settings inside the network interface, something like this: > > iface eth0 inet static > dns-nameservers 1.1.2.2 1.2.3.4 > dns-search google.com <http://google.com> > address 192.168.1.102 > netmask 255.255.0.0 > gateway 192.168.2.1 > auto eth0 > > But we actually pass them outside of the network interface, like this: > > dns-nameservers 1.1.2.2 1.2.3.4 > dns-search google.com <http://google.com> > iface eth0 inet static > address 192.168.1.102 > netmask 255.255.0.0 > gateway 192.168.2.1 > auto eth0 > > I need to check it. > > > _*Java Code:*_ > > org.ovirt.engine.sdk.entities.User userData = new User(); > > userData.setUserName("root"); > > userData.setPassword(password); > > Users usersData = new Users(); > > usersData.getUsers().add(userData); > > CloudInit cloudData = new CloudInit(); > > > > > > cloudData.setUsers(usersData); > > Host hostData = new Host(); > > hostData.setAddress(vmName); > > cloudData.setHost(hostData); > > > > org.ovirt.engine.sdk.entities.CloudInit.Network > > networkConfiguration=new > org.ovirt.engine.sdk.entities.CloudInit.Network(); > > > > DNS dns = new DNS(); > > dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); > > dns.setSearchDomains(createServersList("google.com > <http://google.com> > > <http://google.com>")); > > networkConfiguration.setDns(dns); > > networkConfiguration.setNics(new Nics()); > > > > Nics nics = networkConfiguration.getNics(); > > nics.getNics().add(createNic("eth0", "STATIC", > > createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true)); > > > > networkConfiguration.setNics(nics); > > > > cloudData.setNetwork(networkConfiguration); > > > > Initialization initData = new Initialization(); > > > > initData.setCloudInit(cloudData); > > > > VM vmDataForStart = new VM(); > > vmDataForStart.setInitialization(initData); > > Action actionData = new Action(); > > actionData.setVm(vmDataForStart); > > > > // Send the request to start the VM to the server: > > api.getVMs().get(vmName).start(actionData); > > > > > > > > > > > > > > On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag <mailto:masa...@redhat.com> > > <mailto:masa...@redhat.com <mailto:masa...@redhat.com>>> wrote: > > > > > > > > - Original Message - > > > From: "Tejesh M" <mailto:tejes...@gmail.com> <mailto:tejes...@gmail.com > <mailto:tejes...@gmail.com>>> > > > To: "Moti Asayag" <mailto:masa...@redhat.com> <mailto:masa...@redhat.com > <mailto:masa...@redhat.com>>> > > > Cc: "users@oVirt.org" <mailto:users@ovirt.org> <mailto:users@ovirt.org > <mailto:users@ovirt.org>>> > > > Sent: Thursday, February 20, 2014 8:52:52 AM > > > Subject: Re: [Users] Fwd: Sample code for setting NIC - > CloudInit > > > > > > I'm not getting below class: > > > > > > impo
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
I'm using rhevm 3.3 java sdk,which doesn't have NetworkConfiguration class. On 20 Feb 2014 20:58, "Juan Hernandez" wrote: > On 02/20/2014 10:40 AM, Tejesh M wrote: > > I wrote this code to assign IP address to VM interface eth0, but not > > luck. Also, have attached debug log. > > > > I'm attaching a complete examaple of how to do this. However, I think > that setting the DNS information doesn't currently work. Apparently > cloud-init is expecting a network configuration containing the DNS > settings inside the network interface, something like this: > > iface eth0 inet static > dns-nameservers 1.1.2.2 1.2.3.4 > dns-search google.com > address 192.168.1.102 > netmask 255.255.0.0 > gateway 192.168.2.1 > auto eth0 > > But we actually pass them outside of the network interface, like this: > > dns-nameservers 1.1.2.2 1.2.3.4 > dns-search google.com > iface eth0 inet static > address 192.168.1.102 > netmask 255.255.0.0 > gateway 192.168.2.1 > auto eth0 > > I need to check it. > > > _*Java Code:*_ > > org.ovirt.engine.sdk.entities.User userData = new User(); > > userData.setUserName("root"); > > userData.setPassword(password); > > Users usersData = new Users(); > > usersData.getUsers().add(userData); > > CloudInit cloudData = new CloudInit(); > > > > > > cloudData.setUsers(usersData); > > Host hostData = new Host(); > > hostData.setAddress(vmName); > > cloudData.setHost(hostData); > > > > org.ovirt.engine.sdk.entities.CloudInit.Network > > networkConfiguration=new > org.ovirt.engine.sdk.entities.CloudInit.Network(); > > > > DNS dns = new DNS(); > > dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); > > dns.setSearchDomains(createServersList("google.com > > <http://google.com>")); > > networkConfiguration.setDns(dns); > > networkConfiguration.setNics(new Nics()); > > > > Nics nics = networkConfiguration.getNics(); > > nics.getNics().add(createNic("eth0", "STATIC", > > createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true)); > > > > networkConfiguration.setNics(nics); > > > > cloudData.setNetwork(networkConfiguration); > > > > Initialization initData = new Initialization(); > > > > initData.setCloudInit(cloudData); > > > > VM vmDataForStart = new VM(); > > vmDataForStart.setInitialization(initData); > > Action actionData = new Action(); > > actionData.setVm(vmDataForStart); > > > > // Send the request to start the VM to the server: > > api.getVMs().get(vmName).start(actionData); > > > > > > > > > > > > > > On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag > <mailto:masa...@redhat.com>> wrote: > > > > > > > > - Original Message - > > > From: "Tejesh M" mailto:tejes...@gmail.com>> > > > To: "Moti Asayag" mailto:masa...@redhat.com>> > > > Cc: "users@oVirt.org" mailto:users@ovirt.org>> > > > Sent: Thursday, February 20, 2014 8:52:52 AM > > > Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > I'm not getting below class: > > > > > > import org.ovirt.engine.sdk.entities.*NetworkConfiguration*; > > > > Which version of ovirt-engine-sdk-java are you using ? > > > > I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's > pom.xml: > > > > > > org.ovirt.engine.sdk > > ovirt-engine-sdk-java > > 3.4.0.1-1 > > jar > > compile > > > > > > > > > > > > > On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag > <mailto:masa...@redhat.com>> wrote: > > > > > > > > > > > > > > > - Original Message - > > > > > From: "Tejesh M" tejes...@gmail.com>> > > > > > To: "users@oVirt.org" mailto:users@ovirt.org > >> > > > > > Sent:
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
On 02/20/2014 10:40 AM, Tejesh M wrote: > I wrote this code to assign IP address to VM interface eth0, but not > luck. Also, have attached debug log. > I'm attaching a complete examaple of how to do this. However, I think that setting the DNS information doesn't currently work. Apparently cloud-init is expecting a network configuration containing the DNS settings inside the network interface, something like this: iface eth0 inet static dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0 But we actually pass them outside of the network interface, like this: dns-nameservers 1.1.2.2 1.2.3.4 dns-search google.com iface eth0 inet static address 192.168.1.102 netmask 255.255.0.0 gateway 192.168.2.1 auto eth0 I need to check it. > _*Java Code:*_ > org.ovirt.engine.sdk.entities.User userData = new User(); > userData.setUserName("root"); > userData.setPassword(password); > Users usersData = new Users(); > usersData.getUsers().add(userData); > CloudInit cloudData = new CloudInit(); > > > cloudData.setUsers(usersData); > Host hostData = new Host(); > hostData.setAddress(vmName); > cloudData.setHost(hostData); > > org.ovirt.engine.sdk.entities.CloudInit.Network > networkConfiguration=new org.ovirt.engine.sdk.entities.CloudInit.Network(); > > DNS dns = new DNS(); > dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); > dns.setSearchDomains(createServersList("google.com > <http://google.com>")); > networkConfiguration.setDns(dns); > networkConfiguration.setNics(new Nics()); > > Nics nics = networkConfiguration.getNics(); > nics.getNics().add(createNic("eth0", "STATIC", > createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true)); > > networkConfiguration.setNics(nics); > > cloudData.setNetwork(networkConfiguration); > > Initialization initData = new Initialization(); > > initData.setCloudInit(cloudData); > > VM vmDataForStart = new VM(); > vmDataForStart.setInitialization(initData); > Action actionData = new Action(); > actionData.setVm(vmDataForStart); > > // Send the request to start the VM to the server: > api.getVMs().get(vmName).start(actionData); > > > > > > > On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag <mailto:masa...@redhat.com>> wrote: > > > > ----- Original Message - > > From: "Tejesh M" mailto:tejes...@gmail.com>> > > To: "Moti Asayag" mailto:masa...@redhat.com>> > > Cc: "users@oVirt.org" mailto:users@ovirt.org>> > > Sent: Thursday, February 20, 2014 8:52:52 AM > > Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > I'm not getting below class: > > > > import org.ovirt.engine.sdk.entities.*NetworkConfiguration*; > > Which version of ovirt-engine-sdk-java are you using ? > > I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml: > > > org.ovirt.engine.sdk > ovirt-engine-sdk-java > 3.4.0.1-1 > jar > compile > > > > > > > > On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag <mailto:masa...@redhat.com>> wrote: > > > > > > > > > > > - Original Message - > > > > From: "Tejesh M" mailto:tejes...@gmail.com>> > > > > To: "users@oVirt.org" mailto:users@ovirt.org>> > > > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > > > Hi, > > > > > > > > Can someone share me sample java code for assigning IP address > for VM on > > > eth0 > > > > through Java SDK via CloudInit ? > > > > > > > > > > Hi Tejesh, > > > > > > I've attached a sample code that sends the required request (as > the output > > > is demonstrated in
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
I wrote this code to assign IP address to VM interface eth0, but not luck. Also, have attached debug log. *Java Code:* org.ovirt.engine.sdk.entities.User userData = new User(); userData.setUserName("root"); userData.setPassword(password); Users usersData = new Users(); usersData.getUsers().add(userData); CloudInit cloudData = new CloudInit(); cloudData.setUsers(usersData); Host hostData = new Host(); hostData.setAddress(vmName); cloudData.setHost(hostData); org.ovirt.engine.sdk.entities.CloudInit.Network networkConfiguration=new org.ovirt.engine.sdk.entities.CloudInit.Network(); DNS dns = new DNS(); dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); dns.setSearchDomains(createServersList("google.com")); networkConfiguration.setDns(dns); networkConfiguration.setNics(new Nics()); Nics nics = networkConfiguration.getNics(); nics.getNics().add(createNic("eth0", "STATIC", createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true)); networkConfiguration.setNics(nics); cloudData.setNetwork(networkConfiguration); Initialization initData = new Initialization(); initData.setCloudInit(cloudData); VM vmDataForStart = new VM(); vmDataForStart.setInitialization(initData); Action actionData = new Action(); actionData.setVm(vmDataForStart); // Send the request to start the VM to the server: api.getVMs().get(vmName).start(actionData); On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag wrote: > > > - Original Message - > > From: "Tejesh M" > > To: "Moti Asayag" > > Cc: "users@oVirt.org" > > Sent: Thursday, February 20, 2014 8:52:52 AM > > Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > I'm not getting below class: > > > > import org.ovirt.engine.sdk.entities.*NetworkConfiguration*; > > Which version of ovirt-engine-sdk-java are you using ? > > I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml: > > > org.ovirt.engine.sdk > ovirt-engine-sdk-java > 3.4.0.1-1 > jar > compile > > > > > > > > On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag wrote: > > > > > > > > > > > - Original Message - > > > > From: "Tejesh M" > > > > To: "users@oVirt.org" > > > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > > > Hi, > > > > > > > > Can someone share me sample java code for assigning IP address for > VM on > > > eth0 > > > > through Java SDK via CloudInit ? > > > > > > > > > > Hi Tejesh, > > > > > > I've attached a sample code that sends the required request (as the > output > > > is demonstrated in debug mode). > > > Note that the code is jdk-7 compliant. > > > I haven't configured cloud-init and haven't tested it end-to-end. > > > Please try to test it on your environment and provide a feedback for > it. > > > > > > Thanks, > > > Moti > > > > > > > Something Like this but in Java: > > > > > > > > > > > > > > > > eth0 > > > > STATIC > > > > > > > > > > >gateway="192.168.2.1" /> > > > > > > > > true > > > > > > > > > > > > eth1 > > > > DHCP > > > > > > > > > > > > eth2 > > > > NONE > > > > true > > > > > > > > > > > > > > > > > > > > > > > >1.1.2.2 > > > > > > > > > > > >1.2.3.4 > > > > > > > > > > > > > > > > > > > >qa.lab > > > > > > > > > > > > google.com > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > Thanks & Regards > > > > Tejesh > > > > > > > > ___ > > > > Users mailing list > > > > Users@ovirt.org > > > > http://lists.ovirt.org/mailman/listinfo/users > > > > > > > > > > > > > > > -- > > Thanks & Regards > > Tejesh > > > -- Thanks & Regards Tejesh ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
- Original Message - > From: "Tejesh M" > To: "Moti Asayag" > Cc: "users@oVirt.org" > Sent: Thursday, February 20, 2014 8:52:52 AM > Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit > > I'm not getting below class: > > import org.ovirt.engine.sdk.entities.*NetworkConfiguration*; Which version of ovirt-engine-sdk-java are you using ? I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml: org.ovirt.engine.sdk ovirt-engine-sdk-java 3.4.0.1-1 jar compile > > > On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag wrote: > > > > > > > - Original Message - > > > From: "Tejesh M" > > > To: "users@oVirt.org" > > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > > > Hi, > > > > > > Can someone share me sample java code for assigning IP address for VM on > > eth0 > > > through Java SDK via CloudInit ? > > > > > > > Hi Tejesh, > > > > I've attached a sample code that sends the required request (as the output > > is demonstrated in debug mode). > > Note that the code is jdk-7 compliant. > > I haven't configured cloud-init and haven't tested it end-to-end. > > Please try to test it on your environment and provide a feedback for it. > > > > Thanks, > > Moti > > > > > Something Like this but in Java: > > > > > > > > > > > > eth0 > > > STATIC > > > > > > > >gateway="192.168.2.1" /> > > > > > > true > > > > > > > > > eth1 > > > DHCP > > > > > > > > > eth2 > > > NONE > > > true > > > > > > > > > > > > > > > > > >1.1.2.2 > > > > > > > > >1.2.3.4 > > > > > > > > > > > > > > >qa.lab > > > > > > > > > google.com > > > > > > > > > > > > > > > > > > > > > > > > -- > > > Thanks & Regards > > > Tejesh > > > > > > ___ > > > Users mailing list > > > Users@ovirt.org > > > http://lists.ovirt.org/mailman/listinfo/users > > > > > > > > > -- > Thanks & Regards > Tejesh > ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
I'm not getting below class: import org.ovirt.engine.sdk.entities.*NetworkConfiguration*; On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag wrote: > > > - Original Message - > > From: "Tejesh M" > > To: "users@oVirt.org" > > Sent: Wednesday, February 19, 2014 3:24:40 PM > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > > > Hi, > > > > Can someone share me sample java code for assigning IP address for VM on > eth0 > > through Java SDK via CloudInit ? > > > > Hi Tejesh, > > I've attached a sample code that sends the required request (as the output > is demonstrated in debug mode). > Note that the code is jdk-7 compliant. > I haven't configured cloud-init and haven't tested it end-to-end. > Please try to test it on your environment and provide a feedback for it. > > Thanks, > Moti > > > Something Like this but in Java: > > > > > > > > eth0 > > STATIC > > > > >gateway="192.168.2.1" /> > > > > true > > > > > > eth1 > > DHCP > > > > > > eth2 > > NONE > > true > > > > > > > > > > > >1.1.2.2 > > > > > >1.2.3.4 > > > > > > > > > >qa.lab > > > > > > google.com > > > > > > > > > > > > > > > > -- > > Thanks & Regards > > Tejesh > > > > ___ > > Users mailing list > > Users@ovirt.org > > http://lists.ovirt.org/mailman/listinfo/users > > > -- Thanks & Regards Tejesh ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [Users] Fwd: Sample code for setting NIC - CloudInit
- Original Message - > From: "Tejesh M" > To: "users@oVirt.org" > Sent: Wednesday, February 19, 2014 3:24:40 PM > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit > > Hi, > > Can someone share me sample java code for assigning IP address for VM on eth0 > through Java SDK via CloudInit ? > Hi Tejesh, I've attached a sample code that sends the required request (as the output is demonstrated in debug mode). Note that the code is jdk-7 compliant. I haven't configured cloud-init and haven't tested it end-to-end. Please try to test it on your environment and provide a feedback for it. Thanks, Moti > Something Like this but in Java: > > > > eth0 > STATIC > >gateway="192.168.2.1" /> > > true > > > eth1 > DHCP > > > eth2 > NONE > true > > > > > >1.1.2.2 > > >1.2.3.4 > > > > >qa.lab > > > google.com > > > > > > > > -- > Thanks & Regards > Tejesh > > ___ > Users mailing list > Users@ovirt.org > http://lists.ovirt.org/mailman/listinfo/users > package org.ovirt.testday; import java.io.IOException; import java.util.Arrays; import java.util.List; import org.apache.http.client.ClientProtocolException; import org.ovirt.engine.sdk.Api; import org.ovirt.engine.sdk.decorators.VM; import org.ovirt.engine.sdk.entities.Action; import org.ovirt.engine.sdk.entities.CloudInit; import org.ovirt.engine.sdk.entities.DNS; import org.ovirt.engine.sdk.entities.Host; import org.ovirt.engine.sdk.entities.Hosts; import org.ovirt.engine.sdk.entities.IP; import org.ovirt.engine.sdk.entities.Initialization; import org.ovirt.engine.sdk.entities.NIC; import org.ovirt.engine.sdk.entities.Network; import org.ovirt.engine.sdk.entities.NetworkConfiguration; import org.ovirt.engine.sdk.entities.Nics; import org.ovirt.engine.sdk.exceptions.ServerException; import org.ovirt.engine.sdk.exceptions.UnsecuredConnectionAttemptError; /** * Sample non-secured code for sending the following request: * eth0 STATIC true eth1 DHCP eth2 NONE true 1.1.2.2 1.2.3.4 qa.lab google.com * */ public class VmCloudInit { public static void main(String[] args) throws ClientProtocolException, ServerException, UnsecuredConnectionAttemptError, IOException { try (Api api = new Api("http://localhost:8080/api";, "admin@internal", "1", null, null, null, null, null, null, true)){ VM vm = api.getVMs().get("vm1"); NetworkConfiguration networkConfiguration = new NetworkConfiguration(); DNS dns = new DNS(); dns.setServers(createServersList("1.1.2.2", "1.2.3.4")); dns.setSearchDomains(createServersList("qa.lab", "google.com")); networkConfiguration.setDns(dns); networkConfiguration.setNics(new Nics()); List nics = networkConfiguration.getNics().getNics(); nics.add(createNic("eth0", "STATIC", createNetwork("192.168.2.11", "255.255.0.0", "192.168.2.1"), true)); nics.add(createNic("eth1", "DHCP", null, false)); nics.add(createNic("eth1", "NONE", null, true)); vm.setInitialization(new Initialization()); vm.getInitialization().setCloudInit(new CloudInit()); vm.getInitialization().getCloudInit().setNetworkConfiguration(networkConfiguration); Action action = new Action(); action.setVm(vm); vm.start(action); } catch (Exception e) { e.printStackTrace(); } } private static NIC createNic(String name, String bootPro
[Users] Fwd: Sample code for setting NIC - CloudInit
Hi, Can someone share me sample java code for assigning IP address for VM on eth0 through Java SDK via CloudInit ? *Something Like this but in Java:* eth0 STATIC true eth1 DHCP eth2 NONE true 1.1.2.2 1.2.3.4 qa.lab google.com -- Thanks & Regards Tejesh ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users