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 <jhernand@redhat.com>
To:
Chandrahasa S <chandrahasa.s@tcs.com>,
users@ovirt.org
Cc:
Agarwal Ruchita <agarwal.ruchita@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