<font size=2 face="sans-serif">Dear Juan,</font>
<br>
<br><font size=2 face="sans-serif">
Thanks for the prompt reply and support.</font>
<br>
<br><font size=2 face="sans-serif">
As advised I did the registry editing and
then created a template and tried to give the hostname in the manner told
to the deployed vm but no luck. </font>
<br><font size=2 face="sans-serif">
It does not give any error but on checking
the hostname through machine console it is not set there. Please find attached
the screen shot of the registry editing done.</font>
<br>
<br><img src=cid:_1_108AD028108ACDE80034766365257D5E style="border:0px solid;">
<br>
<br><font size=2 face="sans-serif"> Also
for ip configuration if any other method is possible other than DHCP server
option please tell .</font>
<br>
<br><font size=2 face="sans-serif"><br>
<br>
Thanks & Regards<br>
Ruchita Agarwal<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 09:23 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 04:55 PM, Chandrahasa S wrote:<br>
> Windows 2008 R2<br>
> <br>
> Regards,<br>
> Chandrahasa S<br>
> <br>
<br>
Ok. I don't have a 2008 machine to tests, but I tested with Windows 7,<br>
which should be quite similar. These are my suggestions:<br>
<br>
* Take into account that Windows 2008 uses an XML format for the answers<br>
file, and that the file name that sysprep will look for is<br>
"Unattend.xml". On the other hand the engine will always generate
a file<br>
named "sysprep.inf", so you need to alter the registry settings
of the<br>
VM before creating the template. In particular you need to create a key<br>
named "UnattendFile" entry under "HKEY-LOCAL-MACHINE ->
SYSTEM -><br>
Setup". The value should be the location of the file. For the files<br>
generated by the engine it should be "A:\sysprep.inf". With this
the<br>
sysprep support should work if you use it from the GUI.<br>
<br>
* The guest agent is nice to have, but not required in order to use<br>
sysprep, and it won't allow you to change the IP configuration of the<br>
guest, only to view it.<br>
<br>
* As far as I know sysprep doesn't allow you to configure the IP<br>
addresses, only the machine name, so I believe you will have to use a<br>
different mechanism, like configuring your DHCP server so that it<br>
assigns IP addresses based on MAC addresses or host names.<br>
<br>
* You don't need to provide the content of the sysprep file, it is<br>
automatically generated by the engine, merging the parameters that you<br>
pass with the static content in the templte file<br>
/usr/share/ovirt-engine/conf/sysprep.2k8.<br>
<br>
So, to summarize, after preparing correctly the image, you should send
a<br>
request like this (assuming that the VM is already created from the<br>
template):<br>
<br>
PUT /api/vms/7dac74d2-c504-4bbd-8659-c8773a844cb3<br>
<vm><br>
<initialization><br>
<host_name>WIN-AS05EOADAwerwer</host_name><br>
<domain>ultimatixuat.net</domain><br>
</initialization><br>
</vm><br>
<br>
Then you can start it like this:<br>
<br>
POST /api/vms/7dac74d2-c504-4bbd-8659-c8773a844cb3/start<br>
<action/><br>
<br>
And sysprep should trigger and configure the VM. Take into account that<br>
this only works the first time you start the VM, so if you are testing<br>
multiple times remember to remove and create it again.<br>
<br>
To debug this, once the VM is started, go to the hypervisor where it is<br>
running and find the qemu process:<br>
<br>
# ps -ef | grep -- '-name the_name_of_your_vm'<br>
<br>
That should be a very long command line, including a "-drive"
option<br>
corresponding to the sysprep floppy that the engine created and added to<br>
the VM:<br>
<br>
-drive<br>
file=/var/run/vdsm/payload/27faa0ce-3e4d-4705-adf8-30d6e9fde741.a659e9a9747fe55a8eb0c7ecbc549c86.img<br>
<br>
Copy that .img file somewhere, mount and inspect it:<br>
<br>
# cp<br>
/var/run/vdsm/payload/27faa0ce-3e4d-4705-adf8-30d6e9fde741.a659e9a9747fe55a8eb0c7ecbc549c86.img<br>
/tmp/f.img<br>
# mount -o loop,ro /tmp/f.img /mnt<br>
# find /mnt/<br>
/mnt/<br>
/mnt/sysprep.inf<br>
<br>
Check the content of the /mnt/sysprep.inf file, it should contain your<br>
settings.<br>
<br>
If the content of the floppy and the sysprep.inf file are correct but<br>
your VM is still not being configured then there is something wrong with<br>
the preparation of the template.<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>
> Date: 09/23/2014 06:58 PM<br>
> Subject: Re: [ovirt-users] Error while
using REST API with Ovirt<br>
> ------------------------------------------------------------------------<br>
> <br>
> <br>
> <br>
> 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>
>><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 =<br>
> 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<br>
> 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>
> <br>
> =====-----=====-----=====<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<br>
> <br>
> <br>
> <br>
> _______________________________________________<br>
> Users mailing list<br>
> Users@ovirt.org<br>
> </font></tt><a href=http://lists.ovirt.org/mailman/listinfo/users><tt><font size=2>http://lists.ovirt.org/mailman/listinfo/users</font></tt></a><tt><font size=2><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>
</font></tt>
<br>