Dear Juan, Thanks for the prompt reply and support.
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. 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. Also for ip configuration if any other method is possible other than DHCP server option please tell . Thanks & Regards Ruchita Agarwal From: Juan Hernandez <jhern...@redhat.com> To: Chandrahasa S <chandrahas...@tcs.com> Cc: Agarwal Ruchita <agarwal.ruch...@tcs.com>, users@ovirt.org Date: 09/23/2014 09:23 PM Subject: Re: [ovirt-users] Error while using REST API with Ovirt On 09/23/2014 04:55 PM, Chandrahasa S wrote: > Windows 2008 R2 > > Regards, > Chandrahasa S > Ok. I don't have a 2008 machine to tests, but I tested with Windows 7, which should be quite similar. These are my suggestions: * Take into account that Windows 2008 uses an XML format for the answers file, and that the file name that sysprep will look for is "Unattend.xml". On the other hand the engine will always generate a file named "sysprep.inf", so you need to alter the registry settings of the VM before creating the template. In particular you need to create a key named "UnattendFile" entry under "HKEY-LOCAL-MACHINE -> SYSTEM -> Setup". The value should be the location of the file. For the files generated by the engine it should be "A:\sysprep.inf". With this the sysprep support should work if you use it from the GUI. * The guest agent is nice to have, but not required in order to use sysprep, and it won't allow you to change the IP configuration of the guest, only to view it. * As far as I know sysprep doesn't allow you to configure the IP addresses, only the machine name, so I believe you will have to use a different mechanism, like configuring your DHCP server so that it assigns IP addresses based on MAC addresses or host names. * You don't need to provide the content of the sysprep file, it is automatically generated by the engine, merging the parameters that you pass with the static content in the templte file /usr/share/ovirt-engine/conf/sysprep.2k8. So, to summarize, after preparing correctly the image, you should send a request like this (assuming that the VM is already created from the template): PUT /api/vms/7dac74d2-c504-4bbd-8659-c8773a844cb3 <vm> <initialization> <host_name>WIN-AS05EOADAwerwer</host_name> <domain>ultimatixuat.net</domain> </initialization> </vm> Then you can start it like this: POST /api/vms/7dac74d2-c504-4bbd-8659-c8773a844cb3/start <action/> And sysprep should trigger and configure the VM. Take into account that this only works the first time you start the VM, so if you are testing multiple times remember to remove and create it again. To debug this, once the VM is started, go to the hypervisor where it is running and find the qemu process: # ps -ef | grep -- '-name the_name_of_your_vm' That should be a very long command line, including a "-drive" option corresponding to the sysprep floppy that the engine created and added to the VM: -drive file=/var/run/vdsm/payload/27faa0ce-3e4d-4705-adf8-30d6e9fde741.a659e9a9747fe55a8eb0c7ecbc549c86.img Copy that .img file somewhere, mount and inspect it: # cp /var/run/vdsm/payload/27faa0ce-3e4d-4705-adf8-30d6e9fde741.a659e9a9747fe55a8eb0c7ecbc549c86.img /tmp/f.img # mount -o loop,ro /tmp/f.img /mnt # find /mnt/ /mnt/ /mnt/sysprep.inf Check the content of the /mnt/sysprep.inf file, it should contain your settings. If the content of the floppy and the sysprep.inf file are correct but your VM is still not being configured then there is something wrong with the preparation of the template. > > > From: Juan Hernandez <jhern...@redhat.com> > To: Chandrahasa S <chandrahas...@tcs.com> > Cc: Agarwal Ruchita <agarwal.ruch...@tcs.com>, users@ovirt.org > Date: 09/23/2014 06:58 PM > Subject: Re: [ovirt-users] Error while using REST API with Ovirt > ------------------------------------------------------------------------ > > > > On 09/23/2014 06:39 AM, Chandrahasa S wrote: >> Dear Juan, >> >> Thanks lot for support. >> >> Internal server error issue also resolved with linux guests. Now we are >> able to provide ip and hostname to linux guests in rhev 3.4 successfully >> via RESTAPI giving boot protocol as "static" as advised. >> >> For Windows Guest we did the following: >> 1) Prepared a template with guest agents installed and deployed a >> vm successfully through RESTAPI. >> 2) Following initialization part same as Linux guest did not work >> in this case and it gives default/garbage ip,hostname to the vm. >> 3) So we tried giving it through sysprep/payload tag through >> REST API. Code snippet is as follows: >> >> HttpPut put = new HttpPut( >> >> "https://rhevmanager/api/vms/7dac74d2-c504-4bbd-8659-c8773a844cb3/ >> <https://192.168.114.36/api/vms/7dac74d2-c504-4bbd-8659-c8773a844cb3/ >"); >> String inputXML1 = "<?xml version=\"1.0\"?>" >> /*"<vm>"*/ >> +"<sso>"+"<methods>"+"<method >> id=\""+"GUEST_AGENT"+"\"/>"+"</methods>"+"</sso>" >> >> +"<domain>"+"<name>ultimatixuat.net</name>"+"</domain>" >> >> +"<payloads>"+"<payload >> type=\""+"floppy"+"\">"+ "<files>"+"<file>" >> >> +"<name>/WEB-INF/sysprep.xml</name>" >> >> +"</file>"+"</files>"+"</payload>"+"</payloads>" >> >> +"<reported_devices>"+"<reported_device>"+"<ips>"+"<ip >> address=\""+"1.1.1.1"+"\"/</ips>" >> >> >> > +"<fqdn>WIN-AS05EOADAwerwer</fqdn>"+"</reported_device>"+"<reported_devices>"; >> >> >> StringEntity input1 = new StringEntity(inputXML1); >> put.setEntity(input1); >> put.setHeader("Content-Type", "application/xml"); >> HttpResponse responseNIC = > httpclient.execute(put); >> System.out >> .println("RESPONSE >> ::::::::::::::::::::::::::::::::::: " >> + responseNIC); >> >> BufferedReader rd1 = new BufferedReader(new >> InputStreamReader( >> >> responseNIC.getEntity().getContent())); >> String line1 = ""; >> while ((line1 = rd1.readLine()) != null) { >> System.out.println("LINE ::::::::::::: " >> + line1); >> } >> >> The output says that my code is syntactically incorrect. I am >> not very sure as to what has to be the content of "sysprep.xml" file and >> what is syntactically incorrect here. >> >> Also while deploying the windows machine manually through the >> rhev manager , while using sysprep option in "run once" , I am unable to >> find the ip and hostname options as found for linux >> machines. >> >> >> Regards, >> Chandrahasa S >> > > What version of Windows are you using? > >> >> >> From: Juan Hernandez <jhern...@redhat.com> >> To: Chandrahasa S <chandrahas...@tcs.com> >> Cc: Agarwal Ruchita <agarwal.ruch...@tcs.com>, users@ovirt.org, >> "'Shahar Havivi'" <shav...@redhat.com> >> Date: 09/18/2014 06:30 PM >> Subject: Re: [ovirt-users] Error while using REST API with Ovirt >> ------------------------------------------------------------------------ >> >> >> >> On 09/18/2014 01:39 PM, Chandrahasa S wrote: >>> Dear Juan / All, >>> >>> Thanks for reply. >>> >>> I tried to give the hostname with the tag mentioned "host_name". Its >>> working. >>> >>> So below are the issues still remaining: >>> >>> 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. >>> >> >> Actually this is a bug: >> >> https://bugzilla.redhat.com/1144005 >> >> The reason is that when you use an incorrect boot protocol we end up >> storing null in the corresponding place in the database, and later we >> use the value without checking it, which triggers a null pointer > exception. >> >> The right value for the boot protocol is "static", not "STATIC_IP". The >> "STATIC_IP" value is what we use in the backend and in the database, but >> in the RESTAPI it is "static". >> >> To workaround this issue you can delete the VMs and create them again >> with the correct boot protocol. >> >> If you don't want to create the VMs again you can fix the database >> manually like this: >> >> # su - postgres >> # psql >> postgres=# \c engine >> engine=# update vm_init set networks = replace(networks, '"bootProtocol" >> : null', '"bootProtocol" : "STATIC_IP"'); >> >>> 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) >>> or not for that vm. >>> >> >> I'm reasonably sure that you can run initialization only once per VM, >> but Shahar can confirm this better than me. >> >>> 3) For Windows guest we are still unable to provide ip details >>> and hostname using sysprep/payload. >>> >> >> I'm not familiar with Sysprep. Can you provide an example of the code >> that you are using for that? >> >>> Error attached. >>> >>> >>> >>> Regards, >>> Chandrahasa S >>> >>> >>> >>> From: Juan Hernandez <jhern...@redhat.com> >>> To: Chandrahasa S <chandrahas...@tcs.com>, users@ovirt.org >>> Cc: Agarwal Ruchita <agarwal.ruch...@tcs.com> >>> Date: 09/18/2014 03:35 PM >>> Subject: Re: [ovirt-users] Error while using REST API with Ovirt >>> ------------------------------------------------------------------------ >>> >>> >>> >>> On 09/18/2014 08:18 AM, Chandrahasa S wrote: >>>> Dear Experts. >>>> >>>> We are Integrating our internal cloud portal with Ovirt / RHEVM version >>>> 3.4. >>>> >>>> We are integrating our internal cloud with Ovirt / RHEVM. VM template >>>> created using cloud init. >>>> >>>> Through REST API Nippet while codes passes command to template ( with >>>> cloud init) IP, HOSTNAME, We are able to set IP and Hostname to VM >>>> through code. >>>> >>>> But post this Manager getting handed. Error code is attached. >>>> >>>> Need your help please. >>>> >>> >>> If I understand correctly you already created a template with the cloud >>> init configuration, then you created a VM from that template, and you >>> want to modify it and start it. In order to update the VM you need to >>> issue a PUT request, and the tag name for the host is "host_name": >>> >>> String updateXml = >>> "<?xml version=\"1.0\"?>" >>> + "<vm>" >>> + "<initialization>" >>> + "<host_name>meghaasadmin.ultimatixuat.net</host_name>" >>> + "<regenerate_ssh_keys>false</regenerate_ssh_keys>" >>> + "<nic_configurations>" >>> + "<nic_configuration>" >>> + "<name>eth0</name>" >>> + "<ip address=\"1.1.1.1\" netmask=\"255.255.255.0\" >>> gateway=\"13.3.3.3\"/>" >>> + "<boot_protocol>static</boot_protocol>" >>> + "<on_boot>true</on_boot>" >>> + "</nic_configuration>" >>> + "</nic_configurations>" >>> + "</initialization>" >>> + "</vm>"; >>> StringEntity updateEntity = new StringEntity(updateXml); >>> HttpPut updateRequest = new HttpPut(apiUrl + "/vms/" + vmId); >>> updateRequest.setHeader("Content-Type", "application/xml"); >>> updateRequest.setHeader("Accept", "application/xml"); >>> updateRequest.setEntity(updateEntity); >>> HttpResponse updateResponse = client.execute(updateRequest); >>> >>> Then, after the update, you need to start the VM and it will use that >>> configuration: >>> >>> String startXml = >>> "<?xml version=\"1.0\"?>" >>> + "<action/>"; >>> StringEntity startEntity = new StringEntity(startXml); >>> HttpPost startRequest = new HttpPost(apiUrl + "/vms/" + vmId + >>> "/start"); >>> startRequest.setEntity(startEntity); >>> startRequest.setHeader("Content-Type", "application/xml"); >>> startRequest.setHeader("Accept", "application/xml"); >>> HttpResponse startResponse = client.execute(startRequest); >>> >>> Some advices: >>> >>> * Check the XML schema for the structure of the XML documents: >>> >>> https://rhevmanager/api?schema >>> >>> * When sending requests to the RESTAPI makes sure to always explicitly >>> add the Content-Type and Accept headers: >>> >>> yourRequest.setHeader("Content-Type", "application/xml"); >>> yourRequest.setHeader("Accept", "application/xml"); >>> >>> * Take into account that the initialization with cloud-init will only be >>> executed the first time you start the VM, so in your tests you will need >>> to remove the VM and create it again. >>> >>> * If you are planning to do complex things you may find it helpful the >>> Java SDK: >>> >>> http://www.ovirt.org/Java-sdk >>> > > -- > Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta > 3ºD, 28016 Madrid, Spain > Inscrita en el Reg. Mercantil de Madrid ? C.I.F. B82657941 - Red Hat S.L. > > =====-----=====-----===== > Notice: The information contained in this e-mail > message and/or attachments to it may contain > confidential or privileged information. If you are > not the intended recipient, any dissemination, use, > review, distribution, printing or copying of the > information contained in this e-mail message > and/or attachments to it are strictly prohibited. If > you have received this communication in error, > please notify us by reply e-mail or telephone and > immediately and permanently delete the message > and any attachments. Thank you > > > > _______________________________________________ > Users mailing list > Users@ovirt.org > http://lists.ovirt.org/mailman/listinfo/users > -- Dirección Comercial: C/Jose Bardasano Baos, 9, Edif. Gorbea 3, planta 3ºD, 28016 Madrid, Spain Inscrita en el Reg. Mercantil de Madrid ? C.I.F. B82657941 - Red Hat S.L.
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users