Re: [ovirt-users] Error while using REST API with Ovirt
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 To: Chandrahasa S Cc: Agarwal Ruchita , 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 WIN-AS05EOADAwerwer ultimatixuat.net Then you can start it like this: POST /api/vms/7dac74d2-c504-4bbd-8659-c8773a844cb3/start 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 > To: Chandrahasa S > Cc: Agarwal Ruchita , 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/pa
Re: [ovirt-users] Error while using REST API with Ovirt
On 09/25/2014 11:33 AM, Agarwal Ruchita wrote: > 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. > Did you check the contents of the floppy disk attached to the VM as I described in the previous message? What is the content? Also make sure that the operating system of the machine is configured correctly. With the RESTAPI you can check as follows: GET /vms/9895613f-3227-4f66-a13b-9f60f197e9e8 ... ... ... If the operating system isn't set correctly the engine will try to use cloud-init instead of sysprep, and that doesn't work with Windows. > > Also for ip configuration if any other method is possible other > than DHCP server option please tell . > It may be possible to set the IP address with a custom Unattend.xml file. I'd suggest you study the Microsoft documentation available here: http://technet.microsoft.com/en-us/library/hh825114.aspx Apparently there is a tool called "Windows System Image Manager (Windows SIM)" that you can use to open and modify a the answers file. But I can't tell you if this allows setting the IP address, as I don't have that tool. If you finally make an answers file that works as you expect, then you can generate it from your program, and send it as part of the RESTAPI request, using the "custom_script" element: PUT /api/vms/9895613f-3227-4f66-a13b-9f60f197e9e8 Then start the VM: POST /api/vms/9895613f-3227-4f66-a13b-9f60f197e9e8/start > > > Thanks & Regards > Ruchita Agarwal > > > > From:Juan Hernandez > To: Chandrahasa S > Cc: Agarwal Ruchita , 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 > > > WIN-AS05EOADAwerwer > ultimatixuat.net > > > > Then you can start it like this: > > POST /api/vms/7dac74d2-c504-4bbd-8659-c8773a844cb3/start > > > 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
Re: [ovirt-users] Error while using REST API with Ovirt
On 09/24/2014 09:23 AM, Sven Kieske wrote: > Are there plans to improve this, so you don't have to mess > with the image before using it? Like a switch generating the needed > xml file instead of the inf file? > I'm not aware of any plans in these regards. I opened the following bug to track this request: https://bugzilla.redhat.com/1145999 > On 23/09/14 17:47, Juan Hernandez wrote: >> * 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. > -- 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
Re: [ovirt-users] Error while using REST API with Ovirt
Are there plans to improve this, so you don't have to mess with the image before using it? Like a switch generating the needed xml file instead of the inf file? On 23/09/14 17:47, Juan Hernandez wrote: > * 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. -- Mit freundlichen Grüßen / Regards Sven Kieske Systemadministrator Mittwald CM Service GmbH & Co. KG Königsberger Straße 6 32339 Espelkamp T: +49-5772-293-100 F: +49-5772-293-333 https://www.mittwald.de Geschäftsführer: Robert Meyer St.Nr.: 331/5721/1033, USt-IdNr.: DE814773217, HRA 6640, AG Bad Oeynhausen Komplementärin: Robert Meyer Verwaltungs GmbH, HRB 13260, AG Bad Oeynhausen ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
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 WIN-AS05EOADAwerwer ultimatixuat.net Then you can start it like this: POST /api/vms/7dac74d2-c504-4bbd-8659-c8773a844cb3/start 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 > To: Chandrahasa S > Cc: Agarwal Ruchita , 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 = "" >> /*""*/ >> +""+""+"> id=\""+"GUEST_AGENT"+"\"/>"+""+"" >> >> +""+"ultimatixuat.net"+"" >>
Re: [ovirt-users] Error while using REST API with Ovirt
Windows 2008 R2 Regards, Chandrahasa S From: Juan Hernandez To: Chandrahasa S Cc: Agarwal Ruchita , 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 = "" > /*""*/ > +""+""+" id=\""+"GUEST_AGENT"+"\"/>"+""+"" > > +""+"ultimatixuat.net"+"" > > +""+" type=\""+"floppy"+"\">"+ ""+"" > > +"/WEB-INF/sysprep.xml" > > +""+""+""+"" > > +""+""+""+" address=\""+"1.1.1.1"+"\"/" > > > +"WIN-AS05EOADAwerwer"+""+""; > > > 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 > To:Chandrahasa S > Cc:Agarwal Ruchita , users@ovirt.org, > "'Shahar Havivi'" > 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 b
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 = "" > /*""*/ > +""+""+" id=\""+"GUEST_AGENT"+"\"/>"+""+"" > > +""+"ultimatixuat.net"+"" > > +""+" type=\""+"floppy"+"\">"+ ""+"" > > +"/WEB-INF/sysprep.xml" > > +""+""+""+"" > > +""+""+""+" address=\""+"1.1.1.1"+"\"/" > > > +"WIN-AS05EOADAwerwer"+""+""; > > > 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 > To:Chandrahasa S > Cc:Agarwal Ruchita , users@ovirt.org, > "'Shahar Havivi'" > 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,
Re: [ovirt-users] Error while using REST API with Ovirt
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/";); String inputXML1 = "" /*""*/ +""+""+""+""+"" +""+"ultimatixuat.net"+"" +""+""+ ""+"" +"/WEB-INF/sysprep.xml" +""+""+""+"" +""+""+""+"" +"WIN-AS05EOADAwerwer"+""+""; 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 foundfor linux machines. Regards, Chandrahasa S From: Juan Hernandez To: Chandrahasa S Cc: Agarwal Ruchita , users@ovirt.org, "'Shahar Havivi'" 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, > Chandrah
Re: [ovirt-users] Error while using REST API with Ovirt
On 18.09.14 15:00, Juan Hernandez wrote: > 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. Yes on RunVm we send the cloud-init params only the first time, ie when the is_initialized flag is false in vm_static table, You can resend the existing cloud-init params (and override them) via the RunOnce - I believe that if you run the VM via Rest with the section it will run via RunOnce. > > > 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? In 3.5 we have a filed vm_hostname, regarding the IP you can provide the Sysprep file in the Initialization/Sysprep elements (not sure that is the right name, Juan?) - please note that if you do provide it we send the Sysprep as is and not replace the vm_hostname and other fields that user provided. > > > Error attached. > > > > > > > > Regards, > > Chandrahasa S > > > > > > > > From:Juan Hernandez > > To:Chandrahasa S , users@ovirt.org > > Cc:Agarwal Ruchita > > 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 = > > "" > >+ "" > >+ "" > >+ "meghaasadmin.ultimatixuat.net" > >+ "false" > >+ "" > >+ "" > >+ "eth0" > >+ " > gateway=\"13.3.3.3\"/>" > >+ "static&
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 > To:Chandrahasa S , users@ovirt.org > Cc:Agarwal Ruchita > 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 = > "" >+ "" >+ "" >+ "meghaasadmin.ultimatixuat.net" >+ "false" >+ "" >+ "" >+ "eth0" >+ " gateway=\"13.3.3.3\"/>" >+ "static" >+ "true" >+ "" >+ "" >+ "" >+ ""; >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 = > "" >+ ""; >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 = clien
Re: [ovirt-users] Error while using REST API with Ovirt
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. 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. 3) For Windows guest we are still unable to provide ip details and hostname using sysprep/payload. Error attached. Regards, Chandrahasa S From: Juan Hernandez To: Chandrahasa S , users@ovirt.org Cc: Agarwal Ruchita 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 = "" + "" + "" + "meghaasadmin.ultimatixuat.net" + "false" + "" + "" + "eth0" + "" + "static" + "true" + "" + "" + "" + ""; 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 = "" + ""; 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
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 = "" + "" + "" + "meghaasadmin.ultimatixuat.net" + "false" + "" + "" + "eth0" + "" + "static" + "true" + "" + "" + "" + ""; 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 = "" + ""; 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. ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
[ovirt-users] Error while using REST API with Ovirt
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. Regards, Chandrahasa S =-=-= 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 IssuesName: 1)Setting Hostname for deployed VM CODE: HttpPut put = new HttpPut( "https://rhevmanager/api/vms/3a4a3c6e-4bbc-4fea-8bb3-dcb6b4587ee4/";); String inputXML1 = "" +""+"" + "ultimatixuat.net" +"meghaasadmin" +"false" +""+""+ "eth0"+ "" + "STATIC_IP "+ " true"+ ""+ "" +""+""; StringEntity input = new StringEntity(inputXML1); put.setEntity(input); 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); } NOTE: I have tried with Tagname , and other related tags and placed them at various positions but still it gave bad request error. ERROR: RESPONSE ::: HTTP/1.1 400 Bad Request [Date: Wed, 27 Aug 2014 08:18:52 GMT, Content-Type: application/xml, Content-Length: 5663, Vary: Accept-Encoding, Connection: close] LINE : Request syntactically incorrect. See the link description below for the correct usage: update the virtual machine in the system for the given virtual machine id PUT Content-Type application/xml|json Correlation-Id any string VM update the virtual machine in the system for the given virtual machine id with the values specified in the request vm.name vm.cluster.id|name vm.timezone vm.os.boot boot.dev vm.custom_properties.custom_property custom_property.name custom_property.value vm.os.type vm.usb.enabled vm.usb.type vm.type vm.os.initRd vm.display.monitors vm.display.single_qxl_pci vm.display.type vm.display.allow_override vm.display.smartcard_enabled vm.display.keyboard_layout vm.os.cmdline vm.cpu.mode vm.cpu.architecture