Re: [ovirt-users] Attaching storage to VM via JSON REST
Done that: https://bugzilla.redhat.com/show_bug.cgi?id=1095682 Am 08.05.2014 13:09, schrieb Juan Hernandez: > I guess it is for historical reasons. We should probably accept both id > and name in both cases, giving precedence to id if both are given. Care > to open a RFE requesting so? -- 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] Attaching storage to VM via JSON REST
On 05/08/2014 12:59 PM, Sven Kieske wrote: > May I ask if there is any reason why this is so inconsistent? > (id vs name) > I guess it is for historical reasons. We should probably accept both id and name in both cases, giving precedence to id if both are given. Care to open a RFE requesting so? > Am 08.05.2014 11:34, schrieb Juan Hernandez: >> When adding a disk to a VM both a single domain storage and a list of >> storage domains are accepted. The JSON representation is the following: >> >> "storage_domain": { >> "id": "6fbee79d-5b71-48c1-b86c-ee9755a46013" >> } >> >> Note that "name" isn't accepted here, you have to use the "id". >> >> The JSON representation for multiple domains is the following (note that >> only the first one is used): >> >> "storage_domains": { >> "storage_domain": [ { >> "name": "am_data" >> } ] >> } >> >> Note that "id" isn't accepted here, you have to use "name". > -- 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] Attaching storage to VM via JSON REST
May I ask if there is any reason why this is so inconsistent? (id vs name) Am 08.05.2014 11:34, schrieb Juan Hernandez: > When adding a disk to a VM both a single domain storage and a list of > storage domains are accepted. The JSON representation is the following: > > "storage_domain": { > "id": "6fbee79d-5b71-48c1-b86c-ee9755a46013" > } > > Note that "name" isn't accepted here, you have to use the "id". > > The JSON representation for multiple domains is the following (note that > only the first one is used): > > "storage_domains": { > "storage_domain": [ { > "name": "am_data" > } ] > } > > Note that "id" isn't accepted here, you have to use "name". -- 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] Attaching storage to VM via JSON REST
On 05/08/2014 08:30 AM, Gadi Ickowicz wrote: > I have no experience using JSON myself (I use XML when using REST), however, > note that the storage_domain is a list of ids, inside of a storage_domains > object. Maybe try to send a request formatted like that? > > Juan - any other insights? > > Gadi Ickowicz > When adding a disk to a VM both a single domain storage and a list of storage domains are accepted. The JSON representation is the following: "storage_domain": { "id": "6fbee79d-5b71-48c1-b86c-ee9755a46013" } Note that "name" isn't accepted here, you have to use the "id". The JSON representation for multiple domains is the following (note that only the first one is used): "storage_domains": { "storage_domain": [ { "name": "am_data" } ] } Note that "id" isn't accepted here, you have to use "name". > - Original Message ----- > From: "Andrew Morrison" > To: users@ovirt.org > Sent: Wednesday, May 7, 2014 11:23:13 PM > Subject: [ovirt-users] Attaching storage to VM via JSON REST > > Hi all, > > I'm exploring using ovirt's REST APIs to manage VM creation/deletion/etc. I > can create the VM, attach an ISO and change boot order, but I'm unable to > attach a storage disk to the VM. I send a POST request to /api/vms/ uuid>/disks with the structure: > {"storage_domain": > {"name":"am_data", > "id":"6fbee79d-5b71-48c1-b86c-ee9755a46013" > }, > "size":"4294967296", > "type":"system", > "interface":"ide", > "format":"raw", > "sparse":"false", > "bootable":"true", > "wipe_after_delete":"false" > } > The response I receive is > { > "reason" : "Operation Failed", > "detail" : "[Cannot add Virtual Machine Disk. Storage Domain doesn't exist.]" > } > For the storage domain, I've tried just the name, just the id, and both with > the same results. When I attach storage from the GUI, the disk is > created/attached fine, and a GET request for the disks of the VM shows the > storage domain as the same as I was attempting to use before. > "storage_domains" : { > "storage_domain" : [ { > "id" : "6fbee79d-5b71-48c1-b86c-ee9755a46013" > } ] > }, > > Any idea what I might be doing wrong? > > Thanks, > Andrew > The problem with the JSON document that you are sending is that you are using strings to represent numeric and boolean values. That generates an exception inside the engine. Try the following: { "storage_domain": { "id": "6fbee79d-5b71-48c1-b86c-ee9755a46013" }, "size": 4294967296, "type": "system", "interface": "ide", "format": "raw", "sparse": false, "bootable": true, "wipe_after_delete": false } Note that "size" is an integer, no quotes allowed. Same for "sparse", "bootable" and "wipe_after_delete", they are booleans, no quotes allowed. The long exception message that you get when sending an incorrect JSON document is a bug in the error reporting path, it will be fixed in version 3.4.1: https://bugzilla.redhat.com/show_bug.cgi?id=1093755 -- 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] Attaching storage to VM via JSON REST
well, I don't know which version you are using, but there is a bug in 3.4.1. RC, which generates java exceptions when your json is incorrect: https://bugzilla.redhat.com/show_bug.cgi?id=1093755 Am 08.05.2014 08:44, schrieb Andrew Morrison: > If I try to use a storage domains object and a list of a storage > domain, I get a rather large Java stack trace of the same type as > when I have a key named incorrectly or when the request generally > contains invalid parameters. -- 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] Attaching storage to VM via JSON REST
If I try to use a storage domains object and a list of a storage domain, I get a rather large Java stack trace of the same type as when I have a key named incorrectly or when the request generally contains invalid parameters. Thanks, Andrew On May 7, 2014 11:30 PM, "Gadi Ickowicz" wrote: > I have no experience using JSON myself (I use XML when using REST), > however, note that the storage_domain is a list of ids, inside of a > storage_domains object. Maybe try to send a request formatted like that? > > Juan - any other insights? > > Gadi Ickowicz > > - Original Message - > From: "Andrew Morrison" > To: users@ovirt.org > Sent: Wednesday, May 7, 2014 11:23:13 PM > Subject: [ovirt-users] Attaching storage to VM via JSON REST > > Hi all, > > I'm exploring using ovirt's REST APIs to manage VM creation/deletion/etc. > I can create the VM, attach an ISO and change boot order, but I'm unable to > attach a storage disk to the VM. I send a POST request to /api/vms/ uuid>/disks with the structure: > {"storage_domain": > {"name":"am_data", > "id":"6fbee79d-5b71-48c1-b86c-ee9755a46013" > }, > "size":"4294967296", > "type":"system", > "interface":"ide", > "format":"raw", > "sparse":"false", > "bootable":"true", > "wipe_after_delete":"false" > } > The response I receive is > { > "reason" : "Operation Failed", > "detail" : "[Cannot add Virtual Machine Disk. Storage Domain doesn't > exist.]" > } > For the storage domain, I've tried just the name, just the id, and both > with the same results. When I attach storage from the GUI, the disk is > created/attached fine, and a GET request for the disks of the VM shows the > storage domain as the same as I was attempting to use before. > "storage_domains" : { > "storage_domain" : [ { > "id" : "6fbee79d-5b71-48c1-b86c-ee9755a46013" > } ] > }, > > Any idea what I might be doing wrong? > > Thanks, > Andrew > > ___ > Users mailing list > Users@ovirt.org > http://lists.ovirt.org/mailman/listinfo/users > ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
Re: [ovirt-users] Attaching storage to VM via JSON REST
I have no experience using JSON myself (I use XML when using REST), however, note that the storage_domain is a list of ids, inside of a storage_domains object. Maybe try to send a request formatted like that? Juan - any other insights? Gadi Ickowicz - Original Message - From: "Andrew Morrison" To: users@ovirt.org Sent: Wednesday, May 7, 2014 11:23:13 PM Subject: [ovirt-users] Attaching storage to VM via JSON REST Hi all, I'm exploring using ovirt's REST APIs to manage VM creation/deletion/etc. I can create the VM, attach an ISO and change boot order, but I'm unable to attach a storage disk to the VM. I send a POST request to /api/vms//disks with the structure: {"storage_domain": {"name":"am_data", "id":"6fbee79d-5b71-48c1-b86c-ee9755a46013" }, "size":"4294967296", "type":"system", "interface":"ide", "format":"raw", "sparse":"false", "bootable":"true", "wipe_after_delete":"false" } The response I receive is { "reason" : "Operation Failed", "detail" : "[Cannot add Virtual Machine Disk. Storage Domain doesn't exist.]" } For the storage domain, I've tried just the name, just the id, and both with the same results. When I attach storage from the GUI, the disk is created/attached fine, and a GET request for the disks of the VM shows the storage domain as the same as I was attempting to use before. "storage_domains" : { "storage_domain" : [ { "id" : "6fbee79d-5b71-48c1-b86c-ee9755a46013" } ] }, Any idea what I might be doing wrong? Thanks, Andrew ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
[ovirt-users] Attaching storage to VM via JSON REST
Hi all, I'm exploring using ovirt's REST APIs to manage VM creation/deletion/etc. I can create the VM, attach an ISO and change boot order, but I'm unable to attach a storage disk to the VM. I send a POST request to /api/vms//disks with the structure: {"storage_domain": {"name":"am_data", "id":"6fbee79d-5b71-48c1-b86c-ee9755a46013" }, "size":"4294967296", "type":"system", "interface":"ide", "format":"raw", "sparse":"false", "bootable":"true", "wipe_after_delete":"false" } The response I receive is { "reason" : "Operation Failed", "detail" : "[Cannot add Virtual Machine Disk. Storage Domain doesn't exist.]" } For the storage domain, I've tried just the name, just the id, and both with the same results. When I attach storage from the GUI, the disk is created/attached fine, and a GET request for the disks of the VM shows the storage domain as the same as I was attempting to use before. "storage_domains" : { "storage_domain" : [ { "id" : "6fbee79d-5b71-48c1-b86c-ee9755a46013" } ] }, Any idea what I might be doing wrong? Thanks, Andrew ___ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users