[ovirt-users] Unable to rename disks via REST API
Bruno Rodriguez
bruno at pic.es
Fri Jun 30 10:57:27 UTC 2017
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).
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.
Sorry again :(
On Wed, Jun 28, 2017 at 1:56 PM, Juan Hernández <jhernand at redhat.com> wrote:
> On 06/28/2017 01:34 PM, Bruno Rodriguez wrote:
> > Shit, I got it. Sorry
> >
> > The problem is that I was accessing to the v4 disk-attachment id and I
> > was getting everything quite messed up. I was doing all of this while
> > creating a machine, so I was trying to rename the disk at the same time
> > it's being created.
> >
> > I'll delete all the "if ($ovirt_major == 3)" I have in my code. If I
> > have any problem I'll let you know.
> >
> > Thank you
> >
>
> If what you want to do is set the name of the disk for a VM that you are
> creating then you can just set it when adding the disk:
>
> POST /ovirt-engine/api/vms/123/diskattachments
>
> <disk_attachment>
> <disk>
> <name>yourfavoritename</name>
> ...
> </disk>
> ...
> </disk_attachment>
>
> That way you don't need to modify it later.
>
> Also, in general, try to wait till the objects are completely created
> before trying to use or update them. For disks in particular, it is good
> idea to repeatedly retrieve the disk till the 'status' is 'OK':
>
>
> https://github.com/oVirt/ovirt-engine-sdk/blob/master/
> sdk/examples/add_vm_disk.py#L73-L80
>
> (This is an example from the Python SDK, but you get the idea. There are
> SDKs for Ruby and Java as well.)
>
> Finally, if you get a 500 error then there is most probably a bug. The
> API should never return that, even if you try to do something that
> doesn't make sense it should respond with a reasonable error message. If
> you keep getting that 500 error please share the details.
>
> > On Wed, Jun 28, 2017 at 1:03 PM, Juan Hernández <jhernand at redhat.com
> > <mailto:jhernand at redhat.com>> wrote:
> >
> > On 06/28/2017 12:55 PM, Bruno Rodriguez wrote:
> > > I'm sorry about bothering you again, but after trying it some
> times I'm
> > > still getting a "500 Internal Server Error". I'm using a REST
> client
> > > instead of CURL and I tried adding a "Version: 3" to headers and
> used
> > > the URL with the v3 as well.
> > >
> > > I'm issuing a PUT of
> > >
> > > <disk><alias>Alias_for_disk</alias></disk>
> > >
> > > To the URL
> > >
> > > https://myserver/ovirt-engine/api/v3/vms/62498f51-0203-48b9-
> 83c8-4c6f3bdfe05c/disks/583ed952-46a8-4bc5-8a27-8660e4a24ea2
> > <https://myserver/ovirt-engine/api/v3/vms/62498f51-
> 0203-48b9-83c8-4c6f3bdfe05c/disks/583ed952-46a8-4bc5-8a27-8660e4a24ea2>
> > >
> > > I mean, I can live without it but we are using oVirt as a "static
> > > virtualization" environment and is quite useful for us being able
> to
> > > recognize easily each disk by its server name. In case I have to
> wait
> > > until the 4.2 API version to automatize this I'll do :(
> > >
> >
> > That should work. Can you please check if you get any useful message
> in
> > /var/log/ovirt-engine/server.log or /var/log/ovirt-engine/engine.
> log?
> >
> > >
> > >
> > > On Wed, Jun 28, 2017 at 11:18 AM, Bruno Rodriguez <bruno at pic.es
> <mailto:bruno at pic.es>
> > > <mailto:bruno at pic.es <mailto:bruno at pic.es>>> wrote:
> > >
> > > Thank you very much !!!
> > >
> > > I expected I was missing something like that. Thanks again!
> > >
> > > On Wed, Jun 28, 2017 at 11:12 AM, Juan Hernández
> > > <jhernand at redhat.com <mailto:jhernand at redhat.com>
> > <mailto:jhernand at redhat.com <mailto:jhernand at redhat.com>>> wrote:
> > >
> > > On 06/28/2017 10:43 AM, Bruno Rodriguez wrote:
> > > > Thank you, Daniel
> > > >
> > > > I tried a PUT with the same XML body, I got a "405
> > Method Not Allowed".
> > > > It's quite strange, there must be someting I'm missing
> > > >
> > >
> > > The operation to update a disk will be introduced in
> version 4
> > > of the
> > > API with version 4.2 of the engine. Meanwhile the way to
> > update
> > > the disk
> > > is to use version 3 of the API and the disks
> > sub-collection of the
> > > virtual machine. That means that if you have a VM with id
> 123
> > > and a disk
> > > with id 456 you can send a request like this:
> > >
> > > PUT /ovirt-engine/api/v3/vms/123/disks/456
> > >
> > > With a request body like this:
> > >
> > > <disk>
> > > <alias>newalias</alias>
> > > </disk>
> > >
> > > Note that you can use the above "v3" prefix in the URL or
> > else the
> > > "Version: 3" header. A complete example using curl:
> > >
> > > ---8<---
> > > #!/bin/bash -ex
> > >
> > > url="https://.../ovirt-engine/api"
> > > user="admin at internal"
> > > password="..."
> > > vm_id="..."
> > > disk_id="..."
> > >
> > > curl \
> > > --verbose \
> > > --cacert "ca.pem" \
> > > --header "Version: 3" \
> > > --header "Content-Type: application/xml" \
> > > --user "${user}:${password}" \
> > > --request PUT \
> > > --data "
> > > <disk>
> > > <alias>newalias</alias>
> > > </disk>
> > > " \
> > > "${url}/vms/${vm_id}/disks/${disk_id}"
> > > --->8---
> > >
> > > >
> > > > On Wed, Jun 28, 2017 at 10:07 AM, Daniel Erez
> > <derez at redhat.com <mailto:derez at redhat.com> <mailto:derez at redhat.com
> > <mailto:derez at redhat.com>>
> > > > <mailto:derez at redhat.com <mailto:derez at redhat.com>
> <mailto:derez at redhat.com
> > <mailto:derez at redhat.com>>>> wrote:
> > > >
> > > > Hi,
> > > >
> > > > Updating is done using the PUT method.
> > > > Please try that with the same XML body.
> > > >
> > > > Thanks,
> > > > Daniel
> > > >
> > > > On Wed, Jun 28, 2017 at 10:26 AM Bruno Rodriguez <
> bruno at pic.es <mailto:bruno at pic.es> <mailto:bruno at pic.es
> > <mailto:bruno at pic.es>>
> > > > <mailto:bruno at pic.es <mailto:bruno at pic.es>
> > <mailto:bruno at pic.es <mailto:bruno at pic.es>>>> wrote:
> > > >
> > > > Hello everyone,
> > > >
> > > > I'm having some problems about renaming some
> > disks (setting a
> > > > different alias, name or description) for VMs
> > disks created from
> > > > a template. When I get this URL
> > > >
> > > >
> > https://ovirt-manager/ovirt-engine/api/disks/0123
> > <https://ovirt-manager/ovirt-engine/api/disks/0123>
> > > <https://ovirt-manager/ovirt-engine/api/disks/0123
> > <https://ovirt-manager/ovirt-engine/api/disks/0123>>
> > > >
> > <https://ovirt-manager/ovirt-engine/api/disks/0123
> > <https://ovirt-manager/ovirt-engine/api/disks/0123>
> > > <https://ovirt-manager/ovirt-engine/api/disks/0123
> > <https://ovirt-manager/ovirt-engine/api/disks/0123>>>
> > > >
> > > > I can see are the methods sparsify, export, move
> > and copy. I
> > > > tried to POST the following XML to the previous
> > URL with no
> > > > result (as expected, it won't work)
> > > >
> > > > <disk>
> > > > <alias>my_machine_Disk1</alias>
> > > > </disk>
> > > >
> > > > I'm quite sure I'm thinking about it in a wrong
> > way (as usual).
> > > > Any help would be welcome...
> > > >
> > > > Thank you in advance
> > > >
> > > > --
> > > > Bruno Rodríguez Rodríguez
> > > >
> > > > *Port d'Informació Científica (PIC)*
> > > >
> > > > _______________________________________________
> > > > Users mailing list
> > > > Users at ovirt.org <mailto:Users at ovirt.org>
> > <mailto:Users at ovirt.org <mailto:Users at ovirt.org>>
> > > <mailto:Users at ovirt.org <mailto:Users at ovirt.org>
> > <mailto:Users at ovirt.org <mailto:Users at ovirt.org>>>
> > > > http://lists.ovirt.org/mailman/listinfo/users
> > <http://lists.ovirt.org/mailman/listinfo/users>
> > > <http://lists.ovirt.org/mailman/listinfo/users
> > <http://lists.ovirt.org/mailman/listinfo/users>>
> > > > <http://lists.ovirt.org/mailman/listinfo/users
> > <http://lists.ovirt.org/mailman/listinfo/users>
> > > <http://lists.ovirt.org/mailman/listinfo/users
> > <http://lists.ovirt.org/mailman/listinfo/users>>>
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Bruno Rodríguez Rodríguez
> > > >
> > > > *Port d'Informació Científica (PIC)*
> > > > Campus UAB - Edificio D,
> > > > C / Albareda, s / n
> > > > 08193-Bellaterra (Barcelona), España
> > > > Telf. +34 93 170 27 30 <tel:%2B34%2093%20170%2027%2030>
> > <tel:%2B34%2093%20170%2027%2030>
> > > > GPS coordenadas: 41.500850 2.110628
> > > >
> > > > "Si algo me ha enseñado el tetris, es que los errores se
> > acumulan y los
> > > > triunfos desaparecen"
> > > >
> > > >
> > > > _______________________________________________
> > > > Users mailing list
> > > > Users at ovirt.org <mailto:Users at ovirt.org>
> > <mailto:Users at ovirt.org <mailto:Users at ovirt.org>>
> > > > http://lists.ovirt.org/mailman/listinfo/users
> > <http://lists.ovirt.org/mailman/listinfo/users>
> > > <http://lists.ovirt.org/mailman/listinfo/users
> > <http://lists.ovirt.org/mailman/listinfo/users>>
> > > >
> > >
> > >
> > >
> > >
> > > --
> > > Bruno Rodríguez Rodríguez
> > >
> > > *Port d'Informació Científica (PIC)*
> > > Campus UAB - Edificio D,
> > > C / Albareda, s / n
> > > 08193-Bellaterra (Barcelona), España
> > > Telf. +34 93 170 27 30 <tel:%2B34%2093%20170%2027%2030>
> > > GPS coordenadas: 41.500850 2.110628
> > >
> > > "Si algo me ha enseñado el tetris, es que los errores se
> > acumulan y
> > > los triunfos desaparecen"
> > >
> > >
> > >
> > >
> > > --
> > > Bruno Rodríguez Rodríguez
> > >
> > > *Port d'Informació Científica (PIC)*
> > > Campus UAB - Edificio D,
> > > C / Albareda, s / n
> > > 08193-Bellaterra (Barcelona), España
> > > Telf. +34 93 170 27 30 <tel:%2B34%2093%20170%2027%2030>
> > > GPS coordenadas: 41.500850 2.110628
> > >
> > > "Si algo me ha enseñado el tetris, es que los errores se acumulan
> > y los
> > > triunfos desaparecen"
> >
> >
> >
> >
> > --
> > Bruno Rodríguez Rodríguez
> >
> > *Port d'Informació Científica (PIC)*
> > Campus UAB - Edificio D,
> > C / Albareda, s / n
> > 08193-Bellaterra (Barcelona), España
> > Telf. +34 93 170 27 30
> > GPS coordenadas: 41.500850 2.110628
> >
> > "Si algo me ha enseñado el tetris, es que los errores se acumulan y los
> > triunfos desaparecen"
>
>
--
Bruno Rodríguez Rodríguez
*Port d'Informació Científica (PIC)*
Campus UAB - Edificio D,
C / Albareda, s / n
08193-Bellaterra (Barcelona), España
Telf. +34 93 170 27 30
GPS coordenadas: 41.500850 2.110628
"Si algo me ha enseñado el tetris, es que los errores se acumulan y los
triunfos desaparecen"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ovirt.org/pipermail/users/attachments/20170630/7c706783/attachment-0001.html>
More information about the Users
mailing list