<font size=2 face="sans-serif">Windows 2008 R2</font>
<br>
<br><font size=2 face="sans-serif">Regards,</font>
<br><font size=2 face="sans-serif">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></font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc:
</font><font size=1 face="sans-serif">Agarwal Ruchita <agarwal.ruchita@tcs.com>,
users@ovirt.org</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date:
</font><font size=1 face="sans-serif">09/23/2014 06:58 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/23/2014 06:39 AM, Chandrahasa S wrote:<br>
> Dear Juan,<br>
> <br>
> Thanks lot for support.<br>
> <br>
> Internal server error issue also resolved with linux guests. Now we
are<br>
> able to provide ip and hostname to linux guests in rhev 3.4 successfully<br>
> via RESTAPI giving boot protocol as "static"
as advised.<br>
> <br>
> For Windows Guest we did the following:<br>
> 1) Prepared a template with guest agents
installed and deployed a<br>
> vm successfully through RESTAPI.<br>
> 2) Following initialization part same as
Linux guest did not work<br>
> in this case and it gives default/garbage ip,hostname to the vm.<br>
> 3) So we tried giving it through
sysprep/payload tag through<br>
> REST API. Code snippet is as follows:<br>
> <br>
> HttpPut put = new HttpPut(<br>
>
<br>
> "</font></tt><a href="https://rhevmanager/api/vms/7dac74d2-c504-4bbd-8659-c8773a844cb3/"><tt><font size=2>https://rhevmanager/api/vms/7dac74d2-c504-4bbd-8659-c8773a844cb3/</font></tt></a><tt><font size=2><br>
> <</font></tt><a href="https://192.168.114.36/api/vms/7dac74d2-c504-4bbd-8659-c8773a844cb3/"><tt><font size=2>https://192.168.114.36/api/vms/7dac74d2-c504-4bbd-8659-c8773a844cb3/</font></tt></a><tt><font size=2>>");<br>
>
String inputXML1 = "<?xml version=\"1.0\"?>"<br>
> /*"<vm>"*/<br>
>
+"<sso>"+"<methods>"+"<method<br>
> id=\""+"GUEST_AGENT"+"\"/>"+"</methods>"+"</sso>"<br>
>
<br>
> +"<domain>"+"<name>ultimatixuat.net</name>"+"</domain>"<br>
>
<br>
>
+"<payloads>"+"<payload<br>
> type=\""+"floppy"+"\">"+ "<files>"+"<file>"<br>
>
<br>
> +"<name>/WEB-INF/sysprep.xml</name>"
<br>
>
<br>
> +"</file>"+"</files>"+"</payload>"+"</payloads>"<br>
>
<br>
> +"<reported_devices>"+"<reported_device>"+"<ips>"+"<ip<br>
> address=\""+"1.1.1.1"+"\"/</ips>"<br>
>
<br>
>
<br>
> +"<fqdn>WIN-AS05EOADAwerwer</fqdn>"+"</reported_device>"+"<reported_devices>";<br>
> <br>
>
<br>
>
StringEntity input1 = new StringEntity(inputXML1);<br>
>
put.setEntity(input1);<br>
>
put.setHeader("Content-Type", "application/xml");<br>
>
HttpResponse responseNIC = httpclient.execute(put);<br>
>
System.out<br>
>
.println("RESPONSE<br>
> ::::::::::::::::::::::::::::::::::: "<br>
>
+ responseNIC);<br>
>
<br>
>
BufferedReader rd1 = new BufferedReader(new<br>
> InputStreamReader(<br>
>
<br>
> responseNIC.getEntity().getContent()));<br>
>
String line1 = "";<br>
>
while ((line1 = rd1.readLine()) != null) {<br>
>
System.out.println("LINE
::::::::::::: "<br>
> + line1);<br>
>
}<br>
>
<br>
> The output says that my code is syntactically
incorrect. I am<br>
> not very sure as to what has to be the content of "sysprep.xml"
file and<br>
> what is syntactically incorrect here.<br>
> <br>
> Also while deploying the windows machine
manually through the<br>
> rhev manager , while using sysprep option in "run once"
, I am unable to<br>
> find the ip and hostname options as found
for linux <br>
> machines.<br>
> <br>
> <br>
> Regards,<br>
> Chandrahasa S<br>
> <br>
<br>
What version of Windows are you using?<br>
<br>
> <br>
> <br>
> From: Juan Hernandez <jhernand@redhat.com><br>
> To: Chandrahasa S <chandrahasa.s@tcs.com><br>
> Cc: Agarwal Ruchita <agarwal.ruchita@tcs.com>,
users@ovirt.org,<br>
> "'Shahar Havivi'" <shavivi@redhat.com><br>
> Date: 09/18/2014 06:30 PM<br>
> Subject: Re: [ovirt-users] Error while
using REST API with Ovirt<br>
> ------------------------------------------------------------------------<br>
> <br>
> <br>
> <br>
> On 09/18/2014 01:39 PM, Chandrahasa S wrote:<br>
>> Dear Juan / All,<br>
>><br>
>> Thanks for reply.<br>
>><br>
>> I tried to give the hostname with the tag mentioned "host_name".
Its<br>
>> working.<br>
>><br>
>> So below are the issues still remaining:<br>
>><br>
>> 1) The issue of internal server error
still persits (rhev<br>
>> manager showing issues) even after following the advice of the
expert<br>
>> and doing the initialization part just once(giving ip and
<br>
>> hostname) after creating the vm.<br>
>><br>
> <br>
> Actually this is a bug:<br>
> <br>
> </font></tt><a href=https://bugzilla.redhat.com/1144005><tt><font size=2>https://bugzilla.redhat.com/1144005</font></tt></a><tt><font size=2><br>
> <br>
> The reason is that when you use an incorrect boot protocol we end
up<br>
> storing null in the corresponding place in the database, and later
we<br>
> use the value without checking it, which triggers a null pointer exception.<br>
> <br>
> The right value for the boot protocol is "static", not "STATIC_IP".
The<br>
> "STATIC_IP" value is what we use in the backend and in the
database, but<br>
> in the RESTAPI it is "static".<br>
> <br>
> To workaround this issue you can delete the VMs and create them again<br>
> with the correct boot protocol.<br>
> <br>
> If you don't want to create the VMs again you can fix the database<br>
> manually like this:<br>
> <br>
> # su - postgres<br>
> # psql<br>
> postgres=# \c engine<br>
> engine=# update vm_init set networks = replace(networks, '"bootProtocol"<br>
> : null', '"bootProtocol" : "STATIC_IP"');<br>
> <br>
>> 2) Please confirm if this is the case
that we can do<br>
>> initialization part only once on a particular vm , then we can<br>
>> reconfigure the network (ip, subnet, gateway etc)<br>
>> or not for that vm.<br>
>><br>
> <br>
> I'm reasonably sure that you can run initialization only once per
VM,<br>
> but Shahar can confirm this better than me.<br>
> <br>
>> 3) For Windows guest we are still
unable to provide ip details<br>
>> and hostname using sysprep/payload.<br>
>><br>
> <br>
> I'm not familiar with Sysprep. Can you provide an example of the code<br>
> that you are using for that?<br>
> <br>
>> Error attached.<br>
>><br>
>><br>
>><br>
>> Regards,<br>
>> Chandrahasa S<br>
>><br>
>><br>
>><br>
>> From: Juan Hernandez <jhernand@redhat.com><br>
>> To: Chandrahasa S <chandrahasa.s@tcs.com>,
users@ovirt.org<br>
>> Cc: Agarwal Ruchita <agarwal.ruchita@tcs.com><br>
>> Date: 09/18/2014 03:35 PM<br>
>> Subject: Re: [ovirt-users] Error while
using REST API with Ovirt<br>
>> ------------------------------------------------------------------------<br>
>><br>
>><br>
>><br>
>> 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>
-- <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>