<div dir="ltr"><div><div>Hi All,<br><br></div>I&#39;m facing an issue in invoking Cloudinit while customization in RHEV 3.6 using RHEV Java SDK 3.6.<br><br>Below link says we need to explicitly call <b>use_cloud_init=True</b>, but i&#39;m not sure how to pass this value as parameter while creating VM.<br><br><a href="http://users.ovirt.narkive.com/BGUkanAk/ovirt-users-cloud-init-not-apply-when-v-create-from-api">http://users.ovirt.narkive.com/BGUkanAk/ovirt-users-cloud-init-not-apply-when-v-create-from-api</a><br clear="all"><div><div><br><br></div><div><u><b>My Code:</b></u><br>String password = &quot;password&quot;; //&quot;password&quot;<br><br>String templateName = &quot;centos6.7-final&quot;;<br>String clusterName = &quot;Default&quot;;<br>String vmName = &quot;testVM3&quot;;<br><br>//Prepare the data to create the VM from the template:<br>org.ovirt.engine.sdk.entities.Template templateData = new Template();<br>templateData.setName(templateName);<br>org.ovirt.engine.sdk.entities.Cluster clusterData = new Cluster();<br>clusterData.setName(clusterName);<br>org.ovirt.engine.sdk.entities.VM vmDataForCreate = new VM();<br>vmDataForCreate.setName(vmName);<br>vmDataForCreate.setCluster(clusterData);<br>vmDataForCreate.setTemplate(templateData);<br><br>api.getVMs().add(vmDataForCreate);<br>String state;<br>for (;;) {<br> state = api.getVMs().get(vmName).getStatus().getState();<br>if (&quot;down&quot;.equals(state)) {<br>  break;<br>}<br>Thread.sleep(1000);<br>}<br>System.out.println(&quot;System Status:&quot;+state);  <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.NetworkConfiguration networkConfiguration=new NetworkConfiguration();<br><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.setNetworkConfiguration(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><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></div>-- <br><div><div class="gmail_signature" data-smartmail="gmail_signature"><div>Thanks &amp; Regards</div>
<div>Tejesh</div></div>
</div></div></div></div>