<div dir="ltr"><div>Finally I was able to rename the disks, the problem was about handling that put request and my inability to check libcurl documentation (I was treating the XML I was sending as a string instead of a file). </div><div><br></div>Sorry because I needed this script to be working as fast as I could, so I didn't try to reproduce the 500 error, but I wouldn't be suprised if it was because of a totally wrong URL.<div><br></div><div>Sorry again :(</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 28, 2017 at 1:56 PM, Juan Hernández <span dir="ltr"><<a href="mailto:jhernand@redhat.com" target="_blank">jhernand@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 06/28/2017 01:34 PM, Bruno Rodriguez wrote:<br>
> Shit, I got it. Sorry<br>
><br>
> The problem is that I was accessing to the v4 disk-attachment id and I<br>
> was getting everything quite messed up. I was doing all of this while<br>
> creating a machine, so I was trying to rename the disk at the same time<br>
> it's being created.<br>
><br>
> I'll delete all the "if ($ovirt_major == 3)" I have in my code. If I<br>
> have any problem I'll let you know.<br>
><br>
> Thank you<br>
><br>
<br>
</span>If what you want to do is set the name of the disk for a VM that you are<br>
creating then you can just set it when adding the disk:<br>
<br>
POST /ovirt-engine/api/vms/123/<wbr>diskattachments<br>
<br>
<disk_attachment><br>
<disk><br>
<name>yourfavoritename</name><br>
...<br>
</disk><br>
...<br>
</disk_attachment><br>
<br>
That way you don't need to modify it later.<br>
<br>
Also, in general, try to wait till the objects are completely created<br>
before trying to use or update them. For disks in particular, it is good<br>
idea to repeatedly retrieve the disk till the 'status' is 'OK':<br>
<br>
<br>
<a href="https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/add_vm_disk.py#L73-L80" rel="noreferrer" target="_blank">https://github.com/oVirt/<wbr>ovirt-engine-sdk/blob/master/<wbr>sdk/examples/add_vm_disk.py#<wbr>L73-L80</a><br>
<br>
(This is an example from the Python SDK, but you get the idea. There are<br>
SDKs for Ruby and Java as well.)<br>
<br>
Finally, if you get a 500 error then there is most probably a bug. The<br>
API should never return that, even if you try to do something that<br>
doesn't make sense it should respond with a reasonable error message. If<br>
you keep getting that 500 error please share the details.<br>
<span class="im HOEnZb"><br>
> On Wed, Jun 28, 2017 at 1:03 PM, Juan Hernández <<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a><br>
</span><span class="im HOEnZb">> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>>> wrote:<br>
><br>
> On 06/28/2017 12:55 PM, Bruno Rodriguez wrote:<br>
> > I'm sorry about bothering you again, but after trying it some times I'm<br>
> > still getting a "500 Internal Server Error". I'm using a REST client<br>
> > instead of CURL and I tried adding a "Version: 3" to headers and used<br>
> > the URL with the v3 as well.<br>
> ><br>
> > I'm issuing a PUT of<br>
> ><br>
> > <disk><alias>Alias_for_disk</<wbr>alias></disk><br>
> ><br>
> > To the URL<br>
> ><br>
> > <a href="https://myserver/ovirt-engine/api/v3/vms/62498f51-0203-48b9-83c8-4c6f3bdfe05c/disks/583ed952-46a8-4bc5-8a27-8660e4a24ea2" rel="noreferrer" target="_blank">https://myserver/ovirt-engine/<wbr>api/v3/vms/62498f51-0203-48b9-<wbr>83c8-4c6f3bdfe05c/disks/<wbr>583ed952-46a8-4bc5-8a27-<wbr>8660e4a24ea2</a><br>
> <<a href="https://myserver/ovirt-engine/api/v3/vms/62498f51-0203-48b9-83c8-4c6f3bdfe05c/disks/583ed952-46a8-4bc5-8a27-8660e4a24ea2" rel="noreferrer" target="_blank">https://myserver/ovirt-<wbr>engine/api/v3/vms/62498f51-<wbr>0203-48b9-83c8-4c6f3bdfe05c/<wbr>disks/583ed952-46a8-4bc5-8a27-<wbr>8660e4a24ea2</a>><br>
> ><br>
> > I mean, I can live without it but we are using oVirt as a "static<br>
> > virtualization" environment and is quite useful for us being able to<br>
> > recognize easily each disk by its server name. In case I have to wait<br>
> > until the 4.2 API version to automatize this I'll do :(<br>
> ><br>
><br>
> That should work. Can you please check if you get any useful message in<br>
> /var/log/ovirt-engine/server.<wbr>log or /var/log/ovirt-engine/engine.<wbr>log?<br>
><br>
> ><br>
> ><br>
> > On Wed, Jun 28, 2017 at 11:18 AM, Bruno Rodriguez <<a href="mailto:bruno@pic.es">bruno@pic.es</a> <mailto:<a href="mailto:bruno@pic.es">bruno@pic.es</a>><br>
</span><span class="im HOEnZb">> > <mailto:<a href="mailto:bruno@pic.es">bruno@pic.es</a> <mailto:<a href="mailto:bruno@pic.es">bruno@pic.es</a>>>> wrote:<br>
> ><br>
</span><span class="im HOEnZb">> > Thank you very much !!!<br>
> ><br>
> > I expected I was missing something like that. Thanks again!<br>
> ><br>
> > On Wed, Jun 28, 2017 at 11:12 AM, Juan Hernández<br>
> > <<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>><br>
</span><div class="HOEnZb"><div class="h5">> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a> <mailto:<a href="mailto:jhernand@redhat.com">jhernand@redhat.com</a>>>> wrote:<br>
> ><br>
> > On 06/28/2017 10:43 AM, Bruno Rodriguez wrote:<br>
> > > Thank you, Daniel<br>
> > ><br>
> > > I tried a PUT with the same XML body, I got a "405<br>
> Method Not Allowed".<br>
> > > It's quite strange, there must be someting I'm missing<br>
> > ><br>
> ><br>
> > The operation to update a disk will be introduced in version 4<br>
> > of the<br>
> > API with version 4.2 of the engine. Meanwhile the way to<br>
> update<br>
> > the disk<br>
> > is to use version 3 of the API and the disks<br>
> sub-collection of the<br>
> > virtual machine. That means that if you have a VM with id 123<br>
> > and a disk<br>
> > with id 456 you can send a request like this:<br>
> ><br>
> > PUT /ovirt-engine/api/v3/vms/123/<wbr>disks/456<br>
> ><br>
> > With a request body like this:<br>
> ><br>
> > <disk><br>
> > <alias>newalias</alias><br>
> > </disk><br>
> ><br>
> > Note that you can use the above "v3" prefix in the URL or<br>
> else the<br>
> > "Version: 3" header. A complete example using curl:<br>
> ><br>
> > ---8<---<br>
> > #!/bin/bash -ex<br>
> ><br>
> > url="https://.../ovirt-engine/<wbr>api"<br>
> > user="admin@internal"<br>
> > password="..."<br>
> > vm_id="..."<br>
> > disk_id="..."<br>
> ><br>
> > curl \<br>
> > --verbose \<br>
> > --cacert "ca.pem" \<br>
> > --header "Version: 3" \<br>
> > --header "Content-Type: application/xml" \<br>
> > --user "${user}:${password}" \<br>
> > --request PUT \<br>
> > --data "<br>
> > <disk><br>
> > <alias>newalias</alias><br>
> > </disk><br>
> > " \<br>
> > "${url}/vms/${vm_id}/disks/${<wbr>disk_id}"<br>
> > --->8---<br>
> ><br>
> > ><br>
> > > On Wed, Jun 28, 2017 at 10:07 AM, Daniel Erez<br>
> <<a href="mailto:derez@redhat.com">derez@redhat.com</a> <mailto:<a href="mailto:derez@redhat.com">derez@redhat.com</a>> <mailto:<a href="mailto:derez@redhat.com">derez@redhat.com</a><br>
> <mailto:<a href="mailto:derez@redhat.com">derez@redhat.com</a>>><br>
> > > <mailto:<a href="mailto:derez@redhat.com">derez@redhat.com</a> <mailto:<a href="mailto:derez@redhat.com">derez@redhat.com</a>> <mailto:<a href="mailto:derez@redhat.com">derez@redhat.com</a><br>
> <mailto:<a href="mailto:derez@redhat.com">derez@redhat.com</a>>>>> wrote:<br>
> > ><br>
> > > Hi,<br>
> > ><br>
> > > Updating is done using the PUT method.<br>
> > > Please try that with the same XML body.<br>
> > ><br>
> > > Thanks,<br>
> > > Daniel<br>
> > ><br>
> > > On Wed, Jun 28, 2017 at 10:26 AM Bruno Rodriguez <<a href="mailto:bruno@pic.es">bruno@pic.es</a> <mailto:<a href="mailto:bruno@pic.es">bruno@pic.es</a>> <mailto:<a href="mailto:bruno@pic.es">bruno@pic.es</a><br>
> <mailto:<a href="mailto:bruno@pic.es">bruno@pic.es</a>>><br>
> > > <mailto:<a href="mailto:bruno@pic.es">bruno@pic.es</a> <mailto:<a href="mailto:bruno@pic.es">bruno@pic.es</a>><br>
> <mailto:<a href="mailto:bruno@pic.es">bruno@pic.es</a> <mailto:<a href="mailto:bruno@pic.es">bruno@pic.es</a>>>>> wrote:<br>
> > ><br>
> > > Hello everyone,<br>
> > ><br>
> > > I'm having some problems about renaming some<br>
> disks (setting a<br>
> > > different alias, name or description) for VMs<br>
> disks created from<br>
> > > a template. When I get this URL<br>
> > ><br>
> > ><br>
> <a href="https://ovirt-manager/ovirt-engine/api/disks/0123" rel="noreferrer" target="_blank">https://ovirt-manager/ovirt-<wbr>engine/api/disks/0123</a><br>
> <<a href="https://ovirt-manager/ovirt-engine/api/disks/0123" rel="noreferrer" target="_blank">https://ovirt-manager/ovirt-<wbr>engine/api/disks/0123</a>><br>
> > <<a href="https://ovirt-manager/ovirt-engine/api/disks/0123" rel="noreferrer" target="_blank">https://ovirt-manager/ovirt-<wbr>engine/api/disks/0123</a><br>
> <<a href="https://ovirt-manager/ovirt-engine/api/disks/0123" rel="noreferrer" target="_blank">https://ovirt-manager/ovirt-<wbr>engine/api/disks/0123</a>>><br>
> > ><br>
> <<a href="https://ovirt-manager/ovirt-engine/api/disks/0123" rel="noreferrer" target="_blank">https://ovirt-manager/ovirt-<wbr>engine/api/disks/0123</a><br>
> <<a href="https://ovirt-manager/ovirt-engine/api/disks/0123" rel="noreferrer" target="_blank">https://ovirt-manager/ovirt-<wbr>engine/api/disks/0123</a>><br>
> > <<a href="https://ovirt-manager/ovirt-engine/api/disks/0123" rel="noreferrer" target="_blank">https://ovirt-manager/ovirt-<wbr>engine/api/disks/0123</a><br>
> <<a href="https://ovirt-manager/ovirt-engine/api/disks/0123" rel="noreferrer" target="_blank">https://ovirt-manager/ovirt-<wbr>engine/api/disks/0123</a>>>><br>
> > ><br>
> > > I can see are the methods sparsify, export, move<br>
> and copy. I<br>
> > > tried to POST the following XML to the previous<br>
> URL with no<br>
> > > result (as expected, it won't work)<br>
> > ><br>
> > > <disk><br>
> > > <alias>my_machine_Disk1</<wbr>alias><br>
> > > </disk><br>
> > ><br>
> > > I'm quite sure I'm thinking about it in a wrong<br>
> way (as usual).<br>
> > > Any help would be welcome...<br>
> > ><br>
> > > Thank you in advance<br>
> > ><br>
> > > --<br>
> > > Bruno Rodríguez Rodríguez<br>
> > ><br>
> > > *Port d'Informació Científica (PIC)*<br>
> > ><br>
> > > ______________________________<wbr>_________________<br>
> > > Users mailing list<br>
> > > <a href="mailto:Users@ovirt.org">Users@ovirt.org</a> <mailto:<a href="mailto:Users@ovirt.org">Users@ovirt.org</a>><br>
> <mailto:<a href="mailto:Users@ovirt.org">Users@ovirt.org</a> <mailto:<a href="mailto:Users@ovirt.org">Users@ovirt.org</a>>><br>
> > <mailto:<a href="mailto:Users@ovirt.org">Users@ovirt.org</a> <mailto:<a href="mailto:Users@ovirt.org">Users@ovirt.org</a>><br>
> <mailto:<a href="mailto:Users@ovirt.org">Users@ovirt.org</a> <mailto:<a href="mailto:Users@ovirt.org">Users@ovirt.org</a>>>><br>
> > > <a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a><br>
> <<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a>><br>
> > <<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a><br>
> <<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a>>><br>
> > > <<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a><br>
> <<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a>><br>
> > <<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a><br>
> <<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a>>>><br>
> > ><br>
> > ><br>
> > ><br>
> > ><br>
> > > --<br>
> > > Bruno Rodríguez Rodríguez<br>
> > ><br>
> > > *Port d'Informació Científica (PIC)*<br>
> > > Campus UAB - Edificio D,<br>
> > > C / Albareda, s / n<br>
> > > 08193-Bellaterra (Barcelona), España<br>
> > > Telf. <a href="tel:%2B34%2093%20170%2027%2030" value="+34931702730">+34 93 170 27 30</a> <tel:%2B34%2093%20170%2027%<wbr>2030><br>
> <tel:%2B34%2093%20170%2027%<wbr>2030><br>
> > > GPS coordenadas: 41.500850 2.110628<br>
> > ><br>
> > > "Si algo me ha enseñado el tetris, es que los errores se<br>
> acumulan y los<br>
> > > triunfos desaparecen"<br>
> > ><br>
> > ><br>
> > > ______________________________<wbr>_________________<br>
> > > Users mailing list<br>
> > > <a href="mailto:Users@ovirt.org">Users@ovirt.org</a> <mailto:<a href="mailto:Users@ovirt.org">Users@ovirt.org</a>><br>
> <mailto:<a href="mailto:Users@ovirt.org">Users@ovirt.org</a> <mailto:<a href="mailto:Users@ovirt.org">Users@ovirt.org</a>>><br>
> > > <a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a><br>
> <<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a>><br>
> > <<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a><br>
> <<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/<wbr>mailman/listinfo/users</a>>><br>
> > ><br>
> ><br>
> ><br>
> ><br>
> ><br>
> > --<br>
> > Bruno Rodríguez Rodríguez<br>
> ><br>
> > *Port d'Informació Científica (PIC)*<br>
> > Campus UAB - Edificio D,<br>
> > C / Albareda, s / n<br>
> > 08193-Bellaterra (Barcelona), España<br>
> > Telf. <a href="tel:%2B34%2093%20170%2027%2030" value="+34931702730">+34 93 170 27 30</a> <tel:%2B34%2093%20170%2027%<wbr>2030><br>
> > GPS coordenadas: 41.500850 2.110628<br>
> ><br>
> > "Si algo me ha enseñado el tetris, es que los errores se<br>
> acumulan y<br>
> > los triunfos desaparecen"<br>
> ><br>
> ><br>
> ><br>
> ><br>
> > --<br>
> > Bruno Rodríguez Rodríguez<br>
> ><br>
> > *Port d'Informació Científica (PIC)*<br>
> > Campus UAB - Edificio D,<br>
> > C / Albareda, s / n<br>
> > 08193-Bellaterra (Barcelona), España<br>
> > Telf. +34 93 170 27 30 <tel:%2B34%2093%20170%2027%<wbr>2030><br>
> > GPS coordenadas: 41.500850 2.110628<br>
> ><br>
> > "Si algo me ha enseñado el tetris, es que los errores se acumulan<br>
> y los<br>
> > triunfos desaparecen"<br>
><br>
><br>
><br>
><br>
</div></div><div class="HOEnZb"><div class="h5">> --<br>
> Bruno Rodríguez Rodríguez<br>
><br>
> *Port d'Informació Científica (PIC)*<br>
> Campus UAB - Edificio D,<br>
> C / Albareda, s / n<br>
> 08193-Bellaterra (Barcelona), España<br>
> Telf. <a href="tel:%2B34%2093%20170%2027%2030" value="+34931702730">+34 93 170 27 30</a><br>
> GPS coordenadas: 41.500850 2.110628<br>
><br>
> "Si algo me ha enseñado el tetris, es que los errores se acumulan y los<br>
> triunfos desaparecen"<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div style="text-align:left;font-family:Arial,Tahoma,Helvetica,FreeSans,sans-serif;line-height:20px;background-color:rgb(255,255,255)"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;line-height:normal">Bruno Rodríguez Rodríguez</span></div><div style="color:rgb(80,0,80);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br><div dir="ltr" style="color:rgb(34,34,34);font-size:12.8px"><font color="#444444"><b>Port d'Informació Científica (PIC)</b></font> <br>Campus UAB - Edificio D,</div><div dir="ltr" style="color:rgb(34,34,34);font-size:12.8px">C / <span>Albareda</span>, s / n <br>08193-Bellaterra (Barcelona), España</div><div style="color:rgb(34,34,34);font-size:12.8px"><a value="+34935813322" style="color:rgb(17,85,204);font-size:13px">Telf. +34 93 170 27 30</a><br></div><div dir="ltr" style="color:rgb(34,34,34);font-size:12.8px"><font color="#0000ff">GPS </font> coordenadas: <span style="font-size:12.8px">41.500850 2.110628</span></div></div><div><a value="+34935813322" style="color:rgb(17,85,204);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></a></div><div><a value="+34935813322" style="color:rgb(17,85,204);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><span style="color:rgb(0,0,0);font-family:Arial,Tahoma,Helvetica,FreeSans,sans-serif;font-size:small;line-height:20px">"Si algo me ha enseñado el tetris, es que los errores se acumulan y los triunfos desaparecen"</span></a></div></div></div></div></div></div></div>
</div>