<font size=2 face="sans-serif">Dear Juan / All,</font>
<br>
<br><font size=2 face="sans-serif">Thanks for reply.</font>
<br>
<br><font size=2 face="sans-serif"> I tried to give the hostname with
the tag mentioned "host_name". Its working.</font>
<br>
<br><font size=2 face="sans-serif"> So
below are the issues still remaining:</font>
<br>
<br><font size=2 face="sans-serif"> 1)
The issue of internal server error still persits (rhev manager showing
issues) even after following the advice of the expert and doing the initialization
part just once(giving ip and
hostname) after creating the vm.</font>
<br>
<br><font size=2 face="sans-serif"> 2)
Please confirm if this is the case that we can do initialization
part only once on a particular vm , then we can reconfigure the network
(ip, subnet, gateway etc)</font>
<br><font size=2 face="sans-serif">
or not for that vm. </font>
<br>
<br><font size=2 face="sans-serif"> 3)
For Windows guest we are still unable to provide ip details and hostname
using sysprep/payload.</font>
<br>
<br><font size=2 face="sans-serif">Error attached.</font>
<br>
<br><img src=cid:_1_0A9F90100A9F8DA4003FFEA465257D57 style="border:0px solid;">
<br>
<br><font size=2 face="sans-serif">Regards,<br>
Chandrahasa S<br>
</font>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From:
</font><font size=1 face="sans-serif">Juan Hernandez <jhernand@redhat.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">To:
</font><font size=1 face="sans-serif">Chandrahasa S <chandrahasa.s@tcs.com>,
users@ovirt.org</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc:
</font><font size=1 face="sans-serif">Agarwal Ruchita <agarwal.ruchita@tcs.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date:
</font><font size=1 face="sans-serif">09/18/2014 03:35 PM</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject:
</font><font size=1 face="sans-serif">Re: [ovirt-users]
Error while using REST API with Ovirt</font>
<br>
<hr noshade>
<br>
<br>
<br><tt><font size=2>On 09/18/2014 08:18 AM, Chandrahasa S wrote:<br>
> Dear Experts.<br>
> <br>
> We are Integrating our internal cloud portal with Ovirt / RHEVM
version<br>
> 3.4.<br>
> <br>
> We are integrating our internal cloud with Ovirt / RHEVM. VM template<br>
> created using cloud init.<br>
> <br>
> Through REST API Nippet while codes passes command to template ( with<br>
> cloud init) IP, HOSTNAME, We are able to set IP and Hostname to VM<br>
> through code.<br>
> <br>
> But post this Manager getting handed. Error code is attached.<br>
> <br>
> Need your help please.<br>
> <br>
<br>
If I understand correctly you already created a template with the cloud<br>
init configuration, then you created a VM from that template, and you<br>
want to modify it and start it. In order to update the VM you need to<br>
issue a PUT request, and the tag name for the host is "host_name":<br>
<br>
String updateXml =<br>
"<?xml version=\"1.0\"?>"<br>
+ "<vm>"<br>
+ "<initialization>"<br>
+ "<host_name>meghaasadmin.ultimatixuat.net</host_name>"<br>
+ "<regenerate_ssh_keys>false</regenerate_ssh_keys>"<br>
+ "<nic_configurations>"<br>
+ "<nic_configuration>"<br>
+ "<name>eth0</name>"<br>
+ "<ip
address=\"1.1.1.1\" netmask=\"255.255.255.0\"<br>
gateway=\"13.3.3.3\"/>"<br>
+ "<boot_protocol>static</boot_protocol>"<br>
+ "<on_boot>true</on_boot>"<br>
+ "</nic_configuration>"<br>
+ "</nic_configurations>"<br>
+ "</initialization>"<br>
+ "</vm>";<br>
StringEntity updateEntity = new StringEntity(updateXml);<br>
HttpPut updateRequest = new HttpPut(apiUrl + "/vms/"
+ vmId);<br>
updateRequest.setHeader("Content-Type", "application/xml");<br>
updateRequest.setHeader("Accept", "application/xml");<br>
updateRequest.setEntity(updateEntity);<br>
HttpResponse updateResponse = client.execute(updateRequest);<br>
<br>
Then, after the update, you need to start the VM and it will use that<br>
configuration:<br>
<br>
String startXml =<br>
"<?xml version=\"1.0\"?>"<br>
+ "<action/>";<br>
StringEntity startEntity = new StringEntity(startXml);<br>
HttpPost startRequest = new HttpPost(apiUrl + "/vms/"
+ vmId +<br>
"/start");<br>
startRequest.setEntity(startEntity);<br>
startRequest.setHeader("Content-Type", "application/xml");<br>
startRequest.setHeader("Accept", "application/xml");<br>
HttpResponse startResponse = client.execute(startRequest);<br>
<br>
Some advices:<br>
<br>
* Check the XML schema for the structure of the XML documents:<br>
<br>
</font></tt><a href=https://rhevmanager/api?schema><tt><font size=2>https://rhevmanager/api?schema</font></tt></a><tt><font size=2><br>
<br>
* When sending requests to the RESTAPI makes sure to always explicitly<br>
add the Content-Type and Accept headers:<br>
<br>
yourRequest.setHeader("Content-Type", "application/xml");<br>
yourRequest.setHeader("Accept", "application/xml");<br>
<br>
* Take into account that the initialization with cloud-init will only be<br>
executed the first time you start the VM, so in your tests you will need<br>
to remove the VM and create it again.<br>
<br>
* If you are planning to do complex things you may find it helpful the<br>
Java SDK:<br>
<br>
</font></tt><a href="http://www.ovirt.org/Java-sdk"><tt><font size=2>http://www.ovirt.org/Java-sdk</font></tt></a><tt><font size=2><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>
</font></tt>
<br>
<p>=====-----=====-----=====<br>
Notice: The information contained in this e-mail<br>
message and/or attachments to it may contain <br>
confidential or privileged information. If you are <br>
not the intended recipient, any dissemination, use, <br>
review, distribution, printing or copying of the <br>
information contained in this e-mail message <br>
and/or attachments to it are strictly prohibited. If <br>
you have received this communication in error, <br>
please notify us by reply e-mail or telephone and <br>
immediately and permanently delete the message <br>
and any attachments. Thank you</p>
<p></p>