<div dir="ltr"><div>I wrote this code to assign IP address to VM interface eth0, but not luck. Also, have attached debug log.<br><br></div><u><b>Java Code:</b></u><br>��� ��� � org.ovirt.engine.sdk.entities.User userData = new User();<br>
��� ��� � userData.setUserName("root");<br>��� ��� � userData.setPassword(password);<br>��� ��� � Users usersData = new Users();<br>��� ��� � usersData.getUsers().add(userData);<br>��� ��� � CloudInit cloudData = new CloudInit();<br>
��� ��� � <br>��� ��� � <br>��� ��� � cloudData.setUsers(usersData);<br>��� ��� � Host hostData = new Host();<br>��� ��� � hostData.setAddress(vmName);<br>��� ��� � cloudData.setHost(hostData);<br><br>��� ��� � org.ovirt.engine.sdk.entities.CloudInit.Network networkConfiguration=new org.ovirt.engine.sdk.entities.CloudInit.Network();<br>
��� <br>��������� DNS dns = new DNS();<br>��������� dns.setServers(createServersList("1.1.2.2", "1.2.3.4"));<br>��������� dns.setSearchDomains(createServersList("<a href="http://google.com">google.com</a>"));<br>
��������� networkConfiguration.setDns(dns);<br>��������� networkConfiguration.setNics(new Nics());<br>��������� <br>��������� Nics nics = networkConfiguration.getNics();<br>��� ��� � nics.getNics().add(createNic("eth0", "STATIC", createNetwork("192.168.1.102", "255.255.0.0", "192.168.2.1"), true));<br>
��������� ��� ��� � <br>��� ��� � networkConfiguration.setNics(nics);<br>��� ��� � <br>��� ��� � cloudData.setNetwork(networkConfiguration);<br>��� ��� � <br>��� ��� � Initialization initData = new Initialization();<br>��� ��� � <br>
��� ��� � initData.setCloudInit(cloudData);<br>��� ��� � <br>��� ��� � VM vmDataForStart = new VM();<br>��� ��� � vmDataForStart.setInitialization(initData);<br>��� ��� � Action actionData = new Action();<br>��� ��� � actionData.setVm(vmDataForStart);<br>
<br>��� ��� � // Send the request to start the VM to the server:<br>��� ��� � api.getVMs().get(vmName).start(actionData);<br><br><br><br><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 20, 2014 at 1:39 PM, Moti Asayag <span dir="ltr"><<a href="mailto:masayag@redhat.com" target="_blank">masayag@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
----- Original Message -----<br>
> From: "Tejesh M" <<a href="mailto:tejeshmk@gmail.com">tejeshmk@gmail.com</a>><br>
> To: "Moti Asayag" <<a href="mailto:masayag@redhat.com">masayag@redhat.com</a>><br>
> Cc: "users@oVirt.org" <<a href="mailto:users@ovirt.org">users@ovirt.org</a>><br>
> Sent: Thursday, February 20, 2014 8:52:52 AM<br>
> Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit<br>
><br>
> I'm not getting below class:<br>
><br>
> import org.ovirt.engine.sdk.entities.*NetworkConfiguration*;<br>
<br>
Which version of ovirt-engine-sdk-java are you using ?<br>
<br>
I used ovirt-engine-sdk-java-3.4.0.1-1, added to my project's pom.xml:<br>
<br>
� � � � <dependency><br>
� � � � � � � � <groupId>org.ovirt.engine.sdk</groupId><br>
� � � � � � � � <artifactId>ovirt-engine-sdk-java</artifactId><br>
� � � � � � � � <version>3.4.0.1-1</version><br>
� � � � � � � � <type>jar</type><br>
� � � � � � � � <scope>compile</scope><br>
� � � � </dependency><br>
<br>
><br>
><br>
> On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag <<a href="mailto:masayag@redhat.com">masayag@redhat.com</a>> wrote:<br>
><br>
> ><br>
> ><br>
> > ----- Original Message -----<br>
> > > From: "Tejesh M" <<a href="mailto:tejeshmk@gmail.com">tejeshmk@gmail.com</a>><br>
> > > To: "users@oVirt.org" <<a href="mailto:users@ovirt.org">users@ovirt.org</a>><br>
> > > Sent: Wednesday, February 19, 2014 3:24:40 PM<br>
> > > Subject: [Users] Fwd: Sample code for setting NIC - CloudInit<br>
> > ><br>
> > > Hi,<br>
> > ><br>
> > > Can someone share me sample java code for assigning IP address for VM on<br>
> > eth0<br>
> > > through Java SDK via CloudInit ?<br>
> > ><br>
> ><br>
> > Hi Tejesh,<br>
> ><br>
> > I've attached a sample code that sends the required request (as the output<br>
> > is demonstrated in debug mode).<br>
> > Note that the code is jdk-7 compliant.<br>
> > I haven't configured cloud-init and haven't tested it end-to-end.<br>
> > Please try to test it on your environment and provide a feedback for it.<br>
> ><br>
> > Thanks,<br>
> > Moti<br>
> ><br>
> > > Something Like this but in Java:<br>
> > > <network_configuration><br>
> > > � � � � �<nics><br>
> > > � � � � � �<nic><br>
> > > � � � � � � �<name>eth0</name><br>
> > > � � � � � � �<boot_protocol>STATIC</boot_protocol><br>
> > > � � � � � � �<network><br>
> > > � � � � � � � �<ip address="192.168.2.11" netmask="255.255.0.0"<br>
> > > � � � � � � � �gateway="192.168.2.1" /><br>
> > > � � � � � � �</network><br>
> > > � � � � � � �<on_boot>true</on_boot><br>
> > > � � � � � �</nic><br>
> > > � � � � � �<nic><br>
> > > � � � � � � �<name>eth1</name><br>
> > > � � � � � � �<boot_protocol>DHCP</boot_protocol><br>
> > > � � � � � �</nic><br>
> > > � � � � � �<nic><br>
> > > � � � � � � �<name>eth2</name><br>
> > > � � � � � � �<boot_protocol>NONE</boot_protocol><br>
> > > � � � � � � �<on_boot>true</on_boot><br>
> > > � � � � � �</nic><br>
> > > � � � � �</nics><br>
> > > � � � � �<dns><br>
> > > � � � � � �<servers><br>
> > > � � � � � � �<host><br>
> > > � � � � � � � �<address>1.1.2.2</address><br>
> > > � � � � � � �</host><br>
> > > � � � � � � �<host><br>
> > > � � � � � � � �<address>1.2.3.4</address><br>
> > > � � � � � � �</host><br>
> > > � � � � � �</servers><br>
> > > � � � � � �<search_domains><br>
> > > � � � � � � �<host><br>
> > > � � � � � � � �<address>qa.lab</address><br>
> > > � � � � � � �</host><br>
> > > � � � � � � �<host><br>
> > > � � � � � � � �<address> <a href="http://google.com" target="_blank">google.com</a> </address><br>
> > > � � � � � � �</host><br>
> > > � � � � � �</search_domains><br>
> > > � � � � �</dns><br>
> > > � � � �</network_configuration><br>
> > ><br>
> > ><br>
> > ><br>
> > > --<br>
> > > Thanks & Regards<br>
> > > Tejesh<br>
> > ><br>
> > > _______________________________________________<br>
> > > Users mailing list<br>
> > > <a href="mailto:Users@ovirt.org">Users@ovirt.org</a><br>
> > > <a href="http://lists.ovirt.org/mailman/listinfo/users" target="_blank">http://lists.ovirt.org/mailman/listinfo/users</a><br>
> > ><br>
> ><br>
><br>
><br>
<span class="HOEnZb"><font color="#888888">><br>
> --<br>
> Thanks & Regards<br>
> Tejesh<br>
><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div>Thanks & Regards</div>
<div>Tejesh</div>
</div>