<p dir="ltr">Actually, i want to automate the vm provisioning through java sdk. and this urgent requirement. Is it possible to automate setting hostname, root password n nic info by any means in 3.3? Also in windows administration password as similar to linux.. kindly help as im new to this..</p>
<div class="gmail_quote">On 13 Feb 2014 20:32, "Juan Hernandez" <<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 02/13/2014 03:59 PM, Shahar Havivi wrote:<br>
> On 13.02.14 20:17, Tejesh M wrote:<br>
>> 1. The Version is RHEV-M 3.3 & Cloud-init is<br>
>> cloud-init-0.6.3-0.12.bzr532.el6.noarch<br>
>><br>
>> 2. In Webadmin, i don't find any option to set Cloud-init data's. I checked<br>
>> under New VM->Initial Run.. Am i looking at the right place?<br>
>> How to enable cloud-init support in engine?<br>
> You will not found it since you are working in 3.3 and this feature presented<br>
> in 3.4.<br>
> In 3.3 you can try to set the Cloud-Init via the Run-Once button.<br>
><br>
<br>
In 3.3 you need first to create the VM. Once it is created select it,<br>
click the "Run Once" button, then click on the plus sign next to<br>
"Initial Run", check the "Cloud-Init" box, and populate the fields you want.<br>
<br>
>><br>
>> I have installed cloud-init package in RHEV-M & also in Template.<br>
>><br>
>> Please suggest.<br>
>><br>
>><br>
>> On Thu, Feb 13, 2014 at 7:31 PM, Juan Hernandez <<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>> wrote:<br>
>><br>
>>> On 02/13/2014 02:39 PM, Tejesh M wrote:<br>
>>>> Hi All,<br>
>>>><br>
>>>> Thanks alot.<br>
>>>><br>
>>>> I have created one VM with minimal installation & installed cloud-init<br>
>>>> package. And, converted that VM into Template. Then executed the code<br>
>>>> given in<br>
>>>> <a href="http://lists.ovirt.org/pipermail/users/2014-February/021302.html" target="_blank">http://lists.ovirt.org/pipermail/users/2014-February/021302.html</a> , but<br>
>>>> no luck, the code is not setting root password.<br>
>>>><br>
>>><br>
>>> What version of the engine are you running? I may not have the required<br>
>>> cloud-init support.<br>
>>><br>
>>> Try to run the application in debug mode:<br>
>>><br>
>>> Api api = new Api(<br>
>>> "<a href="https://whatever/api" target="_blank">https://whatever/api</a>",<br>
>>> "user@domain",<br>
>>> "password",<br>
>>> null,<br>
>>> null,<br>
>>> null,<br>
>>> null,<br>
>>> true,<br>
>>> null,<br>
>>> true // <- This is to enable debug mode<br>
>>> );<br>
>>><br>
>>> It will send to the log the actual XML documents sent to the server. We<br>
>>> can use it to see if the request is generated correctly.<br>
>>><br>
>>> It may also happen that cloud-init support isn't working correctly. To<br>
>>> verify this try to use the cloud-init support manually from webadmin.<br>
>>> Does it work from there?<br>
>>><br>
>>>> Also, there is no option to set *Hostname *for the VM.<br>
>>>><br>
>>><br>
>>> To set the host name you need to add something like this:<br>
>>><br>
>>> Host hostData = new Host();<br>
>>> hostData.setAddress("<a href="http://the.host.name" target="_blank">the.host.name</a>");<br>
>>> cloudData.setHost(hostData);<br>
>>><br>
>>>><br>
>>>><br>
>>>> _*Code:*_<br>
>>>><br>
>>>> /*********************Begin Customize VM*********************/<br>
>>>> // Generate the random password, using whatever mechanism you<br>
>>>> // prefer:<br>
>>>> String password = "cJql3P9XLQG4drCYVG/6Q/";<br>
>>>><br>
>>>> // You need to know the name of the template, the cluster and<br>
>>>> // the VM you are going to create:<br>
>>>> String templateName = "rhel2_temp";<br>
>>>> String clusterName = "testCluster";<br>
>>>> String vmName = "myvm";<br>
>>>><br>
>>>> // Prepare the data to create the VM from the template:<br>
>>>> org.ovirt.engine.sdk.entities.Template templateData = new<br>
>>>> Template();<br>
>>>> templateData.setName(templateName);<br>
>>>> org.ovirt.engine.sdk.entities.Cluster clusterData = new<br>
>>> 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>
>>>> // Send the request to create the VM to the server:<br>
>>>> api.getVMs().add(vmDataForCreate);<br>
>>>> String state;<br>
>>>> // White till the VM is down (it will be locked for a while):<br>
>>>> for (;;) {<br>
>>>> state = api.getVMs().get(vmName).getStatus().getState();<br>
>>>> if ("down".equals(state)) {<br>
>>>> break;<br>
>>>> }<br>
>>>> Thread.sleep(1000);<br>
>>>> }<br>
>>>> System.out.println("System Status:"+state);<br>
>>>> // Populate parameters for the action to start the VM with<br>
>>>> cloud-init:<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>
>>>> cloudData.setUsers(usersData);<br>
>>>><br>
>>>> Initialization initData = new Initialization();<br>
>>>> initData.setCloudInit(cloudData);<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>
>>>> System.out.println("After :<br>
>>>> "+api.getVMs().get(vmName).getStatus());<br>
>>>> /*********************End Customize VM*********************/<br>
>>>><br>
>>>><br>
>>>><br>
>>>> Thanks & Regards,<br>
>>>> Tejesh<br>
>>>><br>
>>>><br>
>>>><br>
>>>> On Thu, Feb 13, 2014 at 2:26 PM, Juan Hernandez <<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a><br>
>>>> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>>> wrote:<br>
>>>><br>
>>>> On 02/13/2014 09:29 AM, Shahar Havivi wrote:<br>
>>>> > On 13.02.14 00:59, Oved Ourfalli wrote:<br>
>>>> >><br>
>>>> >><br>
>>>> >> ----- Original Message -----<br>
>>>> >>> From: "Shahar Havivi" <<a href="mailto:shaharh@redhat.com">shaharh@redhat.com</a><br>
>>>> <mailto:<a href="mailto:shaharh@redhat.com">shaharh@redhat.com</a>>><br>
>>>> >>> To: <a href="mailto:users@ovirt.org">users@ovirt.org</a> <mailto:<a href="mailto:users@ovirt.org">users@ovirt.org</a>><br>
>>>> >>> Cc: "Juan Antonio Hernandez Fernandez" <<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a><br>
>>>> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>>>, <a href="mailto:rhevm-api@lists.fedorahosted.org">rhevm-api@lists.fedorahosted.org</a><br>
>>>> <mailto:<a href="mailto:rhevm-api@lists.fedorahosted.org">rhevm-api@lists.fedorahosted.org</a>>, "Tejesh M"<br>
>>>> >>> <<a href="mailto:tejeshmk@gmail.com">tejeshmk@gmail.com</a> <mailto:<a href="mailto:tejeshmk@gmail.com">tejeshmk@gmail.com</a>>><br>
>>>> >>> Sent: Wednesday, February 12, 2014 11:22:20 PM<br>
>>>> >>> Subject: Re: [Users] [rhevm-api] Assign IP address to VM using<br>
>>>> Java SDK<br>
>>>> >>><br>
>>>> >>> On 12.02.14 22:55, Itamar Heim wrote:<br>
>>>> >>>> On 02/12/2014 03:14 PM, Tejesh M wrote:<br>
>>>> >>>>> Hi,<br>
>>>> >>>>><br>
>>>> >>>>> Can anyone share sample code on how to assign IP address to<br>
>>>> guest os &<br>
>>>> >>>>> changing the root password while creating VM from Template<br>
>>>> using Java SDK?<br>
>>>> >>> Hi Tejesh,<br>
>>>> >>> You should start here:<br>
>>>> >>> <a href="http://www.ovirt.org/Api" target="_blank">http://www.ovirt.org/Api</a><br>
>>>> >>> This link will explain the basics for fetching VM via the API<br>
>>>> using HTTP via<br>
>>>> >>> curl command line.<br>
>>>> >>><br>
>>>> >>> Every VM have a collection of networks and manipulating them can<br>
>>>> be seeing<br>
>>>> >>> here with the REST API examples:<br>
>>>> >>> <a href="http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST" target="_blank">http://www.ovirt.org/Features/Design/Network/SetupNetworks#REST</a><br>
>>>> >>> the section for you is "Attaching a network to a NIC" under the<br>
>>> REST<br>
>>>> >>> category.<br>
>>>> >>><br>
>>>> >>> Shahar Havivi.<br>
>>>> >>><br>
>>>> >><br>
>>>> >> Actually it looks like Tejesh is referring to the Guests and not<br>
>>>> the hosts, so you can use cloud-init in order to do that.<br>
>>>> >> See more in "<a href="http://www.ovirt.org/Features/Cloud-Init_Integration" target="_blank">http://www.ovirt.org/Features/Cloud-Init_Integration</a><br>
>>> ".<br>
>>>> >> If the VM's operating system is defined as some kind of Linux,<br>
>>>> then you'll be able to set some stuff using cloud-init, either via<br>
>>>> the Run-Once Dialog, or in the regular VM properties dialog.<br>
>>>> >><br>
>>>> >> Omer - we have REST API support for cloud-init, right?<br>
>>>> > Yes, more on that can be found here:<br>
>>>> > <a href="http://www.ovirt.org/Features/vm-init-persistent" target="_blank">http://www.ovirt.org/Features/vm-init-persistent</a><br>
>>>> >><br>
>>>><br>
>>>> Tajesh, you have a detailed example of how to set the password in the<br>
>>>> following message:<br>
>>>><br>
>>>> <a href="http://lists.ovirt.org/pipermail/users/2014-February/021302.html" target="_blank">http://lists.ovirt.org/pipermail/users/2014-February/021302.html</a><br>
>>>><br>
>>>> Setting the IP address is similar.<br>
>>>><br>
>>><br>
>>> --<br>
>>> Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta<br>
>>> 3ºD, 28016 Madrid, Spain<br>
>>> Inscrita en el Reg. Mercantil de Madrid - C.I.F. B82657941 - Red Hat S.L.<br>
>>><br>
>><br>
>><br>
>><br>
>> --<br>
>> Thanks & Regards<br>
>> Tejesh<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>
Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta<br>
3ºD, 28016 Madrid, Spain<br>
Inscrita en el Reg. Mercantil de Madrid – C.I.F. B82657941 - Red Hat S.L.<br>
</blockquote></div>