Cannot find the link between virtual machine and virtual disk
-
Hello,
I am starting to work on implementing the JSON RPC API on our side.
I can get virtual machines and virtual disks, but cannot find where to link both.I looked on XenOrchestra to see the ws messages but couldn't find on message where content indicate that one virtual disk is part a one vm.
Any help would be appreciated.
Best regards,
Paul BESRET. -
Hi,
In the lower layer (XAPI API), the link is called "VBD". See:
Source: https://xapi-project.github.io/xen-api/
That should be helpful to search what you need. Also, I'm pinging @julien-f for more details
-
@olivierlambert Thank's for the answer.
So do you have an "action" to use on the JSON RPC API which helps me join the VMs and VDI ? -
That's a question for @julien-f
-
@paul-besret No, you can fetch all objects from the API with the method
xo.getAllObjects
but then it's up to you to do the join.On this side, the REST API is much better, you can fetch a VM at
/rest/v0/vms/:id
and all its VDIs at/rest/vms/:id/vdis
.To understand how to interact with a collection, check out the documentation.
-
@julien-f Thank's for your answer.
So I understand that I have to get all the disks, then all the VMs and finally all the VBDs to be able to map, what disk is attached to what VM ?Is that right ?
Moreover, I can't wait to use the REST API in the future, but since it doesn't have enough functionality yet, we will stick to use only one third party system to avoid misunderstanding and technical debt.
Best regards,
Paul BESRET -
So I understand that I have to get all the disks, then all the VMs and finally all the VBDs to be able to map, what disk is attached to what VM ?
Exactly.
Moreover, I can't wait to use the REST API in the future, but since it doesn't have enough functionality yet, we will stick to use only one third party system to avoid misunderstanding and technical debt.
As you wish, objects are the same in both APIs.
-
@julien-f
Thanks a lot, I have been able to work on it today and it's works just fine.
Now I would like to reference the same disk on 2 differents VMs (it is possible, right ?)
But I cannot click on the button "Connect VBD", is there something i am missing ? -
@paul-besret A VDI cannot be attached to multiple running VMs at the same time, just like you cannot connect a physical disks to multiple computers.
-
@paul-besret What's your use case of this?
-
@julien-f
I found that it is possible to attach the same disk on multiple VMs, and succeded to do it on XOA web IHM.
So since it is possible, we have to handle this case in our integration. -
So in theory, you can attach a VDI to multiple VMs, by default if you plug it in read only on any extra VM.
If you want to mount the VDI on multiple VMs in read/write mode, you need to create a VDI with
sharable=true
flag in XAPI. However, then, you must use a shared-disk file system to be able to use it without corrupting data. -
@paul-besret It is indeed possible to do it but the VDI must be created as sharable, something which I believe is not currently possible on XO UI.
I'll investigate how the UI behave with such a VDI.
-
@julien-f Maybe we do not differentiate "attaching" a disk and "connecting" a disk. I just created a new disk then went to a VM to attach it, then did the same on another VM without problem on XO UI.
BUT it seems that I cannot "connect" it on both VMs, which is not a problem, I only need to know what's possible, and what's not to be able to handle it.Regards