Windows 2008 R2 Regards, Chandrahasa S
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