<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(&quot;root&quot;);<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(&quot;1.1.2.2&quot;, &quot;1.2.3.4&quot;));<br>          dns.setSearchDomains(createServersList(&quot;<a href="http://google.com">google.com</a>&quot;));<br>
          networkConfiguration.setDns(dns);<br>          networkConfiguration.setNics(new Nics());<br>          <br>          Nics nics = networkConfiguration.getNics();<br>          nics.getNics().add(createNic(&quot;eth0&quot;, &quot;STATIC&quot;, createNetwork(&quot;192.168.1.102&quot;, &quot;255.255.0.0&quot;, &quot;192.168.2.1&quot;), 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">&lt;<a href="mailto:masayag@redhat.com" target="_blank">masayag@redhat.com</a>&gt;</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>
&gt; From: &quot;Tejesh M&quot; &lt;<a href="mailto:tejeshmk@gmail.com">tejeshmk@gmail.com</a>&gt;<br>
&gt; To: &quot;Moti Asayag&quot; &lt;<a href="mailto:masayag@redhat.com">masayag@redhat.com</a>&gt;<br>
&gt; Cc: &quot;users@oVirt.org&quot; &lt;<a href="mailto:users@ovirt.org">users@ovirt.org</a>&gt;<br>
&gt; Sent: Thursday, February 20, 2014 8:52:52 AM<br>
&gt; Subject: Re: [Users] Fwd: Sample code for setting NIC - CloudInit<br>
&gt;<br>
&gt; I&#39;m not getting below class:<br>
&gt;<br>
&gt; 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&#39;s pom.xml:<br>
<br>
        &lt;dependency&gt;<br>
                &lt;groupId&gt;org.ovirt.engine.sdk&lt;/groupId&gt;<br>
                &lt;artifactId&gt;ovirt-engine-sdk-java&lt;/artifactId&gt;<br>
                &lt;version&gt;3.4.0.1-1&lt;/version&gt;<br>
                &lt;type&gt;jar&lt;/type&gt;<br>
                &lt;scope&gt;compile&lt;/scope&gt;<br>
        &lt;/dependency&gt;<br>
<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Feb 20, 2014 at 4:11 AM, Moti Asayag &lt;<a href="mailto:masayag@redhat.com">masayag@redhat.com</a>&gt; wrote:<br>
&gt;<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; ----- Original Message -----<br>
&gt; &gt; &gt; From: &quot;Tejesh M&quot; &lt;<a href="mailto:tejeshmk@gmail.com">tejeshmk@gmail.com</a>&gt;<br>
&gt; &gt; &gt; To: &quot;users@oVirt.org&quot; &lt;<a href="mailto:users@ovirt.org">users@ovirt.org</a>&gt;<br>
&gt; &gt; &gt; Sent: Wednesday, February 19, 2014 3:24:40 PM<br>
&gt; &gt; &gt; Subject: [Users] Fwd: Sample code for setting NIC - CloudInit<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Hi,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; Can someone share me sample java code for assigning IP address for VM on<br>
&gt; &gt; eth0<br>
&gt; &gt; &gt; through Java SDK via CloudInit ?<br>
&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt; Hi Tejesh,<br>
&gt; &gt;<br>
&gt; &gt; I&#39;ve attached a sample code that sends the required request (as the output<br>
&gt; &gt; is demonstrated in debug mode).<br>
&gt; &gt; Note that the code is jdk-7 compliant.<br>
&gt; &gt; I haven&#39;t configured cloud-init and haven&#39;t tested it end-to-end.<br>
&gt; &gt; Please try to test it on your environment and provide a feedback for it.<br>
&gt; &gt;<br>
&gt; &gt; Thanks,<br>
&gt; &gt; Moti<br>
&gt; &gt;<br>
&gt; &gt; &gt; Something Like this but in Java:<br>
&gt; &gt; &gt; &lt;network_configuration&gt;<br>
&gt; &gt; &gt;          &lt;nics&gt;<br>
&gt; &gt; &gt;            &lt;nic&gt;<br>
&gt; &gt; &gt;              &lt;name&gt;eth0&lt;/name&gt;<br>
&gt; &gt; &gt;              &lt;boot_protocol&gt;STATIC&lt;/boot_protocol&gt;<br>
&gt; &gt; &gt;              &lt;network&gt;<br>
&gt; &gt; &gt;                &lt;ip address=&quot;192.168.2.11&quot; netmask=&quot;255.255.0.0&quot;<br>
&gt; &gt; &gt;                gateway=&quot;192.168.2.1&quot; /&gt;<br>
&gt; &gt; &gt;              &lt;/network&gt;<br>
&gt; &gt; &gt;              &lt;on_boot&gt;true&lt;/on_boot&gt;<br>
&gt; &gt; &gt;            &lt;/nic&gt;<br>
&gt; &gt; &gt;            &lt;nic&gt;<br>
&gt; &gt; &gt;              &lt;name&gt;eth1&lt;/name&gt;<br>
&gt; &gt; &gt;              &lt;boot_protocol&gt;DHCP&lt;/boot_protocol&gt;<br>
&gt; &gt; &gt;            &lt;/nic&gt;<br>
&gt; &gt; &gt;            &lt;nic&gt;<br>
&gt; &gt; &gt;              &lt;name&gt;eth2&lt;/name&gt;<br>
&gt; &gt; &gt;              &lt;boot_protocol&gt;NONE&lt;/boot_protocol&gt;<br>
&gt; &gt; &gt;              &lt;on_boot&gt;true&lt;/on_boot&gt;<br>
&gt; &gt; &gt;            &lt;/nic&gt;<br>
&gt; &gt; &gt;          &lt;/nics&gt;<br>
&gt; &gt; &gt;          &lt;dns&gt;<br>
&gt; &gt; &gt;            &lt;servers&gt;<br>
&gt; &gt; &gt;              &lt;host&gt;<br>
&gt; &gt; &gt;                &lt;address&gt;1.1.2.2&lt;/address&gt;<br>
&gt; &gt; &gt;              &lt;/host&gt;<br>
&gt; &gt; &gt;              &lt;host&gt;<br>
&gt; &gt; &gt;                &lt;address&gt;1.2.3.4&lt;/address&gt;<br>
&gt; &gt; &gt;              &lt;/host&gt;<br>
&gt; &gt; &gt;            &lt;/servers&gt;<br>
&gt; &gt; &gt;            &lt;search_domains&gt;<br>
&gt; &gt; &gt;              &lt;host&gt;<br>
&gt; &gt; &gt;                &lt;address&gt;qa.lab&lt;/address&gt;<br>
&gt; &gt; &gt;              &lt;/host&gt;<br>
&gt; &gt; &gt;              &lt;host&gt;<br>
&gt; &gt; &gt;                &lt;address&gt; <a href="http://google.com" target="_blank">google.com</a> &lt;/address&gt;<br>
&gt; &gt; &gt;              &lt;/host&gt;<br>
&gt; &gt; &gt;            &lt;/search_domains&gt;<br>
&gt; &gt; &gt;          &lt;/dns&gt;<br>
&gt; &gt; &gt;        &lt;/network_configuration&gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; --<br>
&gt; &gt; &gt; Thanks &amp; Regards<br>
&gt; &gt; &gt; Tejesh<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; _______________________________________________<br>
&gt; &gt; &gt; Users mailing list<br>
&gt; &gt; &gt; <a href="mailto:Users@ovirt.org">Users@ovirt.org</a><br>
&gt; &gt; &gt; <a href="http://lists.ovirt.org/mailman/listinfo/users" target="_blank">http://lists.ovirt.org/mailman/listinfo/users</a><br>
&gt; &gt; &gt;<br>
&gt; &gt;<br>
&gt;<br>
&gt;<br>
<span class="HOEnZb"><font color="#888888">&gt;<br>
&gt; --<br>
&gt; Thanks &amp; Regards<br>
&gt; Tejesh<br>
&gt;<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div>Thanks &amp; Regards</div>
<div>Tejesh</div>
</div>